NO FRAMES

Class IloIterator<E>

Definition file: ilconcert/iloiterator.h
A template to create iterators for a class of extractable objects.

This template creates iterators for a given class of extractable objects (denoted by E in the template) within an instance of IloEnv.

By default, an iterator created in this way will traverse instances of E and of its subclasses. You can prevent the iterator from traversing instances of subclasses of E (that is, you can limit its effect) by setting the argument withSubClasses to IloFalse in the constructor of the iterator.

While an iterator created in this way is working, you must not create nor destroy any extractable objects in the instance of IloEnv where it is working. In other words, an iterator created in this way works only in a stable environment.

An iterator created with this template differs from an instance of IloModel::Iterator. An instance of IloModel::Iterator works only on extractable objects (instances of IloExtractable or its subclasses) that have explicitly been added to a model (an instance of IloModel). In contrast, an iterator created with this template will work on all extractable objects within a given environment, whether or not they have been explicitly added to a model.

See Also:

Constructor Summary
public IloIterator(const IloEnv env, IloBool withSubClasses=IloTrue)
Method Summary
public IloBoolok()
public voidoperator++()
Constructor Detail

IloIterator

public IloIterator(const IloEnv env, IloBool withSubClasses=IloTrue)

This template constructor creates an iterator for instances of the class E. When the argument withSubClasses is IloTrue (its default value), the iterator will also work on instances of the subclasses of E. When withSubClasses is IloFalse, the iterator works only on instances of E.

Example

Here is an example of an iterator created by this template for the class IloNumVar.

   typedef IloIterator<IloNumVar> IloNumVarIterator;

   void displayAllVars(IloEnv env) {
     for (IloNumVarIterator it(env); it.ok(); ++it) {
       IloNumVar ext = *it;
       cout << ext;
     }
   }
 

Method Detail

ok

public IloBool ok()

This member function returns IloTrue if there is a current element and the iterator points to it. Otherwise, it returns IloFalse.


operator++

public void operator++()

This operator advances the iterator to point to the next value in the iteration.