Class ArrayBackedOffsetLookupCache<VALUE_TYPE,EXTRA_INPUT_TYPE>
java.lang.Object
io.deephaven.util.datastructures.cache.ArrayBackedOffsetLookupCache<VALUE_TYPE,EXTRA_INPUT_TYPE>
- All Implemented Interfaces:
OffsetLookupCache<VALUE_TYPE,
EXTRA_INPUT_TYPE>
Caching data structure for caching int (offset) to Object mappings. For use when lookup is expensive but idempotent,
and the range of offset indexes is relatively contiguous. This is only suitable for lookup functions that return
fully-initialized, immutable objects (or null).
This implementation stores data in a single contiguous array.
-
Constructor Summary
ConstructorDescriptionArrayBackedOffsetLookupCache
(@NotNull Class<VALUE_TYPE> valueType, @NotNull OffsetLookup<VALUE_TYPE, EXTRA_INPUT_TYPE> lookupFunction) Construct a lookup cache for the supplied arguments, usingOffsetLookupCache.createPlaceholder(Class)
to create a "null" placeholder value. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Release all resources held by the cache.get
(int index, EXTRA_INPUT_TYPE extra) Lookup the value for index.
-
Constructor Details
-
ArrayBackedOffsetLookupCache
public ArrayBackedOffsetLookupCache(@NotNull @NotNull Class<VALUE_TYPE> valueType, @NotNull @NotNull OffsetLookup<VALUE_TYPE, EXTRA_INPUT_TYPE> lookupFunction) Construct a lookup cache for the supplied arguments, usingOffsetLookupCache.createPlaceholder(Class)
to create a "null" placeholder value.- Parameters:
valueType
- The value typelookupFunction
- The lookup function from index to value, must return a fully-initialized, immutable object or null
-
-
Method Details
-
get
Description copied from interface:OffsetLookupCache
Lookup the value for index.- Parameters:
index
- The offset (must be >= 0)- Returns:
- The result of calling the lookup function for index, possibly from cache
-
clear
public void clear()Description copied from interface:OffsetLookupCache
Release all resources held by the cache.
-