|
2904
|
1 // This file is part of the uSTL library, an STL implementation. |
|
|
2 // |
|
3152
|
3 // Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net> |
|
2904
|
4 // This file is free software, distributed under the MIT License. |
|
|
5 |
|
|
6 #include "stdtest.h" |
|
|
7 |
|
|
8 void PrintVector (const int* first, const int* last) |
|
|
9 { |
|
|
10 cout << "{"; |
|
|
11 while (first < last) |
|
|
12 cout << ' ' << *first++; |
|
|
13 cout << " }" << endl; |
|
|
14 } |
|
|
15 |
|
|
16 void TestSetAndMultiset (void) |
|
|
17 { |
|
|
18 const int vv[] = { 1, 8, 9, 2, 3, 1, 1, 4, 6, 1, 3, 4 }; |
|
|
19 set<int> v (VectorRange (vv)); |
|
|
20 multiset<int> mv (VectorRange (vv)); |
|
|
21 cout << "set:\t\t"; |
|
|
22 PrintVector (v.begin(), v.end()); |
|
|
23 cout << "erase(3):\t"; |
|
|
24 v.erase (3); |
|
|
25 PrintVector (v.begin(), v.end()); |
|
|
26 cout << "multiset:\t"; |
|
|
27 PrintVector (mv.begin(), mv.end()); |
|
|
28 cout << "count(1) = " << mv.count(1) << endl; |
|
|
29 cout << "find(4) = " << lower_bound (mv, 4) - mv.begin() << endl; |
|
|
30 cout << "find(5) = " << binary_search (mv, 5) << endl; |
|
|
31 cout << "erase(3):\t"; |
|
|
32 mv.erase (3); |
|
|
33 PrintVector (mv.begin(), mv.end()); |
|
|
34 } |
|
|
35 |
|
|
36 StdBvtMain (TestSetAndMultiset) |