-
Notifications
You must be signed in to change notification settings - Fork 216
/
Copy pathbucket_sorter_2u.cpp
53 lines (38 loc) · 1.01 KB
/
bucket_sorter_2u.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <boost/property_map/property_map.hpp>
#include <boost/pending/bucket_sorter.hpp>
#include <boost/test/minimal.hpp>
#include <vector>
int test_main(int, char**)
{
typedef boost::iterator_property_map<unsigned*,
boost::identity_property_map, unsigned, unsigned&> map_type;
typedef boost::bucket_sorter<unsigned, unsigned,
map_type, boost::identity_property_map > container_type;
std::vector<unsigned> V(10);
map_type M(&V[0], boost::identity_property_map());
container_type B(10, 10, M);
for(unsigned i=4; i<10; ++i){
V[i]=9;
B.push(i);
}
BOOST_CHECK(B[9].top()==9);
// intended use?
V[6]=3;
B.update(6);
while(!B[9].empty()){
B[9].pop();
}
V[0]=0;
B.push(0);
V[2]=1; /// ***
B.push(2);
BOOST_CHECK(B[1].top()==2);
V[0]=1;
// intended use? kills 2 in bucket #1 ***
B.update(0);
container_type::value_type const & top1 = B[1].top();
B[1].pop();
container_type::value_type const &top2 = B[1].top();
BOOST_CHECK(top1 == 2 || top2 == 2);
return 0;
}