FRAMES NO FRAMES

Class IlcConstraintArray

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

The class IlcConstraintArray is the class for an array of instances of IlcConstraint.

It is a handle class. The implementation class for IlcConstraintArray is the undocumented class IlcConstraintArrayI. An object of this class contains a pointer to a constraint allocated on the Solver heap. Exploiting handles in this way greatly simplifies the programming interface since the handle can then be an automatic object. When you use 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 IlcConstraintArray()
public IlcConstraintArray(IlcConstraintArrayI * impl)
public IlcConstraintArray(IloSolver solver, IlcInt size)
Method Summary
public voiddisplay(ostream & stream) const
public IlcConstraintArrayI *getImpl() const
public IlcIntgetSize() const
public IloSolvergetSolver() const
public voidoperator=(const IlcConstraintArray & array)
public IlcConstraint &operator[](IlcInt rank) const
Constructor Detail

IlcConstraintArray

public IlcConstraintArray()

This constructor creates a void array. In other words, the array is an empty handle with a null handle pointer. The elements of this array must then be assigned before it is used, exactly as when you declare any other pointer.


IlcConstraintArray

public IlcConstraintArray(IlcConstraintArrayI * impl)

This constructor creates a handle object (an instance of the class IlcConstraintArray) from a pointer to an object (an instance of the implementation class IlcConstraintArrayI).


IlcConstraintArray

public IlcConstraintArray(IloSolver solver, IlcInt size)

This constructor creates an array of size elements. The elements of this array are not initialized. The argument size must be strictly greater than 0 (zero). Each element of the array must be assigned before the array can be used.


Method Detail

display

public void display(ostream & stream) const

This member function is called by the operator <<.


getImpl

public IlcConstraintArrayI * getImpl() const

This member function returns a pointer to the implementation object of the invoking array. You can use this member function to check whether an array is empty.


getSize

public IlcInt getSize() const

This member function returns the number of constraints in the invoking array.


getSolver

public IloSolver getSolver() const

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


operator=

public void operator=(const IlcConstraintArray & array)

This assignment operator copies array into the invoking array by assigning an address to the handle pointer of the invoking object. That address is the location of the implementation object of the argument array.


operator[]

public IlcConstraint & operator[](IlcInt rank) const

This subscripting operator returns a reference to a constraint corresponding to the given index in the invoking array of constraints.