Class HistoricalLinkedList<E>
- java.lang.Object
-
- org.opentrafficsim.core.perception.AbstractHistorical<E,AbstractHistoricalCollection.EventCollection<E,C>>
-
- org.opentrafficsim.core.perception.collections.AbstractHistoricalCollection<E,L>
-
- org.opentrafficsim.core.perception.collections.AbstractHistoricalList<E,LinkedList<E>>
-
- org.opentrafficsim.core.perception.collections.HistoricalLinkedList<E>
-
- Type Parameters:
E
- element type
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Deque<E>
,List<E>
,Queue<E>
,HistoricalCollection<E>
,HistoricalDeque<E>
,HistoricalList<E>
,HistoricalQueue<E>
,HistoryManager.HistoricalElement
public class HistoricalLinkedList<E> extends AbstractHistoricalList<E,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.
TheIterator
returned by this class does not support theremove()
,add()
andset()
methods. Any returned sublist is unmodifiable.Copyright (c) 2013-2022 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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opentrafficsim.core.perception.collections.AbstractHistoricalList
AbstractHistoricalList.AddEvent<E,L extends List<E>>, AbstractHistoricalList.EventList<E,L extends List<E>>, AbstractHistoricalList.RemoveEvent<E,L extends List<E>>
-
Nested classes/interfaces inherited from class org.opentrafficsim.core.perception.collections.AbstractHistoricalCollection
AbstractHistoricalCollection.EventCollection<E,C extends Collection<E>>
-
Nested classes/interfaces inherited from class org.opentrafficsim.core.perception.AbstractHistorical
AbstractHistorical.EventValue<T>
-
-
Constructor Summary
Constructors Constructor Description HistoricalLinkedList(HistoryManager historyManager)
Constructor.HistoricalLinkedList(HistoryManager historyManager, Collection<? extends E> c)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFirst(E e)
void
addLast(E e)
Iterator<E>
descendingIterator()
This implementation copies a list and reverses the order before returning the iterator.E
element()
LinkedList<E>
get()
Returns the current deque.LinkedList<E>
get(Time time)
Returns a past deque.E
getFirst()
E
getLast()
boolean
offer(E e)
boolean
offerFirst(E e)
boolean
offerLast(E e)
E
peek()
E
peekFirst()
E
peekLast()
E
poll()
E
pollFirst()
E
pollLast()
E
pop()
void
push(E e)
E
remove()
E
removeFirst()
boolean
removeFirstOccurrence(Object o)
E
removeLast()
boolean
removeLastOccurrence(Object o)
String
toString()
-
Methods inherited from class org.opentrafficsim.core.perception.collections.AbstractHistoricalList
add, add, addAll, get, indexOf, lastIndexOf, listIterator, listIterator, remove, remove, set, subList
-
Methods inherited from class org.opentrafficsim.core.perception.collections.AbstractHistoricalCollection
addAll, clear, contains, containsAll, fill, fill, getCollection, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray
-
Methods inherited from class org.opentrafficsim.core.perception.AbstractHistorical
addEvent, cleanUpHistory, getEvent, getEvents, getLastEvent, isLastState, now, removeEvent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface org.opentrafficsim.core.perception.collections.HistoricalCollection
removeIf
-
Methods inherited from interface org.opentrafficsim.core.perception.collections.HistoricalList
replaceAll, sort
-
-
-
-
Constructor Detail
-
HistoricalLinkedList
public HistoricalLinkedList(HistoryManager historyManager)
Constructor.- Parameters:
historyManager
- HistoryManager; history manager
-
HistoricalLinkedList
public HistoricalLinkedList(HistoryManager historyManager, Collection<? extends E> c)
Constructor.- Parameters:
historyManager
- HistoryManager; history managerc
- Collection<? extends E>; initial collection
-
-
Method Detail
-
get
public LinkedList<E> get()
Returns the current deque.- Specified by:
get
in interfaceHistoricalCollection<E>
- Specified by:
get
in interfaceHistoricalDeque<E>
- Specified by:
get
in interfaceHistoricalList<E>
- Specified by:
get
in interfaceHistoricalQueue<E>
- Returns:
- Deque; current deque
-
get
public LinkedList<E> get(Time time)
Returns a past deque.- Specified by:
get
in interfaceHistoricalCollection<E>
- Specified by:
get
in interfaceHistoricalDeque<E>
- Specified by:
get
in interfaceHistoricalList<E>
- Specified by:
get
in interfaceHistoricalQueue<E>
- Parameters:
time
- Time; time to obtain the deque at- Returns:
- Deque; past deque
-
offer
public boolean offer(E e)
-
remove
public E remove()
-
removeFirst
public E removeFirst()
- Specified by:
removeFirst
in interfaceDeque<E>
-
poll
public E poll()
-
offerFirst
public boolean offerFirst(E e)
- Specified by:
offerFirst
in interfaceDeque<E>
-
removeLast
public E removeLast()
- Specified by:
removeLast
in interfaceDeque<E>
-
removeFirstOccurrence
public boolean removeFirstOccurrence(Object o)
- Specified by:
removeFirstOccurrence
in interfaceDeque<E>
-
removeLastOccurrence
public boolean removeLastOccurrence(Object o)
- Specified by:
removeLastOccurrence
in interfaceDeque<E>
-
element
public E element()
-
peek
public E peek()
-
descendingIterator
public 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 interfaceDeque<E>
-
-