Module gg.xp.xivapi

Class KeyedAlikeMap<K,V>

java.lang.Object
gg.xp.xivapi.collections.KeyedAlikeMap<K,V>
Type Parameters:
K - The key type.
V - The value type.
All Implemented Interfaces:
Map<K,V>

public class KeyedAlikeMap<K,V> extends Object implements Map<K,V>
KeyedAlikeMap is a map with a defined set of allowed keys. The intent is for multiple maps which are going to have an identical set of possible keys to share the same underlying key mapping. Assuming that enough of the possible keys are in use, this saves memory over a traditional hash map.

Thread safety: concurrent reads are okay, and raw concurrent writes are probably fine. However, modifying the map while iterating and other combinations of simultaneous reading/writing are undefined. Methods such as size/isEmpty have undefined behavior as well if they overlap with a write.

This class is not meant to be instantiated by the user. Instead, use your key set to create a KeyedAlikeMapFactory, which may then be used to produce KeyedAlikeMap instances.

See Also:
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface Map<K,V>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
    • containsKey

      public boolean containsKey(@Nullable @Nullable Object key)
      Specified by:
      containsKey in interface Map<K,V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
    • get

      @Nullable public V get(Object key)
      Specified by:
      get in interface Map<K,V>
    • put

      @Nullable public V put(K key, V value)
      Specified by:
      put in interface Map<K,V>
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface Map<K,V>
    • putAll

      public void putAll(@NotNull @NotNull Map<? extends K,? extends V> m)
      Specified by:
      putAll in interface Map<K,V>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<K,V>
    • keySet

      @NotNull public @NotNull Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
    • values

      @NotNull public @NotNull Collection<V> values()
      Specified by:
      values in interface Map<K,V>
    • entrySet

      @NotNull public @NotNull Set<Map.Entry<K,V>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface Map<K,V>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<K,V>
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object