Class IntegerVector
- java.lang.Object
-
- org.cicirello.search.representations.IntegerVector
-
- All Implemented Interfaces:
IntegerValued
,Copyable<IntegerVector>
- Direct Known Subclasses:
BoundedIntegerVector
public class IntegerVector extends Object implements IntegerValued, Copyable<IntegerVector>
A simple class for representing the input to a multivariate function, with integer values.
-
-
Constructor Summary
Constructors Constructor Description IntegerVector(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IntegerVector
copy()
Creates an identical copy of this object.boolean
equals(Object other)
Indicates whether some other object is "equal to" this one.int
get(int i)
Accesses the current value of a specified parameter.int
hashCode()
Returns a hash code value.int
length()
Gets the number of parameters.void
set(int i, int value)
Sets a function parameter to a specified value.int[]
toArray(int[] values)
Accesses the current values of all of the parameters.
-
-
-
Constructor Detail
-
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
public IntegerVector(IntegerVector other)
Initializes the vector as a copy of another.- Parameters:
other
- The other vector to copy.
-
-
Method Detail
-
length
public final int length()
Description copied from interface:IntegerValued
Gets the number of parameters.- Specified by:
length
in interfaceIntegerValued
- Returns:
- The number of parameters for this function.
-
get
public final int get(int i)
Description copied from interface:IntegerValued
Accesses the current value of a specified parameter.- Specified by:
get
in 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:IntegerValued
Accesses the current values of all of the parameters.- Specified by:
toArray
in 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:IntegerValued
Sets a function parameter to a specified value.- Specified by:
set
in interfaceIntegerValued
- Parameters:
i
- The parameter to set.value
- The new value for the i-th parameter.
-
copy
public IntegerVector copy()
Creates an identical copy of this object.- Specified by:
copy
in interfaceCopyable<IntegerVector>
- Returns:
- an identical copy of this object
-
equals
public boolean equals(Object other)
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.
-
-