FRAMES NO FRAMES

Class IlcFloatArray

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

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.

IlcFloatArray is the array class for the basic floating-point class. It is a handle class. The implementation class for IlcFloatArray is the undocumented class IlcFloatArrayI.

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 IlcFloatArray()
public IlcFloatArray(IlcFloatArrayI * impl)
public IlcFloatArray(IloSolver s, IlcInt size, IlcFloat * values)
public IlcFloatArray(IloSolver solver, IlcInt size, IlcFloat prototype=0)
public IlcFloatArray(IloSolver solver, IlcInt size, IlcFloat exp0, IlcFloat exp1, ...)
public IlcFloatArray(IloSolver solver, IlcInt size, IlcInt exp0, IlcInt exp1, ...)
Method Summary
public IlcFloatArrayI *getImpl() const
public IlcIntgetSize() const
public IloSolvergetSolver() const
public voidoperator=(const IlcFloatArray & h)
public IlcFloat &operator[](IlcInt i) const
Constructor Detail

IlcFloatArray

public IlcFloatArray()

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


IlcFloatArray

public IlcFloatArray(IlcFloatArrayI * impl)

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


IlcFloatArray

public IlcFloatArray(IloSolver s, IlcInt size, IlcFloat * values)

This constructor creates an array of floating-point numbers 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. When you create an array of floating-point values, the elements of the array must be of the same type (for example, all floating-point, or all integer, but not a mixture of the two) because those types are not necessarily the same size in C++. You can write this:

 IlcFloatArray arrayok (s, 3, 1., 3., 2.);

or this:

 IlcFloatArray arrayOK(s, 3, 1, 3, 2);

but not this:

 IlcFloatArray notok(s, 3, 1., 3, 2.); // bad idea

in which some values are floating-point, some are integer, and consequently of different sizes in C++.


IlcFloatArray

public IlcFloatArray(IloSolver solver, IlcInt size, IlcFloat 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 not initialized.


IlcFloatArray

public IlcFloatArray(IloSolver solver, IlcInt size, IlcFloat exp0, IlcFloat exp1, ...)

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 (that is, the number of arguments of type IlcFloat); it must also be strictly greater than 0 (zero). The constructor creates an array of the values indicated by the other arguments. The arguments, exp0, exp1, etc. are all of the same type. Do not mix types within an array.


IlcFloatArray

public IlcFloatArray(IloSolver solver, IlcInt size, IlcInt exp0, IlcInt exp1, ...)

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 (that is, the number of arguments of type IlcInt); it must also be strictly greater than 0 (zero). The constructor creates an array of the values indicated by the other arguments. The arguments, exp0, exp1, etc. are all of the same type. Do not mix types within an array.


Method Detail

getImpl

public IlcFloatArrayI * getImpl() const
This constructor creates an object by copying another one.

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 invoking array.


getSolver

public IloSolver getSolver() const

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


operator=

public void operator=(const IlcFloatArray & 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 IlcFloat & 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.