[Univ of Cambridge] [Dept of Engineering]
next up previous contents
Next: map Up: The Standard Library Previous: Queues

list

Lists are useful when items are likely to be inserted/deleted from the middle of long sequences. This example creates a vector then copies it into a list, reversing as it does so.
[fontsize=\small,frame=single,formatcom=\color{progcolor}]
     #include <vector>
     #include <list>
     #include <algorithm>
     #include <iostream>
     using namespace std;

     int main()
     {
     vector<int> V;
     V.push_back(0);
     V.push_back(1);
     V.push_back(2);

     list<int> L(V.size());
     reverse_copy(V.begin(), V.end(), L.begin());
     exit(0);
     }



Tim Love
2001-07-05