Interface PerceptionCollectable<H extends Headway,U>
- Type Parameters:
H- headway typeU- underlying object type
- All Superinterfaces:
java.lang.Iterable<H>,PerceptionIterable<H>
- All Known Implementing Classes:
AbstractPerceptionIterable,AbstractPerceptionReiterable,DownstreamNeighborsIterable,LaneBasedObjectIterable,MultiLanePerceptionIterable,SortedSetPerceptionIterable,UpstreamNeighborsIterable
public interface PerceptionCollectable<H extends Headway,U> extends PerceptionIterable<H>
Iterable that additionally provides support for PerceptionCollectors. These gather raw data, to only 'perceive' the result.
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 1 mrt. 2018
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classPerceptionCollectable.Intermediate<I>Wrapper of intermediate result with info for the iterator algorithm.static interfacePerceptionCollectable.PerceptionAccumulator<U,I>Accumulates an object one at a time in to an accumulating intermediate result.static interfacePerceptionCollectable.PerceptionCollector<C,U,I>Combination of an accumulator and a finalizer.static interfacePerceptionCollectable.PerceptionFinalizer<C,I>Translates the last intermediate result of an accumulator in to the collection output.static classPerceptionCollectable.UnderlyingDistance<U>Wrapper for object and its distance. -
Method Summary
Modifier and Type Method Description <C, I> Ccollect(java.util.function.Supplier<I> identity, PerceptionCollectable.PerceptionAccumulator<? super U,I> accumulator, PerceptionCollectable.PerceptionFinalizer<C,I> finalizer)Collect the underlying objects in to a perceived result.default <C, I> Ccollect(PerceptionCollectable.PerceptionCollector<C,? super U,I> collector)Collect the underlying objects in to a perceived result.java.util.Iterator<U>underlying()Returns an iterator over the underlying objects.java.util.Iterator<PerceptionCollectable.UnderlyingDistance<U>>underlyingWithDistance()Returns an iterator over the underlying objects coupled with the distance.Methods inherited from interface org.opentrafficsim.road.gtu.lane.perception.PerceptionIterable
first, isEmpty
-
Method Details
-
collect
Collect the underlying objects in to a perceived result. This methodology is loosely based on Stream.collect().- Type Parameters:
C- collection result typeI- intermediate type- Parameters:
collector- PerceptionCollector<C, ? super U, I>; collector- Returns:
- C; collection result
-
collect
<C, I> C collect(java.util.function.Supplier<I> identity, PerceptionCollectable.PerceptionAccumulator<? super U,I> accumulator, PerceptionCollectable.PerceptionFinalizer<C,I> finalizer)Collect the underlying objects in to a perceived result. This methodology is loosely based on Stream.collect().- Type Parameters:
C- collection result typeI- intermediate type- Parameters:
identity- Supplier<I>; the initial intermediate result valueaccumulator- PerceptionAccumulator<? super U, I>; accumulatorfinalizer- PerceptionFinalizer<C, I>; finalizer- Returns:
- C; collection result
-
underlying
java.util.Iterator<U> underlying()Returns an iterator over the underlying objects.- Returns:
- Iterator<U>; iterator
-
underlyingWithDistance
java.util.Iterator<PerceptionCollectable.UnderlyingDistance<U>> underlyingWithDistance()Returns an iterator over the underlying objects coupled with the distance.- Returns:
- Iterator<UnderlyingDistance<U>>; iterator
-