Record Class Knapsack.KnapsackResult
java.lang.Object
java.lang.Record
io.openml.gearbox.algorithms.Knapsack.KnapsackResult
- Enclosing class:
Knapsack
public static record Knapsack.KnapsackResult(int maxValue, List<Integer> packedItemIndices, int totalWeight)
extends Record
A record to hold the result of the
Knapsack.knapsack(List, List, int) calculation as concise way to create
immutable data carrier classes.-
Constructor Summary
ConstructorsConstructorDescriptionKnapsackResult(int maxValue, List<Integer> packedItemIndices, int totalWeight) Creates an instance of aKnapsackResultrecord 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.intmaxValue()Returns the value of themaxValuerecord component.Returns the value of thepackedItemIndicesrecord component.final StringtoString()Returns a string representation of this record class.intReturns the value of thetotalWeightrecord component.
-
Constructor Details
-
KnapsackResult
Creates an instance of aKnapsackResultrecord class.- Parameters:
maxValue- the value for themaxValuerecord componentpackedItemIndices- the value for thepackedItemIndicesrecord componenttotalWeight- the value for thetotalWeightrecord 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. -
maxValue
public int maxValue()Returns the value of themaxValuerecord component.- Returns:
- the value of the
maxValuerecord component
-
packedItemIndices
-
totalWeight
public int totalWeight()Returns the value of thetotalWeightrecord component.- Returns:
- the value of the
totalWeightrecord component
-