public final class NamedStack<E>
extends java.lang.Object
NamedStack is a data structure that allows named items to be placed on a stack. When it comes time to pop data off the stack, the pop operation takes the name of the item to be popped, and all items pushed on the stack after the named item will also be popped.
That is, NamedStack is basically a Stack that supports rollback to a named state. It is used in the Ganymede server to support checkpoint operations.
NamedStack does not require that names of pushed items be unique. A pop operation will simply pop up to the last item matching the given name off the stack.
| Modifier and Type | Field and Description |
|---|---|
private java.util.Stack<NamedStackHandle<E>> |
stack |
| Constructor and Description |
|---|
NamedStack() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
E |
elementAt(int index) |
boolean |
empty() |
int |
findName(java.lang.String name)
findName() returns the top-most index at which the name is
present in the named object stack, or -1 if the name was not found.
|
java.lang.String |
getTopName()
This method returns the name associated with the last item pushed
onto this name stack, without altering the stack.
|
E |
getTopObject()
This method returns the object associated with the last item pushed
onto this name stack, without altering the stack.
|
java.lang.String |
nameAt(int index) |
E |
pop()
This is just plain old pop, it will return the top element
without regard to its name.
|
E |
pop(java.lang.String name)
pop rolls the state of the stack back to the time just before
the top-most named object matching name was pushed.
|
E |
push(java.lang.String name,
E item)
push pushes a named item onto the stack.
|
void |
removeAllElements() |
int |
size() |
java.lang.String |
toString() |
private java.util.Stack<NamedStackHandle<E>> stack
public E pop(java.lang.String name)
pop rolls the state of the stack back to the time just before the top-most named object matching name was pushed.
public E pop()
This is just plain old pop, it will return the top element without regard to its name.
public E elementAt(int index)
public java.lang.String nameAt(int index)
public int size()
public void clear()
public void removeAllElements()
public java.lang.String getTopName()
This method returns the name associated with the last item pushed onto this name stack, without altering the stack.
public E getTopObject()
This method returns the object associated with the last item pushed onto this name stack, without altering the stack.
public int findName(java.lang.String name)
findName() returns the top-most index at which the name is present in the named object stack, or -1 if the name was not found.
public boolean empty()
public java.lang.String toString()
toString in class java.lang.Object