Package org.ojalgo.type.function
Interface TwoStepMapper<T,R>
- All Known Subinterfaces:
TwoStepMapper.Combineable<T,
,R, A> TwoStepMapper.Mergeable<T,
R>
- All Known Implementing Classes:
BatchNode.TwoStepWrapper
,TwoStepMapper.KeyCounter
,TwoStepMapper.SimpleCache
public interface TwoStepMapper<T,R>
A
TwoStepMapper
is a mapper/reducer that is used in 2 steps – consume(Object)
and
getResults()
. First you consume some (many) elements, then you get the results. The results is one
instance of some aggregate type – most likely a collection or map containing derived information.
Resettable (to enable reuse).
There are 2 optional extensions to this interface: TwoStepMapper.Combineable
and TwoStepMapper.Mergeable
. The first
enables combining the state of multiple instances. The second enables merging the results from multiple
instances. The difference is that combining is done before the final results are calculated, while merging
is done after the final results are calculated. If getResults()
simply returns the internal state
of the instance, unaltered, then combining and merging are identical.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
TwoStepMapper.Combineable<T,
R, A extends TwoStepMapper.Combineable<T, R, A>> Enables combining the state of multiple instances.static final class
A frequency counter that optionally filters some elements when merging subresults.static interface
Enables merging the results from multiple instances.static final class
Will calculate the function value for each input item, and cache the result. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Input/consume the items that should be mappedOutput the mapped resultsvoid
reset()
Reset, so it can be re-used
-
Method Details
-
consume
Input/consume the items that should be mapped -
getResults
R getResults()Output the mapped results -
reset
void reset()Reset, so it can be re-used
-