Interface LinkedDeque<E>

  • Type Parameters:
    E - the type of elements held in this collection
    All Superinterfaces:
    java.util.Collection<E>, java.util.Deque<E>, java.lang.Iterable<E>, java.util.Queue<E>
    All Known Implementing Classes:
    AbstractLinkedDeque, AccessOrderDeque, WriteOrderDeque

    @NotThreadSafe
    interface LinkedDeque<E>
    extends java.util.Deque<E>
    A linked list extension of the Deque interface where the link pointers are tightly integrated with the element. Linked deques have no capacity restrictions; they grow as necessary to support usage. They are not thread-safe; in the absence of external synchronization, they do not support concurrent access by multiple threads. Null elements are prohibited.

    Most LinkedDeque operations run in constant time by assuming that the element parameter is associated with the deque instance. Any usage that violates this assumption will result in non-deterministic behavior.

    An element can exist in only one instance of a deque implementation, but may exist in multiple implementations. Each implementation must define unique names for accessing and modifying its link pointers.

    The iterators returned by this class are not fail-fast: If the deque is modified at any time after the iterator is created, the iterator will be in an unknown state. Thus, in the face of concurrent modification, the iterator risks arbitrary, non-deterministic behavior at an undetermined time in the future.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      LinkedDeque.PeekingIterator<E> descendingIterator()  
      E getNext​(E e)
      Retrieves the next element or null if either the element is unlinked or the last element on the deque.
      E getPrevious​(E e)
      Retrieves the previous element or null if either the element is unlinked or the first element on the deque.
      boolean isFirst​(E e)
      Returns if the element is at the front of the deque.
      boolean isLast​(E e)
      Returns if the element is at the back of the deque.
      LinkedDeque.PeekingIterator<E> iterator()  
      void moveToBack​(E e)
      Moves the element to the back of the deque so that it becomes the last element.
      void moveToFront​(E e)
      Moves the element to the front of the deque so that it becomes the first element.
      void setNext​(E e, E next)
      Sets the next element or null if there is no link.
      void setPrevious​(E e, E prev)
      Sets the previous element or null if there is no link.
      • Methods inherited from interface java.util.Collection

        clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
      • Methods inherited from interface java.util.Deque

        add, addAll, addFirst, addLast, contains, element, getFirst, getLast, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, size
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Method Detail

      • isFirst

        boolean isFirst​(E e)
        Returns if the element is at the front of the deque.
        Parameters:
        e - the linked element
      • isLast

        boolean isLast​(E e)
        Returns if the element is at the back of the deque.
        Parameters:
        e - the linked element
      • moveToFront

        void moveToFront​(E e)
        Moves the element to the front of the deque so that it becomes the first element.
        Parameters:
        e - the linked element
      • moveToBack

        void moveToBack​(E e)
        Moves the element to the back of the deque so that it becomes the last element.
        Parameters:
        e - the linked element
      • getPrevious

        E getPrevious​(E e)
        Retrieves the previous element or null if either the element is unlinked or the first element on the deque.
      • setPrevious

        void setPrevious​(E e,
                         E prev)
        Sets the previous element or null if there is no link.
      • getNext

        E getNext​(E e)
        Retrieves the next element or null if either the element is unlinked or the last element on the deque.
      • setNext

        void setNext​(E e,
                     E next)
        Sets the next element or null if there is no link.
      • iterator

        LinkedDeque.PeekingIterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.util.Deque<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>