Class IngredientMapMultiClassified<T,M,V>

java.lang.Object
org.cyclops.cyclopscore.ingredient.collection.IngredientMapAdapter<T,M,V>
org.cyclops.cyclopscore.ingredient.collection.IngredientMapMultiClassified<T,M,V>
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>>, IIngredientCollectionLikeMultiClassifiedTrait<T,M,Map.Entry<T,V>,IngredientMapSingleClassified<T,M,V,?>>, IIngredientMap<T,M,V>, IIngredientMapMutable<T,M,V>

public class IngredientMapMultiClassified<T,M,V> extends IngredientMapAdapter<T,M,V> implements IIngredientMapMutable<T,M,V>, IIngredientCollectionLikeMultiClassifiedTrait<T,M,Map.Entry<T,V>,IngredientMapSingleClassified<T,M,V,?>>
An ingredient map that classifies instances in smaller collections based on all category type of a component type. This allows instances to be looked up or removed more efficiently when the used match condition is compatible with the identifying match condition of category types.
  • Constructor Details

  • Method Details

    • clear

      public void clear()
      Description copied from interface: IIngredientMapMutable
      Clears this map of all instances.
      Specified by:
      clear in interface IIngredientMapMutable<T,M,V>
    • put

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

      public int putAllThreaded(@Nullable ExecutorService executorService, IIngredientMap<? extends T,M,? extends V> map)
      A multi-threaded putAll implementation. This will create workers for adding the given instances to all classified collections.
      Parameters:
      executorService - An optional executor service. If none is provided, a new temporary one will be created for the duration of this method call.
      map - The map entries that needs to be added.
      Returns:
      The amount of entries that were added.
    • remove

      @Nullable public V remove(T key)
      Description copied from interface: IIngredientMapMutable
      Remove the mapping for the given key instance.
      Specified by:
      remove in interface IIngredientMapMutable<T,M,V>
      Parameters:
      key - An instance key.
      Returns:
      The value that was associated with the given instance.
    • removeAll

      public int removeAll(T instance, M matchCondition)
      Description copied from interface: IIngredientMapMutable
      Remove all occurrences of the given key instance under the given match conditions. This instance will be compared based on the matcher from the ingredient component type using the given match condition.
      Specified by:
      removeAll in interface IIngredientMapMutable<T,M,V>
      Overrides:
      removeAll in class IngredientMapAdapter<T,M,V>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      The number of removed instances.
    • containsValue

      public boolean containsValue(V value)
      Description copied from interface: IIngredientMap
      Check if this map contains the given value.
      Specified by:
      containsValue in interface IIngredientMap<T,M,V>
      Parameters:
      value - A value.
      Returns:
      If this map contains the given value.
    • containsKey

      public boolean containsKey(T instance, M matchCondition)
      Description copied from interface: IIngredientMap
      Check if this map contains the given instance under the given match conditions. This instance will be compared based on the matcher from the ingredient component type using the given match condition.
      Specified by:
      containsKey in interface IIngredientMap<T,M,V>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      If this map contains the given instance under the given match conditions.
    • containsKeyAll

      public boolean containsKeyAll(Iterable<? extends T> instances, M matchCondition)
      Description copied from interface: IIngredientMap
      Check if this map contains all the given instances under the given match conditions. The instances will be compared based on the matcher from the ingredient component type using the given match condition.
      Specified by:
      containsKeyAll in interface IIngredientMap<T,M,V>
      Parameters:
      instances - Instances.
      matchCondition - A match condition.
      Returns:
      If this map contains all the given instances under the given match conditions.
    • get

      @Nullable public V get(T key)
      Description copied from interface: IIngredientMap
      Get the value for the given instance.
      Specified by:
      get in interface IIngredientMap<T,M,V>
      Parameters:
      key - An instance.
      Returns:
      The value.
    • getAll

      public Collection<V> getAll(T key, M matchCondition)
      Description copied from interface: IIngredientMap
      Get all values for all instances that match with the given instance under the given match conditions. This instance will be compared based on the matcher from the ingredient component type using the given match condition.
      Specified by:
      getAll in interface IIngredientMap<T,M,V>
      Overrides:
      getAll in class IngredientMapAdapter<T,M,V>
      Parameters:
      key - An instance.
      matchCondition - A match condition.
      Returns:
      All matching values.
    • keySet

      public IngredientSet<T,M> keySet()
      Specified by:
      keySet in interface IIngredientMap<T,M,V>
      Returns:
      All key instances.
    • keySet

      public IngredientSet<T,M> keySet(T instance, M matchCondition)
      Description copied from interface: IIngredientMap
      Get all key instances that match the given instance. This instance will be compared based on the matcher from the ingredient component type using the given match condition.
      Specified by:
      keySet in interface IIngredientMap<T,M,V>
      Overrides:
      keySet in class IngredientMapAdapter<T,M,V>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      All key instances that match the given instance.
    • values

      public Collection<V> values()
      Specified by:
      values in interface IIngredientMap<T,M,V>
      Returns:
      All values.
    • size

      public int size()
      Specified by:
      size in interface IIngredientCollectionLike<T,M,V>
      Returns:
      The number of instances contained in this collection.
    • iterator

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

      public Iterator<Map.Entry<T,V>> iterator(T instance, M matchCondition)
      Description copied from interface: IIngredientCollectionLike
      An iterator over this collection over all occurrences of the given instance under the given match conditions.
      Specified by:
      iterator in interface IIngredientCollectionLike<T,M,V>
      Overrides:
      iterator in class IngredientMapAdapter<T,M,V>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      An iterator over this collection over all occurrences of the given instance under the given match conditions.
    • removeInstance

      public void removeInstance(IngredientMapSingleClassified<T,M,V,?> collection, Map.Entry<T,V> iterableInstance)
      Description copied from interface: IIngredientCollectionLikeMultiClassifiedTrait
      Remove the given instance from the given collection-like. This is used internally for iteration purposes.
      Specified by:
      removeInstance in interface IIngredientCollectionLikeMultiClassifiedTrait<T,M,Map.Entry<T,V>,IngredientMapSingleClassified<T,M,V,?>>
      Parameters:
      collection - A collection-like.
      iterableInstance - An iterator instance.
    • getClassifiedCollections

      public Map<IngredientComponentCategoryType<T,M,?>,IngredientMapSingleClassified<T,M,V,?>> getClassifiedCollections()
      Specified by:
      getClassifiedCollections in interface IIngredientCollectionLikeMultiClassifiedTrait<T,M,Map.Entry<T,V>,IngredientMapSingleClassified<T,M,V,?>>
      Returns:
      A mapping of all internal classified collections.