Class TopologicalSorts

java.lang.Object
net.minecraft.util.TopologicalSorts

public final class TopologicalSorts extends Object
Utilities to perform a topological sort.
Mappings:
Namespace Name
official aoo
intermediary net/minecraft/class_6496
named net/minecraft/util/TopologicalSorts
  • Constructor Details

    • TopologicalSorts

      private TopologicalSorts()
  • Method Details

    • sort

      public static <T> boolean sort(Map<T,Set<T>> successors, Set<T> visited, Set<T> visiting, Consumer<T> reversedOrderConsumer, T now)
      Performs a topological sort recursively through a reverse DFS. The results are passed to the consumer in reverse order, where each element is guaranteed to be passed before any of its predecessors (dependencies). When multiple orders are valid, the results will first trace along earlier returned successors in the successor set iteration for each element.
      Parameters:
      successors - the map holding information on successor (dependents) of each element
      visited - elements that already iterated all their successors
      visiting - elements that are still iterating their successors
      reversedOrderConsumer - accepts sorted results in reverse order; each element is passed only before any of its predecessors (dependencies) is, or after all its successors (dependents) are passed
      now - the starting or current element
      Returns:
      true if the sort ends up in a loop, or false for a successful sort
      Mappings:
      Namespace Name Mixin selector
      official a Laoo;a(Ljava/util/Map;Ljava/util/Set;Ljava/util/Set;Ljava/util/function/Consumer;Ljava/lang/Object;)Z
      intermediary method_37951 Lnet/minecraft/class_6496;method_37951(Ljava/util/Map;Ljava/util/Set;Ljava/util/Set;Ljava/util/function/Consumer;Ljava/lang/Object;)Z
      named sort Lnet/minecraft/util/TopologicalSorts;sort(Ljava/util/Map;Ljava/util/Set;Ljava/util/Set;Ljava/util/function/Consumer;Ljava/lang/Object;)Z