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.
|
Function<Integer,T> |
getMemoizedFunction()
Function to access captured non-missing memoizeds. |
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.
|
Function<Integer,T> |
getMemoizedOrDefaultFunction(T defaultValue)
Function to access present items with a default value for missing items. |
int |
size()
Collected items count.
|
int size()
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 NoSuchElementException
i
- Index of an item which is not missingNoSuchElementException
- when given index refers to a missing itemFunction<Integer,T> getMemoizedFunction()
Function
to access captured non-missing memoizeds.Function
of Integer
to the memoized type T
which delegates to
getMemoized(int)
Function<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)