Record Class KSState
java.lang.Object
java.lang.Record
org.ddolib.examples.nolayer.knapsack.KSState
- Record Components:
currentItem- the index of the item currently being consideredremainingCapacity- the remaining capacity in the knapsack
State for the NoLayer formulation of the Knapsack Problem.
-
Constructor Summary
ConstructorsConstructorDescriptionKSState(int currentItem, int remainingCapacity) Creates an instance of aKSStaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thecurrentItemrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of theremainingCapacityrecord component.toString()Returns a string representation of this record class.
-
Constructor Details
-
KSState
public KSState(int currentItem, int remainingCapacity) Creates an instance of aKSStaterecord class.- Parameters:
currentItem- the value for thecurrentItemrecord componentremainingCapacity- the value for theremainingCapacityrecord 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. All components in this record class are compared with '=='. -
currentItem
public int currentItem()Returns the value of thecurrentItemrecord component.- Returns:
- the value of the
currentItemrecord component
-
remainingCapacity
public int remainingCapacity()Returns the value of theremainingCapacityrecord component.- Returns:
- the value of the
remainingCapacityrecord component
-