Package org.simpleframework.xml.stream
Class Stack<T>
java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractList<T>
java.util.ArrayList<T>
org.simpleframework.xml.stream.Stack<T>
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<T>
,Collection<T>
,List<T>
,RandomAccess
,SequencedCollection<T>
- Direct Known Subclasses:
InputStack
,NodeStack
The
Stack
object is used to provide a lightweight
stack implementation. To ensure top performance this stack is not
synchronized and keeps track of elements using an array list.
A null from either a pop
or top
means
that the stack is empty. This allows the stack to be peeked at
even if it has not been populated with anything yet.-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbottom()
This is used to acquire the node from the bottom of the stack.pop()
This is used to remove the element from the top of this stack.This method is used to add an element to the top of the stack.top()
This is used to peek at the element from the top of this stack.Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
containsAll, reversed
-
Constructor Details
-
Stack
public Stack(int size) Constructor for theStack
object. This is used to create a stack that can be used to keep track of values in a first in last out manner. Typically this is used to determine if an XML element is in or out of context.- Parameters:
size
- this is the initial size of the stack to use
-
-
Method Details
-
pop
This is used to remove the element from the top of this stack. If the stack is empty then this will return null, as such it is not advisable to push null elements on the stack.- Returns:
- this returns the node element the top of the stack
-
top
This is used to peek at the element from the top of this stack. If the stack is empty then this will return null, as such it is not advisable to push null elements on the stack.- Returns:
- this returns the node element the top of the stack
-
bottom
This is used to acquire the node from the bottom of the stack. If the stack is empty then this will return null, as such it is not advisable to push null elements on the stack.- Returns:
- this returns the element from the bottom of the stack
-
push
This method is used to add an element to the top of the stack. Although it is possible to add a null element to the stack it is not advisable, as null is returned when the stack is empty.- Parameters:
value
- this is the element to add to the stack- Returns:
- this returns the actual node that has just been added
-