Class IngredientMapWrappedAdapter<T,M,V,C extends Map<IngredientInstanceWrapper<T,M>,V>>

java.lang.Object
org.cyclops.cyclopscore.ingredient.collection.IngredientMapAdapter<T,M,V>
org.cyclops.cyclopscore.ingredient.collection.IngredientMapWrappedAdapter<T,M,V,C>
Type Parameters:
T - The instance type.
M - The matching condition parameter.
V - The type of mapped values.
All Implemented Interfaces:
Iterable<Map.Entry<T,V>>, IIngredientCollectionLike<T,M,Map.Entry<T,V>>, IIngredientMap<T,M,V>, IIngredientMapMutable<T,M,V>
Direct Known Subclasses:
IngredientHashMap, IngredientTreeMap

public abstract class IngredientMapWrappedAdapter<T,M,V,C extends Map<IngredientInstanceWrapper<T,M>,V>> extends IngredientMapAdapter<T,M,V>
An abstract ingredient map adapter.
  • Constructor Details

    • IngredientMapWrappedAdapter

      protected IngredientMapWrappedAdapter(IngredientComponent<T,M> component, C collection)
  • Method Details

    • getCollection

      protected C getCollection()
    • wrap

      protected IngredientInstanceWrapper<T,M> wrap(T instance)
    • clear

      public void clear()
      Description copied from interface: IIngredientMapMutable
      Clears this map of all instances.
    • put

      @Nullable public V put(T key, V value)
      Description copied from interface: IIngredientMapMutable
      Add a new entry.
      Parameters:
      key - An instance key.
      value - A value.
      Returns:
      The previous value that was associated with the given instance.
    • remove

      @Nullable public V remove(T key)
      Description copied from interface: IIngredientMapMutable
      Remove the mapping for the given key instance.
      Parameters:
      key - An instance key.
      Returns:
      The value that was associated with the given instance.
    • size

      public int size()
      Returns:
      The number of instances contained in this collection.
    • containsValue

      public boolean containsValue(V value)
      Description copied from interface: IIngredientMap
      Check if this map contains the given value.
      Parameters:
      value - A value.
      Returns:
      If this map contains the given value.
    • get

      @Nullable public V get(T key)
      Description copied from interface: IIngredientMap
      Get the value for the given instance.
      Parameters:
      key - An instance.
      Returns:
      The value.
    • compute

      @Nullable public V compute(T key, BiFunction<T,V,V> remappingFunction)
      Description copied from interface: IIngredientMapMutable
      Compute a new value for the given key instance, following Map.compute(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>) semantics. The remapping function is passed the key and the currently mapped value, or null when the key is absent. Returning null removes the mapping, returning anything else stores it. Implementations back onto a hash of the key instance, which for some component types is expensive. Doing this in one call rather than a get followed by a put lets them hash once.
      Parameters:
      key - An instance key.
      remappingFunction - A function computing the new value from the key and the old value.
      Returns:
      The new value associated with the key, or null if none.
    • keySet

      public IngredientSet<T,M> keySet()
      Returns:
      All key instances.
    • values

      public Collection<V> values()
      Returns:
      All values.
    • iterator

      public Iterator<Map.Entry<T,V>> iterator()