stl2 - Sets & Multisets • provide fast retrieval of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
provide fast retrieval of elements (keys) elements must be unique in sets; multisets allow duplicate elements elements are ordered by ‘less-than” by default both classes have no mutable iterator type: don’t change one instead provide special search functions: find(elem) returns the position of the first element equivalent to elem or end() lower bound(elem) returns the position of the first ele- ment not less than elem upper bound(elem) returns the position of the first ele- ment greater than elem equal range(elem) returns a pair * whose first is lower bound(elem) * whose second is upper bound(elem) (it basically returns a range of elements equivalent to elem ) if equal range(elem).first==equal range(elem).second , elem is not found count(elem) returns the number of elements equivalent to elem aw/07 10
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
#include <iostream> #include <set> using std::multiset; using std::cout; using std::endl; int main() { multiset<int> s; s.insert(2); s.insert(1); s.insert(2); s.insert(3); s.insert(5); s.insert(2); s.insert(5); cout << s.count(2) << endl;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/05/2009 for the course COMM 1100 taught by Professor N during the Spring '09 term at BC.

Page1 / 7

stl2 - Sets & Multisets • provide fast retrieval of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online