Class HistoricalLinkedList<E>

  • Type Parameters:
    E - element type
    All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.Deque<E>, java.util.List<E>, java.util.Queue<E>, HistoricalCollection<E>, HistoricalDeque<E>, HistoricalList<E>, HistoricalQueue<E>, HistoryManager.HistoricalElement

    public class HistoricalLinkedList<E>
    extends AbstractHistoricalList<E,​java.util.LinkedList<E>>
    implements HistoricalDeque<E>
    LinkedList-valued historical state. The current linked list is always maintained, and past states of the linked list are obtained by applying the events between now and the requested time in reverse.

    The Iterator returned by this class does not support the remove(), add() and set() methods. Any returned sublist is unmodifiable.

    Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    Version:
    $Revision$, $LastChangedDate$, by $Author$, initial version 3 feb. 2018
    Author:
    Alexander Verbraeck, Peter Knoppers, Wouter Schakel
    • Constructor Detail

      • HistoricalLinkedList

        public HistoricalLinkedList​(HistoryManager historyManager)
        Constructor.
        Parameters:
        historyManager - HistoryManager; history manager
      • HistoricalLinkedList

        public HistoricalLinkedList​(HistoryManager historyManager,
                                    java.util.Collection<? extends E> c)
        Constructor.
        Parameters:
        historyManager - HistoryManager; history manager
        c - Collection<? extends E>; initial collection
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • offer

        public boolean offer​(E e)
        Specified by:
        offer in interface java.util.Deque<E>
        Specified by:
        offer in interface java.util.Queue<E>
      • offerLast

        public boolean offerLast​(E e)
        Specified by:
        offerLast in interface java.util.Deque<E>
      • addLast

        public void addLast​(E e)
        Specified by:
        addLast in interface java.util.Deque<E>
      • remove

        public E remove()
        Specified by:
        remove in interface java.util.Deque<E>
        Specified by:
        remove in interface java.util.Queue<E>
      • removeFirst

        public E removeFirst()
        Specified by:
        removeFirst in interface java.util.Deque<E>
      • pop

        public E pop()
        Specified by:
        pop in interface java.util.Deque<E>
      • pollFirst

        public E pollFirst()
        Specified by:
        pollFirst in interface java.util.Deque<E>
      • poll

        public E poll()
        Specified by:
        poll in interface java.util.Deque<E>
        Specified by:
        poll in interface java.util.Queue<E>
      • addFirst

        public void addFirst​(E e)
        Specified by:
        addFirst in interface java.util.Deque<E>
      • push

        public void push​(E e)
        Specified by:
        push in interface java.util.Deque<E>
      • offerFirst

        public boolean offerFirst​(E e)
        Specified by:
        offerFirst in interface java.util.Deque<E>
      • removeLast

        public E removeLast()
        Specified by:
        removeLast in interface java.util.Deque<E>
      • pollLast

        public E pollLast()
        Specified by:
        pollLast in interface java.util.Deque<E>
      • removeFirstOccurrence

        public boolean removeFirstOccurrence​(java.lang.Object o)
        Specified by:
        removeFirstOccurrence in interface java.util.Deque<E>
      • removeLastOccurrence

        public boolean removeLastOccurrence​(java.lang.Object o)
        Specified by:
        removeLastOccurrence in interface java.util.Deque<E>
      • element

        public E element()
        Specified by:
        element in interface java.util.Deque<E>
        Specified by:
        element in interface java.util.Queue<E>
      • peek

        public E peek()
        Specified by:
        peek in interface java.util.Deque<E>
        Specified by:
        peek in interface java.util.Queue<E>
      • getFirst

        public E getFirst()
        Specified by:
        getFirst in interface java.util.Deque<E>
      • getLast

        public E getLast()
        Specified by:
        getLast in interface java.util.Deque<E>
      • peekFirst

        public E peekFirst()
        Specified by:
        peekFirst in interface java.util.Deque<E>
      • peekLast

        public E peekLast()
        Specified by:
        peekLast in interface java.util.Deque<E>
      • descendingIterator

        public java.util.Iterator<E> descendingIterator()


        This implementation copies a list and reverses the order before returning the iterator. This is not efficient and it should be avoided when possible.
        Specified by:
        descendingIterator in interface java.util.Deque<E>