FRAMES NO FRAMES

Arrays
NEXT
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.

Arrays in an Environment

Every array must belong to an environment (an instance of IloEnv). In other words, when you create a Concert Technology array, you pass an instance of IloEnv as a parameter to the constructor. All the elements of a given array must belong to the same environment.

Extensible Arrays

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.

Arrays as Handles

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.

Copying Arrays

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
Programming Hint: Using Arrays Efficiently

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.

NEXT