Overview | Group | Tree | Graph | Index | Concepts |
Arrays in an Environment |
Extensible Arrays |
Arrays as Handles |
Copying Arrays |
Programming Hint: Using Arrays Efficiently |
For most basic classes (such as IloNumVar
or IloConstraint
)
in Concert Technology, there is also a corresponding class of arrays where the elements
of the array are instances of that basic class. For example, elements of an instance of
IloConstraintArray
are instances of the class
IloConstraint
.
Concert Technology arrays are extensible. That is, you can add elements to the array dynamically. You add
elements by means of the add
member function of the array class.
You can also remove elements from an array by means of its remove
member function.
References to an array change whenever an element is added to or removed from the array.
Like other Concert Technology objects, arrays are implemented by means of two classes: a handle class corresponding to an implementation class. An object of the handle class contains a data member (the handle pointer) that points to an object (its implementation object) of the corresponding implementation class. As a Concert Technology user, you will be working primarily with handles.
Many handles may point to the same implementation object. This principle holds true for arrays as well as other handle classes in Concert Technology. When you want to create more than one handle for the same implementation object, you should use either the copy constructor or the assignment operator of the array class. For example,
IloNumArray array(env); // creates a handle pointing to new impl IloNumArray array1(array); // creates a handle pointing to same impl IloNumArray array2; // creates an empty handle array2 = array; // sets impl of handle array2 to impl of array
If your application only reads an array (that is, if your function does not modify an element of the
array), then we recommend that you pass the array to your function as a const
parameter.
This practice forces Concert Technology to access the const
conversion of the index operator
(that is, operator[]
), which is faster.