Ch 16. Case Study Containers
Introduction
PPT Slide
Shortest Path Graph Problem
Figure 15.1 A Weighted Graph
typedef map <const char *, cityInfo, charCompare> graph;
Shortest Path Algorithm
Developing the Data Structures
Developing Data Structures
int main() {graph cityMap;... // initialization of the mapgraph::iterator start = cityMap.begin();graph::iterator stop = cityMap.end();for ( ; start != stop; ++start) { const char * city = (*start).first; cout << "\nStarting from " << city << "\n"; cityInfo costs; dijkstra(cityMap, city, costs); cityInfo::iterator cstart = costs.begin(); cityInfo::iterator cstop = costs.end(); for ( ; cstart != cstop; ++cstart) { cout << "to " << (*cstart).first << " costs " << (*cstart).second << '\n'; }}return 0;
A Concordance
void concordance::readText (istream & in)
void concordance::printConcordance (ostream & out)
An iterator loop is used to cycle over the elements being maintained by the word list.
Email: budd@cs.orst.edu
Home Page: http://www.cs.orst.edu/~budd