// File: read2.C // // Sample program using STL deque templates // Read the "spell" dictionary into a deque #include #include #include #include // another STL "sequence container" #include // STL string template, like BString main() { deque D ; string str ; int i ; // Get strings from stdin // while (cin >> str) { D.push_back(str) ; // append new string } D.push_front("0000") ; // deque allows efficient insertion at front cout << "# of strings read = " << D.size() << endl ; // For loop syntax for iteration // for (i = 0 ; i < D.size() ; i++) { cout << D[i] << endl ; } // Using STL iterators // cout << "\nSTL iterators" << endl ; deque::iterator it ; for (it = D.begin() ; it != D.end() ; it++) { cout << *it << endl ; } }