it.unimi.dsi.fastutil
Interface Stack<K>

All Known Subinterfaces:
BooleanStack, ByteStack, CharStack, DoubleStack, FloatStack, IntStack, LongStack, ShortStack
All Known Implementing Classes:
AbstractBooleanBigList, AbstractBooleanBigList.BooleanSubList, AbstractBooleanList, AbstractBooleanList.BooleanSubList, AbstractBooleanStack, AbstractByteBigList, AbstractByteBigList.ByteSubList, AbstractByteList, AbstractByteList.ByteSubList, AbstractByteStack, AbstractCharBigList, AbstractCharBigList.CharSubList, AbstractCharList, AbstractCharList.CharSubList, AbstractCharStack, AbstractDoubleBigList, AbstractDoubleBigList.DoubleSubList, AbstractDoubleList, AbstractDoubleList.DoubleSubList, AbstractDoubleStack, AbstractFloatBigList, AbstractFloatBigList.FloatSubList, AbstractFloatList, AbstractFloatList.FloatSubList, AbstractFloatStack, AbstractIntBigList, AbstractIntBigList.IntSubList, AbstractIntList, AbstractIntList.IntSubList, AbstractIntStack, AbstractLongBigList, AbstractLongBigList.LongSubList, AbstractLongList, AbstractLongList.LongSubList, AbstractLongStack, AbstractObjectBigList, AbstractObjectBigList.ObjectSubList, AbstractObjectList, AbstractObjectList.ObjectSubList, AbstractReferenceBigList, AbstractReferenceBigList.ReferenceSubList, AbstractReferenceList, AbstractReferenceList.ReferenceSubList, AbstractShortBigList, AbstractShortBigList.ShortSubList, AbstractShortList, AbstractShortList.ShortSubList, AbstractShortStack, AbstractStack, BooleanArrayList, BooleanBigArrayBigList, BooleanBigLists.ListBigList, BooleanBigLists.Singleton, BooleanLists.Singleton, ByteArrayFrontCodedList, ByteArrayList, ByteBigArrayBigList, ByteBigLists.ListBigList, ByteBigLists.Singleton, ByteLists.Singleton, CharArrayFrontCodedList, CharArrayList, CharBigArrayBigList, CharBigLists.ListBigList, CharBigLists.Singleton, CharLists.Singleton, DoubleArrayList, DoubleBigArrayBigList, DoubleBigLists.ListBigList, DoubleBigLists.Singleton, DoubleLists.Singleton, FloatArrayList, FloatBigArrayBigList, FloatBigLists.ListBigList, FloatBigLists.Singleton, FloatLists.Singleton, IntArrayFrontCodedList, IntArrayList, IntBigArrayBigList, IntBigLists.ListBigList, IntBigLists.Singleton, IntLists.Singleton, LongArrayFrontCodedList, LongArrayList, LongBigArrayBigList, LongBigLists.ListBigList, LongBigLists.Singleton, LongLists.Singleton, ObjectArrayList, ObjectBigArrayBigList, ObjectBigLists.ListBigList, ObjectBigLists.Singleton, ObjectLists.Singleton, ReferenceArrayList, ReferenceBigArrayBigList, ReferenceBigLists.ListBigList, ReferenceBigLists.Singleton, ReferenceLists.Singleton, ShortArrayFrontCodedList, ShortArrayList, ShortBigArrayBigList, ShortBigLists.ListBigList, ShortBigLists.Singleton, ShortLists.Singleton

public interface Stack<K>

A stack.

A stack must provide the classical push(Object) and pop() operations, but may be also peekable to some extent: it may provide just the top() function, or even a more powerful peek(int) method that provides access to all elements on the stack (indexed from the top, which has index 0).


Method Summary
 boolean isEmpty()
          Checks whether the stack is empty.
 K peek(int i)
          Peeks at an element on the stack (optional operation).
 K pop()
          Pops the top off the stack.
 void push(K o)
          Pushes the given object on the stack.
 K top()
          Peeks at the top of the stack (optional operation).
 

Method Detail

push

void push(K o)
Pushes the given object on the stack.

Parameters:
o - the object that will become the new top of the stack.

pop

K pop()
Pops the top off the stack.

Returns:
the top of the stack.
Throws:
NoSuchElementException - if the stack is empty.

isEmpty

boolean isEmpty()
Checks whether the stack is empty.

Returns:
true if the stack is empty.

top

K top()
Peeks at the top of the stack (optional operation).

Returns:
the top of the stack.
Throws:
NoSuchElementException - if the stack is empty.

peek

K peek(int i)
Peeks at an element on the stack (optional operation).

Returns:
the i-th element on the stack; 0 represents the top.
Throws:
IndexOutOfBoundsException - if the designated element does not exist..