FRAMES NO FRAMES

Class IlcBoolVarArray

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

The class IlcBoolVarArray is the class for an array of instances of IlcBoolVar.

Generic Constraints

The array makes it easier to implement generic constraints. In this context, a generic constraint is a constraint that applies to all of the variables in the array. Member functions of the array class are available to post such generic constraints. A generic constraint is then allocated and recorded only once for all the variables in the array. This fact represents a significant economy in memory, compared to allocating and recording one constraint per variable.

Backtracking and Reversibility

All the functions and member functions capable of modifying arrays of constrained Boolean variables are reversible. In particular, when modifiers and functions that post constraints are called, the state before their call will be saved by Solver.

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 IlcBoolVarArray()
public IlcBoolVarArray(IlcBoolVarArrayI * impl)
public IlcBoolVarArray(const IlcBoolVarArray & array)
public IlcBoolVarArray(IloSolver solver, IlcInt size)
Method Summary
public voiddisplay(ostream & stream) const
public IlcBoolVar &getElem(IlcInt index) const
public IlcBoolVarArrayI *getImpl() const
public IlcIntgetSize() const
public IloSolvergetSolver() const
public voidoperator=(const IlcBoolVarArray & array)
public IlcBoolVar &operator[](IlcInt index) const
Constructor Detail

IlcBoolVarArray

public IlcBoolVarArray()

This constructor creates an uninitialized array of constrained Boolean variables. The index range of the array is undefined. The array must be assigned before it can be used.


IlcBoolVarArray

public IlcBoolVarArray(IlcBoolVarArrayI * impl)

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


IlcBoolVarArray

public IlcBoolVarArray(const IlcBoolVarArray & array)

This copy constructor creates a new instance of IlcBoolVarArray. After execution of this constructor, both the newly created array and array point to the same implementation object.


IlcBoolVarArray

public IlcBoolVarArray(IloSolver solver, IlcInt size)

This constructor creates an instance of IlcBoolVarArray and adds it to those belonging to solver. The parameter size, of course, indicates the size of the new array.


Method Detail

display

public void display(ostream & stream) const

This member function is called by the operator <<. The name of the invoking array, if it has been assigned with setName, or the string IlcBoolVarArrayI, otherwise, will be printed on the given output stream, followed by the display of all the elements of the array enclosed by brackets.


getElem

public IlcBoolVar & getElem(IlcInt index) const

This member function returns a reference to the constrained Boolean variable located at index in the invoking array.


getImpl

public IlcBoolVarArrayI * getImpl() const

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


getSize

public IlcInt getSize() const

This member function returns an integer that indicates the size of 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 IlcBoolVarArray & array)

This assignment operator copies array into the invoking constrained Boolean 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 IlcBoolVar & operator[](IlcInt index) const

This subscripting operator returns a reference to a constrained Boolean variable corresponding to the given index in the invoking array of constrained Boolean variables. Solver will throw an exception (an instance of IloSolver::SolverErrorException) with the message "bad index" if the given index is not a valid one for the invoking array of constrained Boolean variables.