Package io.deephaven.base.cache
Class OpenAddressedCanonicalizationCache
java.lang.Object
io.deephaven.base.cache.OpenAddressedCanonicalizationCache
An object canonicalization cache, suitable for use with objects that define equals(...) in such a way as to identify
objects that can be mutually substituted in a manner appropriate for the application using the cache. Objects with an
improper hashCode() implementation will cause undefined behavior.
See KeyedObjectHashMap and its parent classes for many of the ideas I'm working from. The implementation is (loosely)
based on an open-addressed hash map.
The intended problem domain is effectively single-threaded, so I've optimized on single-threaded efficiency and used
coarse synchronization instead of optimizing for concurrency.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Allows cache users to supercede the equals() and hashCode() methods of their input items, and supply an alternative object to cache. -
Constructor Summary
ConstructorDescriptionOpenAddressedCanonicalizationCache
(int minimumInitialCapacity) OpenAddressedCanonicalizationCache
(int minimumInitialCapacity, float loadFactor) -
Method Summary
Modifier and TypeMethodDescription<INPUT_OUTPUT_TYPE>
INPUT_OUTPUT_TYPEgetCachedItem
(INPUT_OUTPUT_TYPE item) <INPUT_TYPE,
OUTPUT_TYPE>
OUTPUT_TYPEgetCachedItem
(INPUT_TYPE item, @NotNull OpenAddressedCanonicalizationCache.Adapter<INPUT_TYPE, OUTPUT_TYPE> adapter)
-
Constructor Details
-
OpenAddressedCanonicalizationCache
public OpenAddressedCanonicalizationCache(int minimumInitialCapacity, float loadFactor) -
OpenAddressedCanonicalizationCache
public OpenAddressedCanonicalizationCache(int minimumInitialCapacity) -
OpenAddressedCanonicalizationCache
public OpenAddressedCanonicalizationCache()
-
-
Method Details
-
getCachedItem
public <INPUT_OUTPUT_TYPE> INPUT_OUTPUT_TYPE getCachedItem(@NotNull INPUT_OUTPUT_TYPE item) -
getCachedItem
public <INPUT_TYPE,OUTPUT_TYPE> OUTPUT_TYPE getCachedItem(@NotNull INPUT_TYPE item, @NotNull @NotNull OpenAddressedCanonicalizationCache.Adapter<INPUT_TYPE, OUTPUT_TYPE> adapter)
-