Class ForwardingDeque<E extends @Nullable Object>

    • Constructor Detail

      • ForwardingDeque

        protected ForwardingDeque()
        Constructor for use by subclasses.
    • Method Detail

      • delegate

        protected abstract Deque<Edelegate()
        Description copied from class: ForwardingObject
        Returns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override this method with an abstract method that has a more specific return type, such as ForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.
        Specified by:
        delegate in class ForwardingQueue<E extends @Nullable Object>
      • addFirst

        public void addFirst​(E e)
        Description copied from interface: java.util.Deque
        Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available. When using a capacity-restricted deque, it is generally preferable to use method Deque.offerFirst(E).
        Specified by:
        addFirst in interface Deque<E extends @Nullable Object>
        Parameters:
        e - the element to add
      • addLast

        public void addLast​(E e)
        Description copied from interface: java.util.Deque
        Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available. When using a capacity-restricted deque, it is generally preferable to use method Deque.offerLast(E).

        This method is equivalent to Deque.add(E).

        Specified by:
        addLast in interface Deque<E extends @Nullable Object>
        Parameters:
        e - the element to add
      • descendingIterator

        public Iterator<EdescendingIterator()
        Description copied from interface: java.util.Deque
        Returns an iterator over the elements in this deque in reverse sequential order. The elements will be returned in order from last (tail) to first (head).
        Specified by:
        descendingIterator in interface Deque<E extends @Nullable Object>
        Returns:
        an iterator over the elements in this deque in reverse sequence
      • getFirst

        public E getFirst()
        Description copied from interface: java.util.Deque
        Retrieves, but does not remove, the first element of this deque. This method differs from peekFirst only in that it throws an exception if this deque is empty.
        Specified by:
        getFirst in interface Deque<E extends @Nullable Object>
        Returns:
        the head of this deque
      • getLast

        public E getLast()
        Description copied from interface: java.util.Deque
        Retrieves, but does not remove, the last element of this deque. This method differs from peekLast only in that it throws an exception if this deque is empty.
        Specified by:
        getLast in interface Deque<E extends @Nullable Object>
        Returns:
        the tail of this deque
      • offerFirst

        @CanIgnoreReturnValue
        public boolean offerFirst​(E e)
        Description copied from interface: java.util.Deque
        Inserts the specified element at the front of this deque unless it would violate capacity restrictions. When using a capacity-restricted deque, this method is generally preferable to the Deque.addFirst(E) method, which can fail to insert an element only by throwing an exception.
        Specified by:
        offerFirst in interface Deque<E extends @Nullable Object>
        Parameters:
        e - the element to add
        Returns:
        true if the element was added to this deque, else false
      • offerLast

        @CanIgnoreReturnValue
        public boolean offerLast​(E e)
        Description copied from interface: java.util.Deque
        Inserts the specified element at the end of this deque unless it would violate capacity restrictions. When using a capacity-restricted deque, this method is generally preferable to the Deque.addLast(E) method, which can fail to insert an element only by throwing an exception.
        Specified by:
        offerLast in interface Deque<E extends @Nullable Object>
        Parameters:
        e - the element to add
        Returns:
        true if the element was added to this deque, else false
      • peekFirst

        @CheckForNull
        public E peekFirst()
        Description copied from interface: java.util.Deque
        Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.
        Specified by:
        peekFirst in interface Deque<E extends @Nullable Object>
        Returns:
        the head of this deque, or null if this deque is empty
      • peekLast

        @CheckForNull
        public E peekLast()
        Description copied from interface: java.util.Deque
        Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.
        Specified by:
        peekLast in interface Deque<E extends @Nullable Object>
        Returns:
        the tail of this deque, or null if this deque is empty
      • pop

        @CanIgnoreReturnValue
        public E pop()
        Description copied from interface: java.util.Deque
        Pops an element from the stack represented by this deque. In other words, removes and returns the first element of this deque.

        This method is equivalent to Deque.removeFirst().

        Specified by:
        pop in interface Deque<E extends @Nullable Object>
        Returns:
        the element at the front of this deque (which is the top of the stack represented by this deque)
      • push

        public void push​(E e)
        Description copied from interface: java.util.Deque
        Pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

        This method is equivalent to Deque.addFirst(E).

        Specified by:
        push in interface Deque<E extends @Nullable Object>
        Parameters:
        e - the element to push
      • removeFirstOccurrence

        @CanIgnoreReturnValue
        public boolean removeFirstOccurrence​(@CheckForNull
                                             Object o)
        Description copied from interface: java.util.Deque
        Removes the first occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the first element e such that Objects.equals(o, e) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).
        Specified by:
        removeFirstOccurrence in interface Deque<E extends @Nullable Object>
        Parameters:
        o - element to be removed from this deque, if present
        Returns:
        true if an element was removed as a result of this call
      • removeLastOccurrence

        @CanIgnoreReturnValue
        public boolean removeLastOccurrence​(@CheckForNull
                                            Object o)
        Description copied from interface: java.util.Deque
        Removes the last occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the last element e such that Objects.equals(o, e) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).
        Specified by:
        removeLastOccurrence in interface Deque<E extends @Nullable Object>
        Parameters:
        o - element to be removed from this deque, if present
        Returns:
        true if an element was removed as a result of this call