Class OneToOneIndex<K,​V>


  • @Internal
    @ThreadSafe
    public class OneToOneIndex<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, it doesn't require linear scan when removing by value. Both K and V must have hashCode() and equals() correctly defined. The class is, for the most part, thread safe. Important: if accessing forward and backward mapping directly, calling code should synchronize on this object.
    • Constructor Detail

      • OneToOneIndex

        public OneToOneIndex()
    • Method Detail

      • index

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

        @NotNull
        public @NotNull Map<K,​V> getForwardMapping()
        You need to synchronize on this object if using this method.
      • getBackwardMapping

        @NotNull
        public @NotNull Map<V,​K> getBackwardMapping()
        You need to synchronize on this object if using this method.
      • 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()