Simulations often need to iterate over all objects in a certain class, for example over all agents or all streets.
In C++, iterators are explicitely provided for many data structures of the STL. Code typically looks like the following:
{} for (Links::iterator ll = links.begin(); ll != links.end(); ll++) { Link* link = ll->second ; }The ->second is necessary if Links is, as discussed in Sec. 4.10, a map<int,Link>. Then ll returns the ``pair'' (int,Link*), while ->second just returns the second item. - This will be filled with more meaning in later examples.