Standard C++ Library Class Reference
Returns an iterator that points to the first element that is greater than or equal to x. If there is no
such element, the iterator points to the past-the-end value.
value_compare
value_comp () const;
Returns the set's comparison object. This is identical to the function key_comp().
Non-member Operators
template <class Key, class Compare, class Allocator>
bool operator== (const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
Equality operator. Returns true if x is the same as y.
template <class Key, class Compare, class Allocator>
bool operator< (const set <Key, Compare, Allocator>& x,
const set <Key, Compare, Allocator>& y);
Returns true if the elements contained in x are lexicographically less than the elements contained
in y.
template <class Key, class Compare, class Allocator>
void swap (set <Key, Compare, Allocator>& a,
set <Key, Compare, Allocator>& b);
Efficiently swaps the contents of a and b.
Example
//
// set.cpp
//
#include <set>
#include <iostream.h>
typedef set<double, less<double>, allocator> set_type;
ostream& operator<<(ostream& out, const set_type& s)
{
copy(s.begin(), s.end(),
ostream_iterator<set_type::value_type>(cout," "));
return out;
}
int main(void)
{
// create a set of doubles
set_type sd;
int i;
for(i = 0; i < 10; ++i) {
// insert values
sd.insert(i);
}