Interface Stack<K>

All Known Subinterfaces:
BooleanStack, ByteStack, CharStack, DoubleStack, FloatStack, IntStack, LongStack, ShortStack
All Known Implementing Classes:
AbstractBooleanBigList, AbstractBooleanBigList.BooleanRandomAccessSubList, AbstractBooleanBigList.BooleanSubList, AbstractBooleanList, AbstractBooleanList.BooleanRandomAccessSubList, AbstractBooleanList.BooleanSubList, AbstractBooleanStack, AbstractByteBigList, AbstractByteBigList.ByteRandomAccessSubList, AbstractByteBigList.ByteSubList, AbstractByteList, AbstractByteList.ByteRandomAccessSubList, AbstractByteList.ByteSubList, AbstractByteStack, AbstractCharBigList, AbstractCharBigList.CharRandomAccessSubList, AbstractCharBigList.CharSubList, AbstractCharList, AbstractCharList.CharRandomAccessSubList, AbstractCharList.CharSubList, AbstractCharStack, AbstractDoubleBigList, AbstractDoubleBigList.DoubleRandomAccessSubList, AbstractDoubleBigList.DoubleSubList, AbstractDoubleList, AbstractDoubleList.DoubleRandomAccessSubList, AbstractDoubleList.DoubleSubList, AbstractDoubleStack, AbstractFloatBigList, AbstractFloatBigList.FloatRandomAccessSubList, AbstractFloatBigList.FloatSubList, AbstractFloatList, AbstractFloatList.FloatRandomAccessSubList, AbstractFloatList.FloatSubList, AbstractFloatStack, AbstractIntBigList, AbstractIntBigList.IntRandomAccessSubList, AbstractIntBigList.IntSubList, AbstractIntList, AbstractIntList.IntRandomAccessSubList, AbstractIntList.IntSubList, AbstractIntStack, AbstractLongBigList, AbstractLongBigList.LongRandomAccessSubList, AbstractLongBigList.LongSubList, AbstractLongList, AbstractLongList.LongRandomAccessSubList, AbstractLongList.LongSubList, AbstractLongStack, AbstractObjectBigList, AbstractObjectBigList.ObjectRandomAccessSubList, AbstractObjectBigList.ObjectSubList, AbstractObjectList, AbstractObjectList.ObjectRandomAccessSubList, AbstractObjectList.ObjectSubList, AbstractReferenceBigList, AbstractReferenceBigList.ReferenceRandomAccessSubList, AbstractReferenceBigList.ReferenceSubList, AbstractReferenceList, AbstractReferenceList.ReferenceRandomAccessSubList, AbstractReferenceList.ReferenceSubList, AbstractShortBigList, AbstractShortBigList.ShortRandomAccessSubList, AbstractShortBigList.ShortSubList, AbstractShortList, AbstractShortList.ShortRandomAccessSubList, AbstractShortList.ShortSubList, AbstractShortStack, AbstractStack, BooleanArrayList, BooleanBigArrayBigList, BooleanBigLists.ListBigList, BooleanBigLists.Singleton, BooleanImmutableList, BooleanLists.Singleton, ByteArrayFrontCodedBigList, ByteArrayFrontCodedList, ByteArrayList, ByteBigArrayBigList, ByteBigLists.ListBigList, ByteBigLists.Singleton, ByteImmutableList, ByteLists.Singleton, ByteMappedBigList, CharArrayFrontCodedBigList, CharArrayFrontCodedList, CharArrayList, CharBigArrayBigList, CharBigLists.ListBigList, CharBigLists.Singleton, CharImmutableList, CharLists.Singleton, CharMappedBigList, DoubleArrayList, DoubleBigArrayBigList, DoubleBigLists.ListBigList, DoubleBigLists.Singleton, DoubleImmutableList, DoubleLists.Singleton, DoubleMappedBigList, FloatArrayList, FloatBigArrayBigList, FloatBigLists.ListBigList, FloatBigLists.Singleton, FloatImmutableList, FloatLists.Singleton, FloatMappedBigList, IntArrayFrontCodedBigList, IntArrayFrontCodedList, IntArrayList, IntBigArrayBigList, IntBigLists.ListBigList, IntBigLists.Singleton, IntImmutableList, IntLists.Singleton, IntMappedBigList, LongArrayFrontCodedBigList, LongArrayFrontCodedList, LongArrayList, LongBigArrayBigList, LongBigLists.ListBigList, LongBigLists.Singleton, LongImmutableList, LongLists.Singleton, LongMappedBigList, ObjectArrayList, ObjectBigArrayBigList, ObjectBigLists.ListBigList, ObjectBigLists.Singleton, ObjectImmutableList, ObjectLists.Singleton, ReferenceArrayList, ReferenceBigArrayBigList, ReferenceBigLists.ListBigList, ReferenceBigLists.Singleton, ReferenceImmutableList, ReferenceLists.Singleton, ShortArrayFrontCodedBigList, ShortArrayFrontCodedList, ShortArrayList, ShortBigArrayBigList, ShortBigLists.ListBigList, ShortBigLists.Singleton, ShortImmutableList, ShortLists.Singleton, ShortMappedBigList

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

    Modifier and Type
    Method
    Description
    boolean
    Checks whether the stack is empty.
    default K
    peek(int i)
    Peeks at an element on the stack (optional operation).
    pop()
    Pops the top off the stack.
    void
    push(K o)
    Pushes the given object on the stack.
    default K
    top()
    Peeks at the top of the stack (optional operation).
  • Method Details

    • 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

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

      This default implementation returns peek(0).

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

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

      This default implementation just throws an UnsupportedOperationException.

      Parameters:
      i - an index from the stop of the stack (0 represents the top).
      Returns:
      the i-th element on the stack.
      Throws:
      IndexOutOfBoundsException - if the designated element does not exist..