Record Class BaseTopologicalOrderGraph.NodeTopologicalOrder

java.lang.Object
java.lang.Record
ai.timefold.solver.core.impl.domain.variable.declarative.BaseTopologicalOrderGraph.NodeTopologicalOrder
All Implemented Interfaces:
Comparable<BaseTopologicalOrderGraph.NodeTopologicalOrder>
Enclosing interface:
BaseTopologicalOrderGraph

public static record BaseTopologicalOrderGraph.NodeTopologicalOrder(int nodeId, BaseTopologicalOrderGraph graph) extends Record implements Comparable<BaseTopologicalOrderGraph.NodeTopologicalOrder>
Stores a graph node id and dynamically calculates its topological order. Comparisons ignore node id and only use the topological order. For instance, for x = (0, 0) and y = (1, 5), x is before y, whereas for x = (0, 5) and y = (1, 0), y is before x. Note BaseTopologicalOrderGraph is not guaranteed to return every topological order index (i.e. it might be the case no nodes has order 0).
  • Constructor Details

    • NodeTopologicalOrder

      public NodeTopologicalOrder(int nodeId, BaseTopologicalOrderGraph graph)
      Creates an instance of a NodeTopologicalOrder record class.
      Parameters:
      nodeId - the value for the nodeId record component
      graph - the value for the graph record component
  • Method Details

    • compareTo

      public int compareTo(BaseTopologicalOrderGraph.NodeTopologicalOrder other)
      If the BaseTopologicalOrderGraph.getTopologicalOrder(int) of the node changes while inside a PriorityQueue, that PriorityQueue would be corrupted.

      It is vital that all changes to a TopologicalOrderGraph happen before nodes are inserted into a PriorityQueue, and that the PriorityQueue is cleared before future changes to the TopologicalOrderGraph.

      Specified by:
      compareTo in interface Comparable<BaseTopologicalOrderGraph.NodeTopologicalOrder>
      Parameters:
      other - The node this node is being topologically compared to.
      Returns:
      a negative int if this node is topologically before the other node, a positive int if this node is topologically after the other node, 0 if both nodes have the same topological order.
    • equals

      public boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • nodeId

      public int nodeId()
      Returns the value of the nodeId record component.
      Returns:
      the value of the nodeId record component
    • graph

      public BaseTopologicalOrderGraph graph()
      Returns the value of the graph record component.
      Returns:
      the value of the graph record component