H
- headway typeU
- underlying object typepublic abstract class AbstractPerceptionReiterable<H extends Headway,U> extends Object implements PerceptionCollectable<H,U>
iterator()
return an iterator which
iterates over the linked list. If an iterator runs to the end of the linked list, the primary iterator is requested to add an
element if it has one.
Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Modifier and Type | Class and Description |
---|---|
class |
AbstractPerceptionReiterable.PerceptionIterator
This iterator is returned to callers of the
iterator() method. |
protected class |
AbstractPerceptionReiterable.PrimaryIteratorEntry
Class for
primaryIterator() to return, implemented in subclasses. |
PerceptionCollectable.Intermediate<I>, PerceptionCollectable.PerceptionAccumulator<U,I>, PerceptionCollectable.PerceptionCollector<C,U,I>, PerceptionCollectable.PerceptionFinalizer<C,I>
Modifier and Type | Field and Description |
---|---|
(package private) org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable.SecondaryIteratorEntry |
first
First entry.
|
(package private) LaneBasedGTU |
gtu
Perceiving GTU.
|
(package private) org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable.SecondaryIteratorEntry |
last
Last entry generated by the primary iterator.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractPerceptionReiterable(LaneBasedGTU perceivingGtu)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
addNext(AbstractPerceptionReiterable.PrimaryIteratorEntry next)
Adds an iterator entry to the internal linked list.
|
(package private) org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable.SecondaryIteratorEntry |
assureNext(org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable.SecondaryIteratorEntry next,
org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable.SecondaryIteratorEntry lastReturned)
Helper method that assures that a next entry is available, if the primary iterator has a next value.
|
<C,I> C |
collect(Supplier<I> identity,
PerceptionCollectable.PerceptionAccumulator<? super U,I> accumulator,
PerceptionCollectable.PerceptionFinalizer<C,I> finalizer)
Collect the underlying objects in to a perceived result.
|
H |
first()
Returns the first element.
|
(package private) Iterator<AbstractPerceptionReiterable.PrimaryIteratorEntry> |
getPrimaryIterator()
Returns the primary iterator.
|
boolean |
isEmpty()
Returns whether this iterable is empty.
|
Iterator<H> |
iterator() |
protected abstract H |
perceive(LaneBasedGTU perceivingGtu,
U object,
org.djunits.value.vdouble.scalar.Length distance)
Returns a perceived version of the underlying object.
|
protected abstract Iterator<AbstractPerceptionReiterable.PrimaryIteratorEntry> |
primaryIterator()
Returns the primary iterator.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
collect
forEach, spliterator
org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable.SecondaryIteratorEntry first
org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable.SecondaryIteratorEntry last
final LaneBasedGTU gtu
protected AbstractPerceptionReiterable(LaneBasedGTU perceivingGtu)
perceivingGtu
- LaneBasedGTU; perceiving GTUfinal Iterator<AbstractPerceptionReiterable.PrimaryIteratorEntry> getPrimaryIterator()
protected abstract Iterator<AbstractPerceptionReiterable.PrimaryIteratorEntry> primaryIterator()
protected abstract H perceive(LaneBasedGTU perceivingGtu, U object, org.djunits.value.vdouble.scalar.Length distance) throws org.opentrafficsim.core.gtu.GTUException, org.opentrafficsim.base.parameters.ParameterException
perceivingGtu
- LaneBasedGTU; perceiving GTUobject
- U; underlying objectdistance
- Length; distance to the objectorg.opentrafficsim.core.gtu.GTUException
- on exceptionorg.opentrafficsim.base.parameters.ParameterException
- on invalid parameter value or missing parameterpublic final H first()
first
in interface PerceptionIterable<H extends Headway>
final void addNext(AbstractPerceptionReiterable.PrimaryIteratorEntry next)
next
- PrimaryIteratorEntry; next objectpublic final boolean isEmpty()
isEmpty
in interface PerceptionIterable<H extends Headway>
public final <C,I> C collect(Supplier<I> identity, PerceptionCollectable.PerceptionAccumulator<? super U,I> accumulator, PerceptionCollectable.PerceptionFinalizer<C,I> finalizer)
collect
in interface PerceptionCollectable<H extends Headway,U>
C
- collection result typeI
- intermediate typeidentity
- Supplier; the initial intermediate result valueaccumulator
- PerceptionAccumulator; accumulatorfinalizer
- PerceptionFinalizer; finalizerorg.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable.SecondaryIteratorEntry assureNext(org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable.SecondaryIteratorEntry next, org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable.SecondaryIteratorEntry lastReturned)
next
- IteratorEntry; currently known next entrylastReturned
- IteratorEntry; entry of last returned object or valueCopyright © 2014–2018 Delft University of Technology. All rights reserved.