edu.northwestern.at.utils

## Class QueueStack<E>

- java.lang.Object
- - edu.northwestern.at.utils.QueueStack<E>

-     public class QueueStack<E>
      extends java.lang.Object

  A stack implemented using a single-ended queue.

  We actually use an ArrayList to mimic a queue.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.ArrayList<E>` | `queue` The queue which is used to hold the stack entries.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueueStack()` Create an empty stack.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isEmpty()` Check if stack is empty.
    `E` | `peek()` Peek at top element of stack without removing it.
    `E` | `pop()` Remove element from stack.
    `void` | `push(E e)` Add element to stack.
    `int` | `size()` Number of entries in stack.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### queue

          protected java.util.ArrayList<E> queue

      The queue which is used to hold the stack entries.

  - ### Constructor Detail

    - #### QueueStack

          public QueueStack()

      Create an empty stack.

  - ### Method Detail

    - #### isEmpty

          public boolean isEmpty()

      Check if stack is empty.
      Returns:
        true if stack is empty.

    - #### peek

          public E peek()

      Peek at top element of stack without removing it.
      Returns:
        Element returned.
      Throws:
        `EmptyQueueStackException` - when stack is empty.

    - #### pop

          public E pop()

      Remove element from stack.
      Returns:
        Element returned.
      Throws:
        `EmptyQueueStackException` - when stack is empty.

    - #### push

          public void push(E e)

      Add element to stack.
      Parameters:
        `e` - Element to add to stack.

    - #### size

          public int size()

      Number of entries in stack.
      Returns:
        Number of entries in stack.