Class IngredientCollectionDiffHelpers
java.lang.Object
org.cyclops.cyclopscore.ingredient.collection.diff.IngredientCollectionDiffHelpers
Helper methods for ingredient collection diffs.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
M> void applyDiff
(IngredientComponent<T, M> ingredientComponent, IngredientCollectionDiff<T, M> diff, IIngredientCollectionMutable<T, M> collection) Apply the given diff to the given collection.static <T,
M> IngredientCollectionDiff<T, M> getDiff
(IngredientComponent<T, M> ingredientComponent, IngredientCollectionPrototypeMap<T, M> oldInstancesCache, IngredientCollectionPrototypeMap<T, M> newInstancesCache, Iterator<T> newInstances) Calculate a diff between oldInstancesCache - newInstances, and produce a diff.
-
Constructor Details
-
IngredientCollectionDiffHelpers
public IngredientCollectionDiffHelpers()
-
-
Method Details
-
getDiff
public static <T,M> IngredientCollectionDiff<T,M> getDiff(IngredientComponent<T, M> ingredientComponent, @Nullable IngredientCollectionPrototypeMap<T, M> oldInstancesCache, IngredientCollectionPrototypeMap<T, M> newInstancesCache, Iterator<T> newInstances) Calculate a diff between oldInstancesCache - newInstances, and produce a diff. Additionally, this will populate newInstancesCache with all instances from newInstances.- Type Parameters:
T
- The instance type.M
- The matching condition parameter.- Parameters:
ingredientComponent
- The ingredient component type.oldInstancesCache
- The collection of instances to take the difference from.newInstancesCache
- An empty collection to store our new instances from newInstances. This should be used as oldInstancesCache parameter on the next call. This map MUST accept negative instances. of this method.newInstances
- The new instances to calculate the difference with.- Returns:
- The resulting diff between oldInstancesCache and newInstances.
-
applyDiff
public static <T,M> void applyDiff(IngredientComponent<T, M> ingredientComponent, IngredientCollectionDiff<T, M> diff, IIngredientCollectionMutable<T, M> collection) Apply the given diff to the given collection.- Type Parameters:
T
- The instance type.M
- The matching condition parameter.- Parameters:
ingredientComponent
- The ingredient component type.diff
- The diff to apply.collection
- The collection to apply the diff to.
-