#include <string>
#include <set>
#include <iostream>

using namespace std;

int main()
{
  set<string> my_set_of_strings;

  // Put some items into the set
  my_set_of_strings.insert("George");
  my_set_of_strings.insert("Cathy");
  my_set_of_strings.insert("Michelle");
  // Nothing happens since it's already in the set
  my_set_of_strings.insert("Michelle");

  // Create an iterator, which is a special kind of pointer. This
  // could also be a const_iterator since we don't plan on
  // changing the thing it points to.
  set<string>::iterator the_found_item;

  // Look for an item in the set
  the_found_item = my_set_of_strings.find("missing");

  if (the_found_item == my_set_of_strings.end())
    cout << "\"missing\" isn't in the set." << endl;

  // Now find something that is in the set
  the_found_item = my_set_of_strings.find("Cathy");

  // Double-check it
  if (the_found_item == my_set_of_strings.end())
    cout << "Hm... STL didn't find the item?!" << endl;
  else if (*the_found_item != "Cathy")
    cout << "Hm... STL didn't find the right item?!" << endl;
  else
    cout << "I found the item: " << *the_found_item << endl;

  // Now let's iterate over the items in the set
  cout << "The set is:" << endl;

  // We'll use a constant iterator this time because we don't intend on
  // modifying the items it points to. (We could have done this before too.)
  set<string>::const_iterator an_item;
  for (an_item = my_set_of_strings.begin();
       an_item != my_set_of_strings.end();
       an_item++)
    cout << *an_item << endl;

  return 0;
}

