• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
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 
27 template <typename HeapType>
run_handle_as_member_test(void)28 void run_handle_as_member_test(void)
29 {
30     typedef typename HeapType::value_type value_type;
31     HeapType heap;
32     value_type f(2);
33     typename value_type::handle_type handle = heap.push(f);
34     value_type & fInHeap = *handle;
35     fInHeap.handle = handle;
36 }
37 
38 
39 struct fibonacci_heap_data
40 {
41     typedef fibonacci_heap<fibonacci_heap_data>::handle_type handle_type;
42 
43     handle_type handle;
44     int i;
45 
fibonacci_heap_datafibonacci_heap_data46     fibonacci_heap_data(int i):i(i) {}
47 
operator <fibonacci_heap_data48     bool operator<(fibonacci_heap_data const & rhs) const
49     {
50         return i < rhs.i;
51     }
52 };
53 
BOOST_AUTO_TEST_CASE(fibonacci_heap_handle_as_member)54 BOOST_AUTO_TEST_CASE( fibonacci_heap_handle_as_member )
55 {
56     run_handle_as_member_test<fibonacci_heap<fibonacci_heap_data> >();
57 }
58 
59 struct d_heap_data
60 {
61     typedef d_ary_heap<d_heap_data, arity<4>, mutable_<true> >::handle_type handle_type;
62 
63     handle_type handle;
64     int i;
65 
d_heap_datad_heap_data66     d_heap_data(int i):i(i) {}
67 
operator <d_heap_data68     bool operator<(d_heap_data const & rhs) const
69     {
70         return i < rhs.i;
71     }
72 };
73 
74 
BOOST_AUTO_TEST_CASE(d_heap_handle_as_member)75 BOOST_AUTO_TEST_CASE( d_heap_handle_as_member )
76 {
77     run_handle_as_member_test<d_ary_heap<d_heap_data, arity<4>, mutable_<true> > >();
78 }
79 
80 struct pairing_heap_data
81 {
82     typedef pairing_heap<pairing_heap_data>::handle_type handle_type;
83 
84     handle_type handle;
85     int i;
86 
pairing_heap_datapairing_heap_data87     pairing_heap_data(int i):i(i) {}
88 
operator <pairing_heap_data89     bool operator<(pairing_heap_data const & rhs) const
90     {
91         return i < rhs.i;
92     }
93 };
94 
95 
BOOST_AUTO_TEST_CASE(pairing_heap_handle_as_member)96 BOOST_AUTO_TEST_CASE( pairing_heap_handle_as_member )
97 {
98     run_handle_as_member_test<pairing_heap<pairing_heap_data> >();
99 }
100 
101 
102 struct binomial_heap_data
103 {
104     typedef binomial_heap<binomial_heap_data>::handle_type handle_type;
105 
106     handle_type handle;
107     int i;
108 
binomial_heap_databinomial_heap_data109     binomial_heap_data(int i):i(i) {}
110 
operator <binomial_heap_data111     bool operator<(binomial_heap_data const & rhs) const
112     {
113             return i < rhs.i;
114     }
115 };
116 
117 
BOOST_AUTO_TEST_CASE(binomial_heap_handle_as_member)118 BOOST_AUTO_TEST_CASE( binomial_heap_handle_as_member )
119 {
120     run_handle_as_member_test<binomial_heap<binomial_heap_data> >();
121 }
122 
123 struct skew_heap_data
124 {
125     typedef skew_heap<skew_heap_data, mutable_<true> >::handle_type handle_type;
126 
127     handle_type handle;
128     int i;
129 
skew_heap_dataskew_heap_data130     skew_heap_data(int i):i(i) {}
131 
operator <skew_heap_data132     bool operator<(skew_heap_data const & rhs) const
133     {
134         return i < rhs.i;
135     }
136 };
137 
138 
BOOST_AUTO_TEST_CASE(skew_heap_handle_as_member)139 BOOST_AUTO_TEST_CASE( skew_heap_handle_as_member )
140 {
141     run_handle_as_member_test<skew_heap<skew_heap_data, mutable_<true> > >();
142 }
143