The Standard Template Library (STL) is a library for C++ that makes extensive use of templates to implement the standard container classes and much more. Each of the container classes provides an interface to iterate over all the objects in the container, e.g.
// MAP is an associate array from location(lat,long) onto the name. typedef map<location,string,locationlt> MAP; void print_map_names(MAP& m) { // print out all the names in the map for(MAP::iterator i = m.begin(); i != m.end(); ++i) { cout << (*i).second << "\n"; } }
‘Qstl.h’ provides the same facilities as ‘Q.h’ but uses the standard STL iterator protocol shown above. The names in ‘Qstl.h’ are generated by appending a ‘O’ (O not zero!) to the names in ‘Q.h’. In particular:
For all values in the container class the predicate must be true. The predicate refers to individual values using name. See the STL documentation for more details. Another way of putting this is forall name in container the predicate must be true.
map<int,char *,ltint> m; // all keys (or indexes) into m are positive I(AO(i, m, (*i).first >= 0));
There exists one or more values in the container class for which the predicate is true.
map<int,char,ltint> m; // one or more characters in m are '$' I(EO(i, m, (*i).second == '$'));
There exists one value in the container for which the predicate is true.
map<int,char,ltint> m; // one characters in m is a '$' I(E1O(i, m, (*i).second == '$'));
Returns the number of times the predicate was true for all values in the container.
map<int,char,ltint> m; int nalpha; // count the number of alphabetic chars in the map nalpha = CO(i, m, isalpha((*i).second));