Record Class SalesmanSolution
java.lang.Object
java.lang.Record
topics.greedy.tsp.SalesmanSolution
Record class to hold the calculated path and its cost.
-
Constructor Summary
ConstructorsConstructorDescriptionSalesmanSolution(int[] path, int totalCost) Creates an instance of aSalesmanSolutionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.int[]path()Returns the value of thepathrecord component.toString()Returns a string representation of this record class.intReturns the value of thetotalCostrecord component.
-
Constructor Details
-
SalesmanSolution
public SalesmanSolution(int[] path, int totalCost) Creates an instance of aSalesmanSolutionrecord class.- Parameters:
path- the value for thepathrecord componenttotalCost- the value for thetotalCostrecord component
-
-
Method Details
-
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
path
public int[] path()Returns the value of thepathrecord component.- Returns:
- the value of the
pathrecord component
-
totalCost
public int totalCost()Returns the value of thetotalCostrecord component.- Returns:
- the value of the
totalCostrecord component
-