| Constructor and Description |
|---|
ArrayStack()
Constructs an empty stack with the inital capacity of 10.
|
ArrayStack(int initialCapacity) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
empty()
Returns true if the stack is empty; otherwise returns false.
|
void |
ensureCapacity(int minCapacity)
Increases the capacity of this ArrayStack, if necessary, to ensure that
it can hold at least the number of elements specified by the minimum
capacity argument.
|
Iterator<T> |
iterator()
Iterates over the items in this Stack, starting
at the top of the stack and working its way down.
|
T |
peek()
Looks at the object at the top of this stack without removing it from the stack.
|
T |
pop()
Removes the object at the top of this stack and returns that object as the value of this function.
|
T |
push(T item)
Pushes an item onto the top of this stack and returns it.
|
int |
search(Object o)
Returns the 1-based position where an object is on this stack.
|
int |
size()
Returns the size of this stack.
|
void |
trimToSize()
Trims the capacity of this ArrayStack to be the
stack's current size.
|
forEach, spliteratorpublic ArrayStack()
no this.elems'public ArrayStack(int initialCapacity)
public boolean empty()
Stackempty in class Stack<T>Stack.empty()public void ensureCapacity(int minCapacity)
public Iterator<T> iterator()
public T peek()
Stackpeek in class Stack<T>Stack.peek()public T pop()
Stackpop in class Stack<T>this.size' = this.size - 1 &&
all i: [1..this.size) | this.elems'[i-1] = this.elems[i]Stack.pop()public T push(T item)
push in class Stack<T>this.size' = this.size + 1 && this.elems'[0] = item &&
all i: [0..this.size) | this.elems'[i+1] = this.elems[i]Stack.push(T)public int search(Object o)
Stacksearch in class Stack<T>Stack.search(java.lang.Object)public int size()
Stacksize in class Stack<T>Stack.size()public void trimToSize()
© Emina Torlak 2005-present