Overview | Group | Tree | Graph | Index | Concepts |
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. As long as you do not modify any of the handles, each
of them will still point to the same implementation object.
However, if you modify an array, then Concert Technology considers whether the array is the sole handle pointing to its implementation object or whether the array is one of many handles pointing to the same implementation object.
If the array is the sole handle pointing to its implementation object, Concert Technology modifies the array.
If the array is one handle among many pointing to the same implementation object, then Concert Technology first creates a copy of the implementation object corresponding to the array (the handle you are modifying) and then modifies the copy. Consequently, the other handles continue to point to the original, unmodified implementation object.
In other words, when Concert Technology copies an array, it uses a lazy copy mechanism.
Input and Output of Multidimensional Arrays
The template operator >>
makes it possible to read
numerical 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 numerical 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 numerical values, as the input operator
is.)
These two operators make it possible to read and write multidimensional arrays of numerical 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:
IloAnyArray, IloAnySetVarArray, IloAnyVarArray, IloBoolArray, IloBoolVarArray, IloConstraintArray, IloExprArray, IloExtractableArray, IloFloatArray, IloFloatVarArray, IloIntArray, IloIntVarArray, IloNumColumnArray, IloNumVarArray, IloRangeArray, IloSemiContVarArray, IloSolutionArray, IloSOS1Array, IloSOS2Array
Constructor Summary | |
---|---|
public | IloArray(IloEnv, IloInt) |
Method Summary | |
---|---|
public void | add(IloArray< X >) |
public void | add(IloInt, X) |
public void | add(X) |
public void | clear() |
public void | end() |
public IloEnv | getEnv() |
public IloInt | getSize() |
public X & | operator[](IloInt) |
public const X & | operator[](IloInt) |
public void | remove(IloInt, IloInt) |
Constructor Detail |
---|
This constructor creates an array of max
elements, all of
which are empty handles.
Method Detail |
---|
This member function appends the elements in ax
to the
invoking array.
This member function appends x
to the invoking array
multiple times. The parameter more
indicates how many times.
This member function appends x
to the invoking array.
This member function removes all the elements from the invoking array. In other words, it produces an empty array.
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.
This member function returns the environment where the invoking array was created. The elements of the invoking array belong to the same environment.
This member function returns an integer indicating the size of the invoking array. An empty array has size 0 (zero).
This operator returns a reference to the object located in the invoking array at the position
indicated by the index i
.
This operator returns a reference to the object located in the invoking array at the position
indicated by the index i
. Concert Technology uses the const
operator
IloArray operator[] (IloInt i) const;
on
const
arrays.
This member function removes elements from the invoking array. It begins
removing elements at the index indicated by first
, and it
removes nb
elements (nb = 1
by default).