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:
map<int,char *,ltint> m; // all keys (or indexes) into m are positive I(AO(i, m, (*i).first >= 0));
map<int,char,ltint> m; // one or more characters in m are '$' I(EO(i, m, (*i).second == '$'));
map<int,char,ltint> m; // one characters in m is a '$' I(E1O(i, m, (*i).second == '$'));
map<int,char,ltint> m; int nalpha; // count the number of alphabetic chars in the map nalpha = CO(i, m, isalpha((*i).second));
map<int,float,ltint> m; float sum; // sum all the values in m sum = SO(i, m, (*i).second);
map<int,float,ltint> m; float product; // multiply all the values in m product = PO(i, m, (*i).second);
Go to the first, previous, next, last section, table of contents.