Class Stack<E>
- java.lang.Object
- 
- org.apache.tapestry5.commons.util.Stack<E>
 
- 
- Type Parameters:
- E- the type of elements stored in the map
 
 public class Stack<E> extends java.lang.Object A simple, streamlined implementation ofStack. The implementation is not threadsafe.- See Also:
- CollectionFactory.newStack()
 
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the stack, the same as popping off all elements.intgetDepth()Returns the number of items currently in the stack.java.lang.Object[]getSnapshot()Returns a snapshot of the current state of the stack as an array of objects.booleanisEmpty()Returns true if the stack is empty.Epeek()Returns the top element of the stack without affecting the stack.Epop()Pops the top element off the stack and returns it.voidpush(E item)Pushes a new item onto the stack.java.lang.StringtoString()Describes the stack, listing the element in order of depth (top element first).
 
- 
- 
- 
Method Detail- 
isEmptypublic boolean isEmpty() Returns true if the stack is empty.
 - 
getDepthpublic int getDepth() Returns the number of items currently in the stack.
 - 
clearpublic void clear() Clears the stack, the same as popping off all elements.
 - 
poppublic E pop() Pops the top element off the stack and returns it.- Returns:
- the top element of the stack
- Throws:
- java.lang.IllegalStateException- if the stack is empty
 
 - 
peekpublic E peek() Returns the top element of the stack without affecting the stack.- Returns:
- top element on the stack
- Throws:
- java.lang.IllegalStateException- if the stack is empty
 
 - 
toStringpublic java.lang.String toString() Describes the stack, listing the element in order of depth (top element first).- Overrides:
- toStringin class- java.lang.Object
- Returns:
- string description of the stack
 
 - 
getSnapshotpublic java.lang.Object[] getSnapshot() Returns a snapshot of the current state of the stack as an array of objects. The first object is the deepest in the stack, the last object is the most shallowest (most recently pushed onto the stack). The returned array may be manipulated (it is a copy).- Returns:
- the stack as an object array
 
 
- 
 
-