]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/heap/test/mutable_heap_test.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / heap / test / mutable_heap_test.cpp
1 /*=============================================================================
2 Copyright (c) 2010 Tim Blechmann
3
4 Use, modification and distribution is subject to the Boost Software
5 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8
9 #define BOOST_TEST_MAIN
10 #include <boost/test/unit_test.hpp>
11
12 #include <boost/heap/d_ary_heap.hpp>
13 #include <boost/heap/fibonacci_heap.hpp>
14 #include <boost/heap/pairing_heap.hpp>
15 #include <boost/heap/binomial_heap.hpp>
16 #include <boost/heap/skew_heap.hpp>
17
18 using namespace boost::heap;
19
20 #if BOOST_WORKAROUND(BOOST_MSVC, != 1800)
21 typedef fibonacci_heap<struct fwd_declared_struct_1>::handle_type handle_type_1;
22 typedef d_ary_heap<struct fwd_declared_struct_2, arity<4>, mutable_<true> >::handle_type handle_type_2;
23 typedef pairing_heap<struct fwd_declared_struct_3>::handle_type handle_type_3;
24 typedef binomial_heap<struct fwd_declared_struct_4>::handle_type handle_type_4;
25 typedef skew_heap<struct fwd_declared_struct_5, mutable_<true> >::handle_type handle_type_5;
26 #endif
27
28 template <typename HeapType>
29 void run_handle_as_member_test(void)
30 {
31 typedef typename HeapType::value_type value_type;
32 HeapType heap;
33 value_type f(2);
34 typename value_type::handle_type handle = heap.push(f);
35 value_type & fInHeap = *handle;
36 fInHeap.handle = handle;
37 }
38
39
40 struct fibonacci_heap_data
41 {
42 typedef fibonacci_heap<fibonacci_heap_data>::handle_type handle_type;
43
44 handle_type handle;
45 int i;
46
47 fibonacci_heap_data(int i):i(i) {}
48
49 bool operator<(fibonacci_heap_data const & rhs) const
50 {
51 return i < rhs.i;
52 }
53 };
54
55 BOOST_AUTO_TEST_CASE( fibonacci_heap_handle_as_member )
56 {
57 run_handle_as_member_test<fibonacci_heap<fibonacci_heap_data> >();
58 }
59
60 struct d_heap_data
61 {
62 typedef d_ary_heap<d_heap_data, arity<4>, mutable_<true> >::handle_type handle_type;
63
64 handle_type handle;
65 int i;
66
67 d_heap_data(int i):i(i) {}
68
69 bool operator<(d_heap_data const & rhs) const
70 {
71 return i < rhs.i;
72 }
73 };
74
75
76 BOOST_AUTO_TEST_CASE( d_heap_handle_as_member )
77 {
78 run_handle_as_member_test<d_ary_heap<d_heap_data, arity<4>, mutable_<true> > >();
79 }
80
81 struct pairing_heap_data
82 {
83 typedef pairing_heap<pairing_heap_data>::handle_type handle_type;
84
85 handle_type handle;
86 int i;
87
88 pairing_heap_data(int i):i(i) {}
89
90 bool operator<(pairing_heap_data const & rhs) const
91 {
92 return i < rhs.i;
93 }
94 };
95
96
97 BOOST_AUTO_TEST_CASE( pairing_heap_handle_as_member )
98 {
99 run_handle_as_member_test<pairing_heap<pairing_heap_data> >();
100 }
101
102
103 struct binomial_heap_data
104 {
105 typedef binomial_heap<binomial_heap_data>::handle_type handle_type;
106
107 handle_type handle;
108 int i;
109
110 binomial_heap_data(int i):i(i) {}
111
112 bool operator<(binomial_heap_data const & rhs) const
113 {
114 return i < rhs.i;
115 }
116 };
117
118
119 BOOST_AUTO_TEST_CASE( binomial_heap_handle_as_member )
120 {
121 run_handle_as_member_test<binomial_heap<binomial_heap_data> >();
122 }
123
124 struct skew_heap_data
125 {
126 typedef skew_heap<skew_heap_data, mutable_<true> >::handle_type handle_type;
127
128 handle_type handle;
129 int i;
130
131 skew_heap_data(int i):i(i) {}
132
133 bool operator<(skew_heap_data const & rhs) const
134 {
135 return i < rhs.i;
136 }
137 };
138
139
140 BOOST_AUTO_TEST_CASE( skew_heap_handle_as_member )
141 {
142 run_handle_as_member_test<skew_heap<skew_heap_data, mutable_<true> > >();
143 }