E
- the type of elements stored in the mappublic class Stack<E> extends Object
Stack
. The implementation is not threadsafe.CollectionFactory.newStack()
Constructor and Description |
---|
Stack()
Normal constructor supporting an initial size of 20.
|
Stack(int initialSize) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the stack, the same as popping off all elements.
|
int |
getDepth()
Returns the number of items currently in the stack.
|
Object[] |
getSnapshot()
Returns a snapshot of the current state of the stack as an array of objects.
|
boolean |
isEmpty()
Returns true if the stack is empty.
|
E |
peek()
Returns the top element of the stack without affecting the stack.
|
E |
pop()
Pops the top element off the stack and returns it.
|
void |
push(E item)
Pushes a new item onto the stack.
|
String |
toString()
Describes the stack, listing the element in order of depth (top element first).
|
public Stack()
public Stack(int initialSize)
initialSize
- the initial size of the internal array (which will be expanded as necessary). For best
efficiency, set this to the maximum depth of the stack.public boolean isEmpty()
public int getDepth()
public void clear()
public E pop()
IllegalStateException
- if the stack is emptypublic E peek()
IllegalStateException
- if the stack is emptypublic String toString()
public Object[] getSnapshot()
${project.version} - Copyright © 2003-2015 The Apache Software Foundation.