<class T, class Compare = less<T>, class Allocator = allocator>
T
is the type of the values stored in the set - a single type
Compare
determines sorting order and equality
Compare(v1, v2)
, Compare(v2, v1)
, or
v2 == v1
must be true for any v1
and v2
Compare(v1, v2)
or Compare(v2,
v1)
, are true, than v2 == v1
must be true
<
is acceptable, <=
is not
set<T> s(const Compare & c = Compare())
set<int,less<int> > intset(greater<int>)
are
legal but not proper
set<T> set1(set2);
set<T> tset(start, end);
- also the
optional compare parameter
multiset
instead of set
reserve()
and capacity()
member functions
d.push_back(v)
, d.pop_back()
, d.push_front(v)
, and
d.pop_front()
member functions
insert()
and erase()
s.insert(v)
- no iterator
v
into s
if s
doesn't already contain v
pair<iterator,bool>
utility
include file - usually included by other
include files
templatestruct pair { T1 first; T2 second; pair(); pair(const T1 & a, const T2 & b); template pair(const pair & p); }
p.second
is true if v
was inserted into s
; false
otherwise
p.first
is an iterator to v
in s
always
ms.insert(v)
v
into ms
insert(i, v)
i
is a hint as to where v
might go - can be
useful in speeding up lots of insertions
v
- actual insertion not indicated for
sets
insert(start, end)
- no iterator
start,end
into the set or multiset
erase(i)
- delete the value referenced by the
iterator i
; in multisets, only one value is deleted, not all of
them; returns nothing
s.erase(v)
- delete the value v
from the set s
;
returns 1
if v
was a member of s
and 0
otherwise
ms.erase(v)
- delete all values v
from the
multiset ms
; returns the number of values deleted
erase(s, e)
- delete the values denoted by the
iterator range s,e
; returns nothing
size()
, max_size()
, and empty()
member functions
count(v)
member function - return the number of
times the value v
appears
[]
or at()
- iterators only
v
; return end()
for no such value
v
; return end()
for no such value
(lower_bound(v),
upper_bound(v))
find(v)
- return an iterator to v
or
end()
count(v)
This page last modified on 1 August 2000.