Package io.openml.gearbox
Record Class Knapsack.KnapsackResult
java.lang.Object
java.lang.Record
io.openml.gearbox.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 aKnapsackResult
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.int
maxValue()
Returns the value of themaxValue
record component.Returns the value of thepackedItemIndices
record component.final String
toString()
Returns a string representation of this record class.int
Returns the value of thetotalWeight
record component.
-
Constructor Details
-
KnapsackResult
Creates an instance of aKnapsackResult
record class.- Parameters:
maxValue
- the value for themaxValue
record componentpackedItemIndices
- the value for thepackedItemIndices
record componenttotalWeight
- the value for thetotalWeight
record component
-
-
Method Details
-
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. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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 '=='. -
maxValue
public int maxValue()Returns the value of themaxValue
record component.- Returns:
- the value of the
maxValue
record component
-
packedItemIndices
Returns the value of thepackedItemIndices
record component.- Returns:
- the value of the
packedItemIndices
record component
-
totalWeight
public int totalWeight()Returns the value of thetotalWeight
record component.- Returns:
- the value of the
totalWeight
record component
-