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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLikeMultiClassifiedTrait
IIngredientCollectionLikeMultiClassifiedTrait.RemoveCallbackIterator<T,M, I, L extends IIngredientCollectionLike<T, M, I>> -
Constructor Summary
ConstructorsConstructorDescriptionIngredientMapMultiClassified(IngredientComponent<T, M> component, Supplier<IIngredientMapMutable<T, M, V>> mapCreator) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears this map of all instances.booleancontainsKey(T instance, M matchCondition) Check if this map contains the given instance under the given match conditions.booleancontainsKeyAll(Iterable<? extends T> instances, M matchCondition) Check if this map contains all the given instances under the given match conditions.booleancontainsValue(V value) Check if this map contains the given value.Get the value for the given instance.Get all values for all instances that match with the given instance under the given match conditions.iterator()An iterator over this collection over all occurrences of the given instance under the given match conditions.keySet()Get all key instances that match the given instance.Add a new entry.intputAllThreaded(ExecutorService executorService, IIngredientMap<? extends T, M, ? extends V> map) A multi-threaded putAll implementation.Remove the mapping for the given key instance.intRemove all occurrences of the given key instance under the given match conditions.voidremoveInstance(IngredientMapSingleClassified<T, M, V, ?> collection, Map.Entry<T, V> iterableInstance) Remove the given instance from the given collection-like.intsize()values()Methods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientMapAdapter
entrySet, equals, getComponent, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLike
equals, getComponent, hashCode, isEmpty, toStringMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLikeMultiClassifiedTrait
getBestClassifiedCollection, getFirstMatchingCategory, getFirstSingleClassifiedMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientMap
containsKey, containsKeyAll, countKey, entrySetMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientMapMutable
putAll, removeAll, removeAllMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
IngredientMapMultiClassified
public IngredientMapMultiClassified(IngredientComponent<T, M> component, Supplier<IIngredientMapMutable<T, M, V>> mapCreator)
-
-
Method Details
-
clear
public void clear()Description copied from interface:IIngredientMapMutableClears this map of all instances.- Specified by:
clearin interfaceIIngredientMapMutable<T,M, V>
-
put
Description copied from interface:IIngredientMapMutableAdd a new entry.- Specified by:
putin interfaceIIngredientMapMutable<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
Description copied from interface:IIngredientMapMutableRemove the mapping for the given key instance.- Specified by:
removein interfaceIIngredientMapMutable<T,M, V> - Parameters:
key- An instance key.- Returns:
- The value that was associated with the given instance.
-
removeAll
Description copied from interface:IIngredientMapMutableRemove 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:
removeAllin interfaceIIngredientMapMutable<T,M, V> - Overrides:
removeAllin classIngredientMapAdapter<T,M, V> - Parameters:
instance- An instance.matchCondition- A match condition.- Returns:
- The number of removed instances.
-
containsValue
Description copied from interface:IIngredientMapCheck if this map contains the given value.- Specified by:
containsValuein interfaceIIngredientMap<T,M, V> - Parameters:
value- A value.- Returns:
- If this map contains the given value.
-
containsKey
Description copied from interface:IIngredientMapCheck 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:
containsKeyin interfaceIIngredientMap<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
Description copied from interface:IIngredientMapCheck 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:
containsKeyAllin interfaceIIngredientMap<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
Description copied from interface:IIngredientMapGet the value for the given instance.- Specified by:
getin interfaceIIngredientMap<T,M, V> - Parameters:
key- An instance.- Returns:
- The value.
-
getAll
Description copied from interface:IIngredientMapGet 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:
getAllin interfaceIIngredientMap<T,M, V> - Overrides:
getAllin classIngredientMapAdapter<T,M, V> - Parameters:
key- An instance.matchCondition- A match condition.- Returns:
- All matching values.
-
keySet
- Specified by:
keySetin interfaceIIngredientMap<T,M, V> - Returns:
- All key instances.
-
keySet
Description copied from interface:IIngredientMapGet 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:
keySetin interfaceIIngredientMap<T,M, V> - Overrides:
keySetin classIngredientMapAdapter<T,M, V> - Parameters:
instance- An instance.matchCondition- A match condition.- Returns:
- All key instances that match the given instance.
-
values
- Specified by:
valuesin interfaceIIngredientMap<T,M, V> - Returns:
- All values.
-
size
public int size()- Specified by:
sizein interfaceIIngredientCollectionLike<T,M, V> - Returns:
- The number of instances contained in this collection.
-
iterator
-
iterator
Description copied from interface:IIngredientCollectionLikeAn iterator over this collection over all occurrences of the given instance under the given match conditions.- Specified by:
iteratorin interfaceIIngredientCollectionLike<T,M, V> - Overrides:
iteratorin classIngredientMapAdapter<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:IIngredientCollectionLikeMultiClassifiedTraitRemove the given instance from the given collection-like. This is used internally for iteration purposes.- Specified by:
removeInstancein interfaceIIngredientCollectionLikeMultiClassifiedTrait<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, getClassifiedCollections()?>, IngredientMapSingleClassified<T, M, V, ?>> - Specified by:
getClassifiedCollectionsin interfaceIIngredientCollectionLikeMultiClassifiedTrait<T,M, Map.Entry<T, V>, IngredientMapSingleClassified<T, M, V, ?>> - Returns:
- A mapping of all internal classified collections.
-