java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.engine.RenderNodeDiffer

public class RenderNodeDiffer extends Object
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:

  1. build a key -> node map for the old nodes
  2. iterate the new node list, matching against the old nodes
  3. record matched nodes (update or move)
  4. record unmatched new nodes (added)
  5. record unmatched old nodes (removed)
Since:
6.2.0
Version:
1.0.0
Author:
UltiTools Team
  • 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 RenderNodes
      newNodes - 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 node
      newNode - 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 Icon
      b - the second Icon
      Returns:
      true if they are equal