Class UnsafeOneToOneIndex<K,V>

java.lang.Object
com.atlassian.bamboo.plan.cache.index.util.unsafe.UnsafeOneToOneIndex<K,V>

@Internal @NotThreadSafe public class UnsafeOneToOneIndex<K,V> extends Object
A class that allows to index any key <-> value, one-to-one relationship. The key characteristics of this class is that, unlike Map<K,V>, it doesn't require linear scan when removing by value. Both K and V must have hashCode() and equals() correctly defined. This class is _not_ thread safe.
  • Constructor Details

    • UnsafeOneToOneIndex

      public UnsafeOneToOneIndex()
    • UnsafeOneToOneIndex

      public UnsafeOneToOneIndex(@NotNull @NotNull Supplier<Map<K,V>> forwardMappingSupplier, @NotNull @NotNull Supplier<Map<V,K>> backwardMappingSupplier)
  • Method Details

    • addToIndex

      public void addToIndex(@NotNull K key, @NotNull V value)
      To be used when you can be sure no prior mapping exists for both key and value.
    • index

      public void index(@NotNull K key, @NotNull V value)
    • getForwardMapping

      public Map<K,V> getForwardMapping()
    • getBackwardMapping

      @NotNull public @NotNull Map<V,K> getBackwardMapping()
    • removeByKey

      @Nullable public V removeByKey(@NotNull K key)
    • removeByValue

      @Nullable public K removeByValue(@NotNull V value)
    • getByKey

      @Nullable public V getByKey(@NotNull K key)
    • getByValue

      @Nullable public K getByValue(@NotNull V value)
    • clear

      public void clear()