Class MutableHashedLinkedMap<K,V>

java.lang.Object
net.minecraftforge.common.util.MutableHashedLinkedMap<K,V>
Type Parameters:
K - the type of keys
V - the type of mapped values
All Implemented Interfaces:
Iterable<Map.Entry<K,V>>

public class MutableHashedLinkedMap<K,V> extends Object implements Iterable<Map.Entry<K,V>>
A mutable linked map with a hashing strategy and a merge function.
  • Field Details

  • Constructor Details

    • MutableHashedLinkedMap

      public MutableHashedLinkedMap()
      Creates a new instance using the BASIC strategy.
    • MutableHashedLinkedMap

      public MutableHashedLinkedMap(it.unimi.dsi.fastutil.Hash.Strategy<? super K> strategy)
      Creates a mutable linked map with a default new-value-selecting merge function.
      Parameters:
      strategy - the hashing strategy
    • MutableHashedLinkedMap

      public MutableHashedLinkedMap(it.unimi.dsi.fastutil.Hash.Strategy<? super K> strategy, MutableHashedLinkedMap.MergeFunction<K,V> merge)
      Creates a mutable linked map with a custom merge function.
      Parameters:
      strategy - the hashing strategy
      merge - the function used when merging an existing value and a new value
  • Method Details

    • put

      @Nullable public V put(K key, V value)
      Inserts the mapping with the specified key and value pair.

      If there is a mapping already associated with this key, then the previous value and the specified (new) value are merged according to this collection's merge function, and the position of the entry is not modified. If there is no such mapping, then the key-value mapping is inserted at the end of this collection.

      Parameters:
      key - key to be inserted
      value - (new) value to be associated with the key
      Returns:
      the previous value associated with the specified key, or null if there was no mapping for the key
    • contains

      public boolean contains(K key)
    • isEmpty

      public boolean isEmpty()
    • remove

      @Nullable public V remove(K key)
    • get

      @Nullable public V get(K key)
    • iterator

      public Iterator<Map.Entry<K,V>> iterator()
      Specified by:
      iterator in interface Iterable<K>
    • putFirst

      @Nullable public V putFirst(K key, V value)
      Inserts the mapping with the specified key and value pair at the beginning of this map.

      If there is a mapping already associated with this key, then the previous value and the specified (new) value are first merged according to this map's merge function, then the entry is moved to the beginning of the map.

      Parameters:
      key - key to be inserted at the beginning
      value - (new) value to be associated with the key
      Returns:
      the previous value associated with the specified key, or null if there was no mapping for the key
      See Also:
    • putAfter

      @Nullable public V putAfter(K after, K key, V value)
      Inserts the mapping with this key and value pair immediately after the entry with the specified positioning key.

      If the specified positioning key is not present within this map, then this method behaves like put(Object, Object). If there is a mapping already associated with this key, then the previous value and the specified (new) value are first merged according to this map's merge function, then the entry is moved to directly after the entry with the specified positioning key.

      Parameters:
      after - the key to position this new entry afterwards
      key - key to be inserted at the beginning
      value - (new) value to be associated with the key
      Returns:
      the previous value associated with the specified key, or null if there was no mapping for the key
      See Also:
    • putBefore

      @Nullable public V putBefore(K before, K key, V value)
      Inserts the mapping with this key and value pair immediately before the entry with the specified positioning key.

      If the specified positioning key is not present within this map, then this method behaves like put(Object, Object). If there is a mapping already associated with this key, then the previous value and the specified (new) value are first merged according to this map's merge function, then the entry is moved to directly before the entry with the specified positioning key.

      Parameters:
      before - the key to position this new entry afterwards
      key - key to be inserted at the beginning
      value - (new) value to be associated with the key
      Returns:
      the previous value associated with the specified key, or null if there was no mapping for the key
      See Also:
    • remove

      private void remove(MutableHashedLinkedMap<K,V>.Entry e)