STL-set用法
// 1.set::begin/end
#include <iostream>
#include <set>
using namespace std;
int main ()
{
}
Output:
myset contains: 13 23 42 65 75
// 2.set::empty
#include <iostream>
#include <set>
using namespace std;
int main ()
{
}
Output:myset contains: 10 20 30
// 3.set::size
#include <iostream>
#include <set>
using namespace std;
int main ()
{
}
Output:0. size: 0
1. size: 10
2. size: 11
3. size: 10
// 4.set::find
#include <iostream>
#include <set>
using namespace std;
int main ()
{
}
Output:
myset contains: 10 30 50
// 5.set::count
#include <iostream>
#include <set>
using namespace std;
int main ()
{
}
Output:
0 is not an element of myset.
1 is not an element of myset.
2 is not an element of myset.
3 is an element of myset.
4 is not an element of myset.
5 is not an element of myset.
6 is an element of myset.
7 is not an element of myset.
8 is not an element of myset.
9 is an element of myset.
// 6.set::lower_bound/upper_bound
#include <iostream>
#include <set>
using namespace std;
int main ()
{
}
Notice that lower_bound(30) returns an iterator to 30, whereas upper_bound(60) returns an iterator to 70.
myset contains: 10 20 70 80 90
// 7.set::equal_elements
#include <iostream>
#include <set>
using namespace std;
int main ()
{
}
lower bound points to: 30
upper bound points to: 40