Interface PerceptionCollectable<H extends Headway,U>
- Type Parameters:
H
- headway typeU
- underlying object type
- All Superinterfaces:
Iterable<H>
,PerceptionIterable<H>
- All Known Implementing Classes:
AbstractPerceptionReiterable
,MultiLanePerceptionIterable
,PerceptionCollectableFiltered
Iterable that additionally provides support for PerceptionCollectors. These gather raw data, to only 'perceive' the result.
Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Wrapper of intermediate result with info for the iterator algorithm.static interface
Accumulates an object one at a time in to an accumulating intermediate result.static interface
Combination of an accumulator and a finalizer.static final record
Wrapper for object and its distance. -
Method Summary
Modifier and TypeMethodDescription<C,
I> C collect
(Supplier<I> identity, PerceptionCollectable.PerceptionAccumulator<? super U, I> accumulator, Function<I, C> finalizer) Collect the underlying objects in to a perceived result.default <C,
I> C collect
(PerceptionCollectable.PerceptionCollector<C, ? super U, I> collector) Collect the underlying objects in to a perceived result.Returns an iterator over the underlying objects.Returns an iterator over the underlying objects coupled with the distance.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
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
- collector- Returns:
- collection result
-
collect
<C,I> C collect(Supplier<I> identity, PerceptionCollectable.PerceptionAccumulator<? super U, I> accumulator, Function<I, C> 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
- the initial intermediate result valueaccumulator
- accumulatorfinalizer
- finalizer- Returns:
- collection result
-
underlying
Returns an iterator over the underlying objects.- Returns:
- iterator
-
underlyingWithDistance
Iterator<PerceptionCollectable.UnderlyingDistance<U>> underlyingWithDistance()Returns an iterator over the underlying objects coupled with the distance.- Returns:
- iterator
-