Class ReverseOffsetLookupCache<VALUE_TYPE,EXTRA_INPUT_TYPE>

java.lang.Object
io.deephaven.util.datastructures.cache.ReverseOffsetLookupCache<VALUE_TYPE,EXTRA_INPUT_TYPE>
All Implemented Interfaces:
ToIntFunction<VALUE_TYPE>

public class ReverseOffsetLookupCache<VALUE_TYPE,EXTRA_INPUT_TYPE> extends Object implements ToIntFunction<VALUE_TYPE>
Caching data structure interface for caching Object to int (offset) mappings returned by an expensive, idempotent lookup function from int to Object.
  • Constructor Details

  • Method Details

    • ensurePopulated

      public void ensurePopulated(int highestIndexNeeded, @NotNull @NotNull Supplier<EXTRA_INPUT_TYPE> extraFactory, @Nullable @Nullable Consumer<EXTRA_INPUT_TYPE> extraCleanup)
      Ensure that the cache is populated for all indexes <= highestIndexNeeded.
      Parameters:
      highestIndexNeeded - The highest index needed for this operation
    • applyAsInt

      public int applyAsInt(VALUE_TYPE value)
      Get the index of value in reverse lookup cache. Be sure to call ensurePopulated(int, Supplier, Consumer) for the appropriate index bound, first.
      Specified by:
      applyAsInt in interface ToIntFunction<VALUE_TYPE>
      Parameters:
      value - The value to look up
      Returns:
      The index of value in the cache, or NULL_INDEX (-1) if not found
    • clear

      public void clear()
      Release all resources held by the cache.