Skip to main content
FRAMES NO FRAMES

Class IloArray<>

Definition file: ilconcert/iloenv.h
Map of IloArray<>IloArray<>IloArray<>
A template to create classes of arrays for elements of a given class.

This C++ template creates a class of arrays for elements of a given class. In other words, you can use this template to create arrays of Concert Technology objects; you can also use this template to create arrays of arrays (that is, multidimensional arrays).

In its synopsis, X represents a class, x is an instance of the class X. This template creates the array class (IloArrayX) for any class in Concert Technology, including classes with names in the form IloXArray, such as IloExtractableArray. Concert Technology predefines the array classes listed here as See Also. The member functions defined by this template are documented in each of those predefined classes.

The classes you create in this way consist of extensible arrays. That is, you can add elements to the array as needed.

Deleting Arrays

The member function end created by this template deletes only the array; the member function does not delete the elements of the array.

Copying Arrays

Like certain other Concert Technology classes, a class of arrays created by IloArray is a handle class corresponding to an implementation class. In other words, an instance of an IloArray class is a handle pointing to a corresponding implementation object. More than one handle may point to the same implementation object.

Input and Output of Multidimensional Arrays

The template operator >> makes it possible to read numeric values from a file in the format [x, y, z, ...] where x, y, z are the results of the operator >> for class X. Class X must provide a default constructor for operator >> to work. That is, the statement X x; must work for X. This input operator is limited to numeric values.

Likewise, the template operator << makes it possible to write to a file in the format [x, y, z, ...] where x, y, z are the results of the operator << for class X. (This output operator is not limited to numeric values, as the input operator is.)

These two operators make it possible to read and write multidimensional arrays of numeric values like this:

 IloArray<IloArray<IloIntArray> > 

(Notice the space between > > at the end of that statement. It is necessary in C++.)

However, there is a practical limit of four on the number of dimensions supported by the input operator for reading multidimensional arrays. This limit is due to the inability of certain C++ compilers to support templates correctly. Specifically, you can read input by means of the input operator for multidimensional arrays of one, two, three, or four dimensions. There is no such limit on the number of dimensions with respect to the output operator for multidimensional arrays.

See Also these classes in the CPLEX C++ API Reference Manual: IloSemiContVarArray, IloSOS1Array, IloSOS2Array, IloNumColumnArray.

See Also these classes in the IBM ILOG Solver Reference Manual: IloAnyArray, IloAnySetVarArray, IloAnyVarArray, IloFloatArray, IloFloatVarArray.

See Also:

Method Summary
public voidadd(IloArray< X > ax) const
public voidadd(IloInt more, X x) const
public voidadd(X x) const
public voidclear()
public voidend()
public IloEnvgetEnv() const
public IloIntgetSize() const
public IloArray(IloEnv env, IloInt max=0)
public X &operator[](IloInt i)
public const X &operator[](IloInt i) const
public voidremove(IloInt first, IloInt nb=1)
Method Detail

IloArray

public IloArray(IloEnv env, IloInt max=0)

This constructor creates an array of max elements, all of which are empty handles.


add

public void add(IloArray< X > ax) const

This member function appends the elements in ax to the invoking array.


add

public void add(IloInt more, X x) const

This member function appends x to the invoking array multiple times. The argument more specifies how many times.


add

public void add(X x) const

This member function appends x to the invoking array.


clear

public void clear()

This member function removes all the elements from the invoking array. In other words, it produces an empty array.


end

public void end()

This member function first removes the invoking extractable object from all other extractable objects where it is used (such as a model, ranges, etc.) and then deletes the invoking extractable object. That is, it frees all the resources used by the invoking object. After a call to this member function, you cannot use the invoking extractable object again.


getEnv

public IloEnv getEnv() const

This member function returns the environment where the invoking array was created. The elements of the invoking array belong to the same environment.


getSize

public IloInt getSize() const

This member function returns an integer specifying the size of the invoking array. An empty array has size 0 (zero).


operator[]

public X & operator[](IloInt i)

This operator returns a reference to the object located in the invoking array at the position specified by the index i.


operator[]

public const X & operator[](IloInt i) const

This operator returns a reference to the object located in the invoking array at the position specified by the index i. On const arrays, Concert Technology uses the const operator:

 IloArray operator[] (IloInt i) const;
 

remove

public void remove(IloInt first, IloInt nb=1)

This member function removes elements from the invoking array. It begins removing elements at the index specified by first, and it removes nb elements (nb = 1 by default).