Package org.ojalgo.type.function
Class TwoStepMapper.SimpleCache<K,V>
- java.lang.Object
-
- org.ojalgo.type.function.TwoStepMapper.SimpleCache<K,V>
-
- All Implemented Interfaces:
TwoStepMapper<K,java.util.Map<K,V>>
,TwoStepMapper.Combineable<K,java.util.Map<K,V>,TwoStepMapper.SimpleCache<K,V>>
,TwoStepMapper.Mergeable<K,java.util.Map<K,V>>
- Enclosing interface:
- TwoStepMapper<T,R>
public static final class TwoStepMapper.SimpleCache<K,V> extends java.lang.Object implements TwoStepMapper.Combineable<K,java.util.Map<K,V>,TwoStepMapper.SimpleCache<K,V>>, TwoStepMapper.Mergeable<K,java.util.Map<K,V>>
Will calculate the function value for each input item, and cache the result. The cache is used to avoid re-calculating the same value multiple times. The final result is a complete map of all input output pairs.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ojalgo.type.function.TwoStepMapper
TwoStepMapper.Combineable<T,R,A extends TwoStepMapper.Combineable<T,R,A>>, TwoStepMapper.KeyCounter<T,G>, TwoStepMapper.Mergeable<T,R>, TwoStepMapper.SimpleCache<K,V>
-
-
Constructor Summary
Constructors Constructor Description SimpleCache(java.util.function.Function<K,V> function)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
combine(TwoStepMapper.SimpleCache<K,V> other)
This method can be used to combine the state of multiple instances.void
consume(K item)
Input/consume the items that should be mapped(package private) java.util.Map<K,V>
getCache()
java.util.Map<K,V>
getResults()
Output the mapped resultsvoid
merge(java.util.Map<K,V> other)
This method can be used to merge the results from multiple instances.void
reset()
Reset, so it can be re-used
-
-
-
Method Detail
-
combine
public void combine(TwoStepMapper.SimpleCache<K,V> other)
Description copied from interface:TwoStepMapper.Combineable
This method can be used to combine the state of multiple instances. The intermediate/internal state from one instance is combined into another.- Specified by:
combine
in interfaceTwoStepMapper.Combineable<K,java.util.Map<K,V>,TwoStepMapper.SimpleCache<K,V>>
-
consume
public void consume(K item)
Description copied from interface:TwoStepMapper
Input/consume the items that should be mapped- Specified by:
consume
in interfaceTwoStepMapper<K,V>
-
getResults
public java.util.Map<K,V> getResults()
Description copied from interface:TwoStepMapper
Output the mapped results- Specified by:
getResults
in interfaceTwoStepMapper<K,V>
-
merge
public void merge(java.util.Map<K,V> other)
Description copied from interface:TwoStepMapper.Mergeable
This method can be used to merge the results from multiple instances. The final results from one instance is merged into another.- Specified by:
merge
in interfaceTwoStepMapper.Mergeable<K,V>
-
reset
public void reset()
Description copied from interface:TwoStepMapper
Reset, so it can be re-used- Specified by:
reset
in interfaceTwoStepMapper<K,V>
-
-