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 Summary
ConstructorsConstructorDescriptionNodeTopologicalOrder(int nodeId, BaseTopologicalOrderGraph graph) Creates an instance of aNodeTopologicalOrderrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintIf theBaseTopologicalOrderGraph.getTopologicalOrder(int)of the node changes while inside aPriorityQueue, thatPriorityQueuewould be corrupted.booleanIndicates whether some other object is "equal to" this one.graph()Returns the value of thegraphrecord component.inthashCode()Returns a hash code value for this object.intnodeId()Returns the value of thenodeIdrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
NodeTopologicalOrder
Creates an instance of aNodeTopologicalOrderrecord class.- Parameters:
nodeId- the value for thenodeIdrecord componentgraph- the value for thegraphrecord component
-
-
Method Details
-
compareTo
If theBaseTopologicalOrderGraph.getTopologicalOrder(int)of the node changes while inside aPriorityQueue, thatPriorityQueuewould be corrupted.It is vital that all changes to a
TopologicalOrderGraphhappen before nodes are inserted into aPriorityQueue, and that thePriorityQueueis cleared before future changes to theTopologicalOrderGraph.- Specified by:
compareToin interfaceComparable<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
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
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. -
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. -
nodeId
public int nodeId()Returns the value of thenodeIdrecord component.- Returns:
- the value of the
nodeIdrecord component
-
graph
Returns the value of thegraphrecord component.- Returns:
- the value of the
graphrecord component
-