// ========================================================================== // $Id: stl_adaptor.cpp,v 1.3 2011/09/10 01:08:19 jlang Exp $ // CSI2372 example Code for lecture 11 // ========================================================================== // (C)opyright: // // Jochen Lang // SITE, University of Ottawa // 800 King Edward Ave. // Ottawa, On., K1N 6N5 // Canada. // http://www.site.uottawa.ca // // Creator: jlang (Jochen Lang) // Email: jlang@site.uottawa.ca // ========================================================================== // $Log: stl_adaptor.cpp,v $ // Revision 1.3 2011/09/10 01:08:19 jlang // Updates F10 // // Revision 1.2 2009/11/16 02:58:27 jlang // Minor touch-up // // Revision 1.1 2006/11/08 01:41:34 jlang // added stl code for lecture 11 // // // ========================================================================== #include #include #include #include using std::cout; using std::endl; using std::vector; using std::priority_queue; using std::stack; int main( int argc, char* argv[] ) { // Vector with 24 ... 0 vector iVec; for ( int i=0; i<25; ++i ) { iVec.push_back(24-i); } // Copy the vector as a basis for priority_queue - default priority_queue pq( iVec.begin(), iVec.end()); cout << "Top and pop all elements from priority queue: " << endl; // loop over the elements and print while ( !pq.empty() ) { cout << pq.top() << ' '; pq.pop(); } cout << endl; cout << "Top and Pop all elements from stack: " << endl; // Copy the vector as a basis for stack - default is deque // here with non-default vector stack > iStack( iVec ); while ( !iStack.empty() ) { cout << iStack.top() << ' '; iStack.pop(); } cout << endl; return 0; }