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>
ATwoStepMapper
is a mapper/reducer that is used in 2 steps –consume(Object)
andgetResults()
. 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
andTwoStepMapper.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. IfgetResults()
simply returns the internal state of the instance, unaltered, then combining and merging are identical.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
TwoStepMapper.Combineable<T,R,A extends TwoStepMapper.Combineable<T,R,A>>
Enables combining the state of multiple instances.static class
TwoStepMapper.KeyCounter<T,G>
A frequency counter that optionally filters some elements when merging subresults.static interface
TwoStepMapper.Mergeable<T,R>
Enables merging the results from multiple instances.static class
TwoStepMapper.SimpleCache<K,V>
Will calculate the function value for each input item, and cache the result.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
consume(T item)
Input/consume the items that should be mappedR
getResults()
Output the mapped resultsvoid
reset()
Reset, so it can be re-used
-