T
- Type of memoized items@Beta @PublicAPI public interface MemoizedSparseCollection<T>
Note that the typical usage of term Memoization usually refers to an operation of storing the results of a potentially expensive calculation (see https://en.wikipedia.org/wiki/Memoization.
Modifier and Type | Method and Description |
---|---|
T |
getMemoized(int i)
Get a non-missing memoiozed.
|
java.util.function.Function<java.lang.Integer,T> |
getMemoizedFunction()
Function to access captured non-missing memoizeds. |
java.util.Optional<T> |
getMemoizedIfPresent(int i)
Get item when present.
|
T |
getMemoizedOrDefault(int i,
T defaultValue)
Get item when present or a default value when missing.
|
java.util.function.Function<java.lang.Integer,T> |
getMemoizedOrDefaultFunction(T defaultValue)
Function to access present items with a default value for missing items. |
int |
size()
Collected items count.
|
int size()
java.util.Optional<T> getMemoizedIfPresent(int i)
i
- Index which refers to either a missing or a present elementT getMemoizedOrDefault(int i, T defaultValue)
i
- Index which refers to either a missing or a present elementdefaultValue
- value for return when missingT getMemoized(int i) throws java.util.NoSuchElementException
i
- Index of an item which is not missingjava.util.NoSuchElementException
- when given index refers to a missing itemjava.util.function.Function<java.lang.Integer,T> getMemoizedFunction()
Function
to access captured non-missing memoizeds.Function
of Integer
to the memoized type T
which delegates to
getMemoized(int)
java.util.function.Function<java.lang.Integer,T> getMemoizedOrDefaultFunction(T defaultValue)
Function
to access present items with a default value for missing items.defaultValue
- Value to return for missing items.Function
of Integer
to the memoized type T
which delegates to
getMemoizedOrDefault(int, java.lang.Object)