Class AbstractHistoricalCollection<E,C extends Collection<E>>
java.lang.Object
org.opentrafficsim.core.perception.AbstractHistorical<E,AbstractHistoricalCollection.EventCollection<E,C>>
org.opentrafficsim.core.perception.collections.AbstractHistoricalCollection<E,C>
- Type Parameters:
E- element typeC- collection type
- All Implemented Interfaces:
Iterable<E>,Collection<E>,HistoricalCollection<E>,HistoryManager.HistoricalElement
- Direct Known Subclasses:
AbstractHistoricalList,AbstractHistoricalQueue,AbstractHistoricalSortedSet,HistoricalHashSet,HistoricalLinkedHashSet
public abstract class AbstractHistoricalCollection<E,C extends Collection<E>> extends AbstractHistorical<E,AbstractHistoricalCollection.EventCollection<E,C>> implements HistoricalCollection<E>
Collection-valued historical state. The current collection is always maintained, and past states of the collection are
obtained by applying the events between now and the requested time in reverse.
This implementation is suitable for sets, as add and remove events to retrieve historical states are only created if indeed the underlying collection is changed.
The
This implementation is suitable for sets, as add and remove events to retrieve historical states are only created if indeed the underlying collection is changed.
Set introduces no new methods relative to Collection.The
Iterator returned by this class does not support the remove() method.
Copyright (c) 2013-2019 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 1 jan. 2018
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractHistoricalCollection.AddEvent<E,C extends Collection<E>>Event for adding value to the collection.static classAbstractHistoricalCollection.EventCollection<E,C extends Collection<E>>Abstract super class for events that add or remove a value from the collection.static classAbstractHistoricalCollection.RemoveEvent<E,C extends Collection<E>>Event for removing value from the collection.Nested classes/interfaces inherited from class org.opentrafficsim.core.perception.AbstractHistorical
AbstractHistorical.EventValue<T> -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractHistoricalCollection(HistoryManager historyManager, C collection)Constructor. -
Method Summary
Modifier and Type Method Description booleanadd(E value)booleanaddAll(Collection<? extends E> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)protected Cfill(C collection)Fill collection with the current collection.protected Cfill(Time time, C collection)Fill collection with the collection at the given simulation time.protected CgetCollection()Returns the internal collection.booleanisEmpty()Iterator<E>iterator()booleanremove(Object value)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)intsize()Object[]toArray()<T> T[]toArray(T[] a)Methods inherited from class org.opentrafficsim.core.perception.AbstractHistorical
addEvent, cleanUpHistory, getEvent, getEvents, getLastEvent, isLastState, now, removeEventMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, spliterator, stream, toArrayMethods inherited from interface org.opentrafficsim.core.perception.collections.HistoricalCollection
get, get, removeIf
-
Constructor Details
-
AbstractHistoricalCollection
Constructor.- Parameters:
historyManager- HistoryManager; history managercollection- C; initial collection
-
-
Method Details
-
getCollection
Returns the internal collection.- Returns:
- C; internal collection
-
fill
Fill collection with the current collection.- Parameters:
collection- C; collection to fill- Returns:
- C; input collection filled
-
fill
Fill collection with the collection at the given simulation time.- Parameters:
time- Time; timecollection- C; collection to fill- Returns:
- C; input collection filled
-
add
- Specified by:
addin interfaceCollection<E>
-
addAll
- Specified by:
addAllin interfaceCollection<E>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>
-
remove
- Specified by:
removein interfaceCollection<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E>
-
size
public int size()- Specified by:
sizein interfaceCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E>
-
contains
- Specified by:
containsin interfaceCollection<E>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<E>
-
toArray
public <T> T[] toArray(T[] a)- Specified by:
toArrayin interfaceCollection<E>
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>
-