Top Description Fields Constructors Methods
org.glassfish.pfl.basic.contain

public final Class MarkStack<E>

extends Object
Class Inheritance
Imports
java.util.ArrayList, .EmptyStackException, .LinkedList, .List

A stack with additional operations that support recording the current top of stack as a mark, and then later popping all items pushed since the last mark call.

Field Summary

Modifier and TypeField and Description
private List<E>
private List<Integer>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
isEmpty()

Return true iff the stack is empty.

public void
mark()

Record the current position in the stack for a subsequent popMark call.

public E
peek()

Return the top element of the stack.

public E
pop()

Return the top element of the stack and remove it from the stack.

public List<E>
popMark()

Return an ordered list of stack elements starting with the element that was on top of the stack when mark was called.

public E
push(E elem)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

itemsback to summary
private List<E> items
marksback to summary
private List<Integer> marks

Constructor Detail

MarkStackback to summary
public MarkStack()

Method Detail

isEmptyback to summary
public boolean isEmpty()

Return true iff the stack is empty.

markback to summary
public void mark()

Record the current position in the stack for a subsequent popMark call. This allow marking the start of a related group of items on the stack that can be popped together later by popMark. Multiple mark calls are supported.

peekback to summary
public E peek()

Return the top element of the stack. Does not change the stack.

Exceptions
EmptyStackException:
is thrown if the stack is empty.
popback to summary
public E pop()

Return the top element of the stack and remove it from the stack.

Exceptions
EmptyStackException:
is thrown if the stack is empty.
IllegalStateException:
if an attempt is made to pop past the top mark.
popMarkback to summary
public List<E> popMark()

Return an ordered list of stack elements starting with the element that was on top of the stack when mark was called.

pushback to summary
public E push(E elem)