Here's an example set<int> setint; // you create a set setint.insert(4); // you add 4 to the set in o(log n) where n is the number of elements of the set setint.insert(5); // you add 5 to the set setint.insert(4); // nothing happens because 4 is already in the set if(setint.find(4)) cout << "4 is in the set" << endl; // you check in o(log n) if 4 is in the set, and because it is in the set you print "4 is in the set". setint.clear(); // you clear the set in o(1).
You can also work with set::iterator but it's a bit more complex and you almost never need it. -- You received this message because you are subscribed to the Google Groups "google-codejam" group. To post to this group, send email to google-code@googlegroups.com. To unsubscribe from this group, send email to google-code+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.