Class IngredientSet<T,M>

Type Parameters:
T - The instance type.
M - The matching condition parameter.
All Implemented Interfaces:
Iterable<T>, IIngredientCollection<T,M>, IIngredientCollectionLike<T,M,T>, IIngredientCollectionMutable<T,M>, IIngredientSet<T,M>, IIngredientSetMutable<T,M>
Direct Known Subclasses:
IngredientHashSet, IngredientTreeSet

public class IngredientSet<T,M> extends IngredientCollectionCollectionWrappedAdapter<T,M,Set<IngredientInstanceWrapper<T,M>>> implements IIngredientSetMutable<T,M>
A mutable ingredient collection using set semantics. This means that each instances can only be present once in the collection based on its equals method.
See Also:
  • Constructor Details

  • Method Details

    • removeAll

      public int removeAll(T instance, M matchCondition)
      Description copied from interface: IIngredientCollectionMutable
      Remove all occurrences of 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:
      removeAll in interface IIngredientCollectionMutable<T,M>
      Overrides:
      removeAll in class IngredientCollectionAdapter<T,M>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      The number of removed instances.
    • contains

      public boolean contains(T instance, M matchCondition)
      Description copied from interface: IIngredientCollection
      Check if this collection 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:
      contains in interface IIngredientCollection<T,M>
      Overrides:
      contains in class IngredientCollectionAdapter<T,M>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      If this collection contains the given instance under the given match conditions.
    • count

      public int count(T instance, M matchCondition)
      Description copied from interface: IIngredientCollection
      Count the number of occurrences of 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:
      count in interface IIngredientCollection<T,M>
      Overrides:
      count in class IngredientCollectionAdapter<T,M>
      Parameters:
      instance - An instance.
      matchCondition - A match condition.
      Returns:
      The number of occurrences of the given instance under the given match conditions.
    • iterator

      public Iterator<T> iterator(T instance, M matchCondition)
      Description copied from interface: IIngredientCollection
      An iterator over this collection over all occurrences of the given instance under the given match conditions.
      Specified by:
      iterator in interface IIngredientCollection<T,M>
      Specified by:
      iterator in interface IIngredientCollectionLike<T,M,T>
      Overrides:
      iterator in class IngredientCollectionAdapter<T,M>
      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.
    • equals

      public boolean equals(Object obj)
      Description copied from interface: IIngredientCollectionLike
      Check if this collection equals the given object.
      Specified by:
      equals in interface IIngredientCollectionLike<T,M,T>
      Overrides:
      equals in class Object
      Parameters:
      obj - An object.
      Returns:
      True if the given object is an ingredient collection of the same type, component type and contains the same instances.