Class CircleStack<E>

  • All Implemented Interfaces:
    IOrderedStack<E>

    public abstract class CircleStack<E>
    extends java.lang.Object
    implements IOrderedStack<E>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Object[] container  
      private int index  
      private java.lang.Object[] pool  
      private int size  
    • Constructor Summary

      Constructors 
      Constructor Description
      CircleStack​(int argStackSize, int argContainerSize)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract E newInstance()
      Creates a new instance of the object contained by this stack.
      E pop()
      Returns the next object in the pool
      E[] pop​(int argNum)
      Returns the next 'argNum' objects in the pool in an array
      void push​(int argNum)
      Tells the stack to take back the last 'argNum' items
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pool

        private final java.lang.Object[] pool
      • index

        private int index
      • size

        private final int size
      • container

        private final java.lang.Object[] container
    • Constructor Detail

      • CircleStack

        public CircleStack​(int argStackSize,
                           int argContainerSize)
    • Method Detail

      • pop

        public final E pop()
        Description copied from interface: IOrderedStack
        Returns the next object in the pool
        Specified by:
        pop in interface IOrderedStack<E>
        Returns:
      • pop

        public final E[] pop​(int argNum)
        Description copied from interface: IOrderedStack
        Returns the next 'argNum' objects in the pool in an array
        Specified by:
        pop in interface IOrderedStack<E>
        Returns:
        an array containing the next pool objects in items 0-argNum. Array length and uniqueness not guaranteed.
      • push

        public void push​(int argNum)
        Description copied from interface: IOrderedStack
        Tells the stack to take back the last 'argNum' items
        Specified by:
        push in interface IOrderedStack<E>
      • newInstance

        protected abstract E newInstance()
        Creates a new instance of the object contained by this stack.