public class IntArrayStack extends Object
Modifier and Type | Class and Description |
---|---|
static class |
IntArrayStack.UnderflowException |
Constructor and Description |
---|
IntArrayStack() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Empties the stack.
|
void |
getElements(int[] destArray,
int destStartIndex)
Copies all elements currently on the stack into the given array.
|
boolean |
isEmpty()
Tests if the stack is empty.
|
int |
peek()
Returns the item at the top of the stack without removing it.
|
int |
pop()
Removes the most recently inserted item from the stack.
|
void |
push(int x)
Pushes a new item onto the stack.
|
int |
size()
Returns the number of element currently on the stack.
|
int[] |
toArray() |
public boolean isEmpty()
public int size()
public void getElements(int[] destArray, int destStartIndex)
destArray
- the arraydestStartIndex
- the index to start copying intopublic int[] toArray()
public void clear()
public int peek()
IntArrayStack.UnderflowException
- if the stack is empty.public int pop()
IntArrayStack.UnderflowException
- if the stack is empty.public void push(int x)
x
- the item to add.Copyright © 2013. All rights reserved.