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
ConstructorDescriptionIngredientMapMultiClassified
(IngredientComponent<T, M> component, Supplier<IIngredientMapMutable<T, M, V>> mapCreator) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears this map of all instances.boolean
containsKey
(T instance, M matchCondition) Check if this map contains the given instance under the given match conditions.boolean
containsKeyAll
(Iterable<? extends T> instances, M matchCondition) Check if this map contains all the given instances under the given match conditions.boolean
containsValue
(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.int
putAllThreaded
(ExecutorService executorService, IIngredientMap<? extends T, M, ? extends V> map) A multi-threaded putAll implementation.Remove the mapping for the given key instance.int
Remove all occurrences of the given key instance under the given match conditions.void
removeInstance
(IngredientMapSingleClassified<T, M, V, ?> collection, Map.Entry<T, V> iterableInstance) Remove the given instance from the given collection-like.int
size()
values()
Methods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientMapAdapter
entrySet, equals, getComponent, hashCode, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLike
equals, getComponent, hashCode, isEmpty, toString
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLikeMultiClassifiedTrait
getBestClassifiedCollection, getFirstMatchingCategory, getFirstSingleClassified
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientMap
containsKey, containsKeyAll, countKey, entrySet
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientMapMutable
putAll, removeAll, removeAll
Methods 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:IIngredientMapMutable
Clears this map of all instances.- Specified by:
clear
in interfaceIIngredientMapMutable<T,
M, V>
-
put
Description copied from interface:IIngredientMapMutable
Add a new entry.- Specified by:
put
in 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:IIngredientMapMutable
Remove the mapping for the given key instance.- Specified by:
remove
in interfaceIIngredientMapMutable<T,
M, V> - Parameters:
key
- An instance key.- Returns:
- The value that was associated with the given instance.
-
removeAll
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 interfaceIIngredientMapMutable<T,
M, V> - Overrides:
removeAll
in classIngredientMapAdapter<T,
M, V> - Parameters:
instance
- An instance.matchCondition
- A match condition.- Returns:
- The number of removed instances.
-
containsValue
Description copied from interface:IIngredientMap
Check if this map contains the given value.- Specified by:
containsValue
in interfaceIIngredientMap<T,
M, V> - Parameters:
value
- A value.- Returns:
- If this map contains the given value.
-
containsKey
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 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: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 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:IIngredientMap
Get the value for the given instance.- Specified by:
get
in interfaceIIngredientMap<T,
M, V> - Parameters:
key
- An instance.- Returns:
- The value.
-
getAll
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 interfaceIIngredientMap<T,
M, V> - Overrides:
getAll
in classIngredientMapAdapter<T,
M, V> - Parameters:
key
- An instance.matchCondition
- A match condition.- Returns:
- All matching values.
-
keySet
- Specified by:
keySet
in interfaceIIngredientMap<T,
M, V> - Returns:
- All key instances.
-
keySet
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 interfaceIIngredientMap<T,
M, V> - Overrides:
keySet
in classIngredientMapAdapter<T,
M, V> - Parameters:
instance
- An instance.matchCondition
- A match condition.- Returns:
- All key instances that match the given instance.
-
values
- Specified by:
values
in interfaceIIngredientMap<T,
M, V> - Returns:
- All values.
-
size
public int size()- Specified by:
size
in interfaceIIngredientCollectionLike<T,
M, V> - Returns:
- The number of instances contained in this collection.
-
iterator
-
iterator
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 interfaceIIngredientCollectionLike<T,
M, V> - Overrides:
iterator
in 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:IIngredientCollectionLikeMultiClassifiedTrait
Remove the given instance from the given collection-like. This is used internally for iteration purposes.- Specified by:
removeInstance
in 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:
getClassifiedCollections
in interfaceIIngredientCollectionLikeMultiClassifiedTrait<T,
M, Map.Entry<T, V>, IngredientMapSingleClassified<T, M, V, ?>> - Returns:
- A mapping of all internal classified collections.
-