Class RenderNodeDiffer
java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.engine.RenderNodeDiffer
RenderNodeDiffer implements the diff algorithm for the RenderNode tree.
The algorithm is based on comparing keys:
- if an old node and a new node share the same key, they are treated as the same node (possibly updated)
- without a key, slotIndex is used for the comparison instead
- added, removed, and updated nodes are all recorded in the DiffResult
Algorithm steps:
- build a key -> node map for the old nodes
- iterate the new node list, matching against the old nodes
- record matched nodes (update or move)
- record unmatched new nodes (added)
- record unmatched old nodes (removed)
- Since:
- 6.2.0
- Version:
- 1.0.0
- Author:
- UltiTools Team
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classThe key used to identify a RenderNode. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull DiffResultdiff(@NotNull List<RenderNode> oldNodes, @NotNull List<RenderNode> newNodes) Compares two sets of RenderNodes and returns the difference.private booleanhasChanged(@NotNull RenderNode oldNode, @NotNull RenderNode newNode) Compares a single node for changes.private booleaniconsEqual(@NotNull mc.obliviate.inventory.Icon a, @NotNull mc.obliviate.inventory.Icon b) Compares two Icons for equality.
-
Constructor Details
-
RenderNodeDiffer
public RenderNodeDiffer()
-
-
Method Details
-
diff
@NotNull public @NotNull DiffResult diff(@NotNull @NotNull List<RenderNode> oldNodes, @NotNull @NotNull List<RenderNode> newNodes) Compares two sets of RenderNodes and returns the difference.- Parameters:
oldNodes- the old list of RenderNodesnewNodes- the new list of RenderNodes- Returns:
- a DiffResult holding every change
-
hasChanged
private boolean hasChanged(@NotNull @NotNull RenderNode oldNode, @NotNull @NotNull RenderNode newNode) Compares a single node for changes.- Parameters:
oldNode- the old nodenewNode- the new node- Returns:
- true if it changed
-
iconsEqual
private boolean iconsEqual(@NotNull @NotNull mc.obliviate.inventory.Icon a, @NotNull @NotNull mc.obliviate.inventory.Icon b) Compares two Icons for equality.Note: this comparison is based on visual effect, not object identity.
- Parameters:
a- the first Iconb- the second Icon- Returns:
- true if they are equal
-