Class FixedStack<T>

java.lang.Object
panda.utilities.collection.FixedStack<T>
All Implemented Interfaces:
IStack<T>

public final class FixedStack<T> extends Object implements IStack<T>
  • Constructor Summary

    Constructors
    Constructor
    Description
    FixedStack(int size)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear the stack
    boolean
    Tests if stack is empty
    Check element on top of the stack
    pop()
    Removes the object at the top of this stack and returns that object as the value
    void
    push(T element)
    Pushes an item onto the top of this stack
    int
    Returns the number of items in this stack
    final T[]
    toArray(Class<T[]> arrayType)
    Converts stack into the array, ordered by the push order (the latest items are the first in array)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FixedStack

      public FixedStack(int size)
  • Method Details

    • push

      public void push(T element)
      Description copied from interface: IStack
      Pushes an item onto the top of this stack
      Specified by:
      push in interface IStack<T>
      Parameters:
      element - the item to be pushed onto this stack
    • peek

      public T peek()
      Description copied from interface: IStack
      Check element on top of the stack
      Specified by:
      peek in interface IStack<T>
      Returns:
      the value on top
    • pop

      public T pop()
      Description copied from interface: IStack
      Removes the object at the top of this stack and returns that object as the value
      Specified by:
      pop in interface IStack<T>
      Returns:
      the object at the top of this stack
    • size

      public int size()
      Description copied from interface: IStack
      Returns the number of items in this stack
      Specified by:
      size in interface IStack<T>
      Returns:
      the number of items
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: IStack
      Tests if stack is empty
      Specified by:
      isEmpty in interface IStack<T>
      Returns:
      true if and only if this stack contains no items
    • clear

      public void clear()
      Description copied from interface: IStack
      Clear the stack
      Specified by:
      clear in interface IStack<T>
    • toArray

      public final T[] toArray(Class<T[]> arrayType)
      Description copied from interface: IStack
      Converts stack into the array, ordered by the push order (the latest items are the first in array)
      Specified by:
      toArray in interface IStack<T>
      Returns:
      the array of items from stack