previous | start | next

## Other Standard Containers

- The standard library contains several other useful containers.
- The `set` always keeps its elements in order, no matter in which order you insert them.

  >     set<string> s;

  >     s.insert("Tom");
  >     s.insert("Dick");
  >     s.insert("Harry");

  >     set<string>::iterator p;
  >     for (p = s.begin(); p!= s.end(); p++)
  >        cout << *p << "\n";

- The above code displays the strings in sorted order: Dick, Harry, Tom.
- The `set` data structure keeps the values in a special tree shaped structure; each time an element is inserted, the tree is reorganized.

previous | start | next