FRAMES NO FRAMES

Class IlcIntArray

Definition file: ilsolver/intexp.h
Include file: <ilsolver/ilosolver.h>

IlcIntArray is the array class for the basic integer class. It is a handle class.

For each basic type, Solver defines a corresponding array class. This array class is a handle class. In other words, an object of this class contains a pointer to another object allocated on the Solver heap associated with a solver (an instance of IloSolver). Exploiting handles in this way greatly simplifies the programming interface since the handle can then be an automatic object: as a developer using handles, you do not have to worry about memory allocation.

Empty Handle or Null Array

It is possible to create a null array, or in other words, an empty handle. When you do so, only these operations are allowed on that null array:

Attempts to access a null array in any other way will throw an exception (an instance of IloSolver::SolverErrorException).

See Also:

Constructor Summary
public IlcIntArray()
public IlcIntArray(IlcInt * impl)
public IlcIntArray(IloSolver solver, IlcInt size, IlcInt * values)
public IlcIntArray(IloSolver solver, IlcInt size, IlcInt prototype=0)
public IlcIntArray(IloSolver solver, IlcInt size, IlcInt exp0, IlcInt exp...)
Method Summary
public IlcInt *getImpl() const
public IlcIntgetSize() const
public IloSolvergetSolver() const
public voidoperator=(const IlcIntArray & h)
public IlcIntExpoperator[](const IlcIntExp rank) const
public IlcInt &operator[](IlcInt i) const
Constructor Detail

IlcIntArray

public IlcIntArray()

This constructor creates an empty handle. You must initialize it before you use it.


IlcIntArray

public IlcIntArray(IlcInt * impl)

This constructor creates a handle object from a pointer to an implementation object.


IlcIntArray

public IlcIntArray(IloSolver solver, IlcInt size, IlcInt * values)

This constructor creates an array of integers containing the values in the array values. The argument size must be the length of the array values; it must also be strictly greater than 0 (zero). Solver does not keep a pointer to the array values.

Here is one way to create an array containing the integers 1, 3, 2.

 IlcInt values [3];
 values[0] = 1;
 values[1] = 3;
 values[2] = 2;
 IlcIntArray array1 (s, 3, values);

IlcIntArray

public IlcIntArray(IloSolver solver, IlcInt size, IlcInt prototype=0)

This constructor creates an array of size elements. The argument size must be strictly greater than 0 (zero). The elements of this array are initialized to the value of prototype.


IlcIntArray

public IlcIntArray(IloSolver solver, IlcInt size, IlcInt exp0, IlcInt exp...)

This constructor accepts a variable number of arguments. Its first argument, size, indicates the length of the array that this constructor will create; size must be the number of arguments minus one; it must also be strictly greater than 0 (zero). The constructor creates an array of the values indicated by the other arguments.

Here is another way to create an array containing the integers 1,3,2.

 IlcIntArray array2 (s, 3, 1, 3, 2);
 

Method Detail

getImpl

public IlcInt * getImpl() const

This member function returns a pointer to the implementation object of the invoking handle.


getSize

public IlcInt getSize() const

This member function returns the number of elements in the array.


getSolver

public IloSolver getSolver() const

This member function returns an instance of IloSolver associated with the invoking object.


operator=

public void operator=(const IlcIntArray & h)

This operator assigns an address to the handle pointer of the invoking object. That address is the location of the implementation object of the provided argument.


operator[]

public IlcIntExp operator[](const IlcIntExp rank) const

This subscripting operator returns a constrained integer expression. For clarity, let's call A the invoking array. When rank is bound to the value i, the value of the expression is A[i]. More generally, the domain of the expression is the set of values A[i] where the i are in the domain of rank.


operator[]

public IlcInt & operator[](IlcInt i) const

This operator returns a reference to the element at rank i. This operator can be used for accessing (that is, simply reading) the element or for modifying (that is, writing) it.

Here is still another way to create an array containing the integers 1, 3, 2.

 IlcIntArray array5 (s, 3);
 array5[0] = 1;
 array5[1] = 3;
 array5[2] = 2;