package cpsc2150.MyDeque;

/**
 * A deque containing integers.
 * A deque is a double-ended queue data structure that allows you
 * to insert and remove from both ends.
 * This deque is bound by MAX_LENGTH.
 *
 * Initialization ensures:
 *      Deque contains nothing, i.e., an empty string {@code <>}.
 *
 * Defines:
 *      length_of_deque: Z
 *
 * Constraints:
 *      0 {@code <= }length of a self {@code <=} MAX_LENGTH
 */
public interface IDeque {
    public static final int MAX_LENGTH = 100;

    /**
     * Adds x to the end of the deque.
     *
     * @param x Integer to be added to end of deque
     *
     * @pre
     *      length of self, |self| {@code <} MAX_LENGTH
     *
     * @post
     *      self = [ x added to the end of #self ] AND
     *      length of self, |self| = length of #self, |#self| + 1
     */
    public void enqueue(Integer x);

    /**
     * Removes and returns the integer at the front of the deque.
     *
     * @return Integer at the front of deque
     *
     * @pre
     *      length of self, |self| {@code >} 0
     *
     * @post
     *      dequeue = [ integer at the front of #self ] AND
     *      self = [ dequeue removed from the front of #self ] AND
     *      length of self, |self| = length of #self, |#self| - 1
     */
    public Integer dequeue();

    /**
     * Adds x to the front of the deque.
     *
     * @param x Integer to be added to front of deque
     *
     * @pre
     *      length of self, |self| {@code <} MAX_LENGTH
     *
     * @post
     *      self = [ x added to the front of #self ] AND
     *      length of self, |self| = length of #self, |#self| + 1
     */
    public void inject(Integer x);

    /**
     * Removes and returns the integer at the end of the deque.
     *
     * @return Integer at the end of deque
     *
     * @pre
     *      length of self, |self| {@code >} 0
     *
     * @post
     *      removeLast = [ integer at the end of #self ] AND
     *      self = [ removeLast removed from the end of #self ] AND
     *      length of self, |self| = length of #self, |#self| - 1
     */
    public Integer removeLast();

    /**
     * Returns the number of integers in the deque.
     *
     * @return The number of integers in the deque
     *
     * @post
     *      length = length of self, |self| and self = #self
     */
    public int length();

    /**
     * Clears the entire deque.
     *
     * @post
     *      self = {@code <>}
     */
    public void clear();

}
