java.lang.Object
org.cicirello.search.representations.IntegerVector
- All Implemented Interfaces:
IntegerValued,Copyable<IntegerVector>
- Direct Known Subclasses:
BoundedIntegerVector
A simple class for representing the input to a multivariate function, with integer values.
-
Constructor Summary
ConstructorsConstructorDescriptionIntegerVector(int n) Initializes the vector to all 0 values.IntegerVector(int[] x) Initializes the vector to the specified values.IntegerVector(IntegerVector other) Initializes the vector as a copy of another. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates an identical copy of this object.booleanIndicates whether some other object is "equal to" this one.static voidexchange(IntegerVector v1, IntegerVector v2, int firstIndex, int lastIndex) Exchanges a sequence of ints between two IntegerVector objects.final intget(int i) Accesses the current value of a specified parameter.inthashCode()Returns a hash code value.final intlength()Gets the number of parameters.voidset(int[] values) Sets all values from an array (copies values from the array).voidset(int i, int value) Sets a function parameter to a specified value.final int[]toArray(int[] values) Accesses the current values of all of the parameters.
-
Constructor Details
-
IntegerVector
public IntegerVector(int n) Initializes the vector to all 0 values.- Parameters:
n- The length of the vector.
-
IntegerVector
public IntegerVector(int[] x) Initializes the vector to the specified values.- Parameters:
x- The initial values for the vector.
-
IntegerVector
Initializes the vector as a copy of another.- Parameters:
other- The other vector to copy.
-
-
Method Details
-
length
public final int length()Description copied from interface:IntegerValuedGets the number of parameters.- Specified by:
lengthin interfaceIntegerValued- Returns:
- The number of parameters for this function.
-
get
public final int get(int i) Description copied from interface:IntegerValuedAccesses the current value of a specified parameter.- Specified by:
getin interfaceIntegerValued- Parameters:
i- The parameter to get.- Returns:
- The current value of the i-th parameter.
-
toArray
public final int[] toArray(int[] values) Description copied from interface:IntegerValuedAccesses the current values of all of the parameters.- Specified by:
toArrayin interfaceIntegerValued- Parameters:
values- An array to hold the result. If values is null or if values.length is not equal to this.length(), then a new array is constructed for the result.- Returns:
- An array containing the current values of all of the parameters.
-
set
public void set(int i, int value) Description copied from interface:IntegerValuedSets a function parameter to a specified value.- Specified by:
setin interfaceIntegerValued- Parameters:
i- The parameter to set.value- The new value for the i-th parameter.
-
set
public void set(int[] values) Description copied from interface:IntegerValuedSets all values from an array (copies values from the array).- Specified by:
setin interfaceIntegerValued- Parameters:
values- an array of new values
-
exchange
Exchanges a sequence of ints between two IntegerVector objects.- Parameters:
v1- The first IntegerVector.v2- The second IntegerVector.firstIndex- The first index of the sequence to exchange, inclusive.lastIndex- The last index of the sequence to exchange, inclusive.- Throws:
IndexOutOfBoundsException- if either index is negative, or if either index ≥ v1.length(), or if either index ≥ v2.length()
-
copy
Creates an identical copy of this object.- Specified by:
copyin interfaceCopyable<IntegerVector>- Returns:
- an identical copy of this object
-
equals
Indicates whether some other object is "equal to" this one. To be equal, the other object must be of the same runtime type and contain the same values. -
hashCode
public int hashCode()Returns a hash code value.
-