1 /*=============================================================================
2 Copyright (c) 2010 Tim Blechmann
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 =============================================================================*/
9 #define BOOST_TEST_MAIN
10 #include <boost/test/unit_test.hpp>
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>
18 using namespace boost::heap
;
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
;
28 template <typename HeapType
>
29 void run_handle_as_member_test(void)
31 typedef typename
HeapType::value_type value_type
;
34 typename
value_type::handle_type handle
= heap
.push(f
);
35 value_type
& fInHeap
= *handle
;
36 fInHeap
.handle
= handle
;
40 struct fibonacci_heap_data
42 typedef fibonacci_heap
<fibonacci_heap_data
>::handle_type handle_type
;
47 fibonacci_heap_data(int i
):i(i
) {}
49 bool operator<(fibonacci_heap_data
const & rhs
) const
55 BOOST_AUTO_TEST_CASE( fibonacci_heap_handle_as_member
)
57 run_handle_as_member_test
<fibonacci_heap
<fibonacci_heap_data
> >();
62 typedef d_ary_heap
<d_heap_data
, arity
<4>, mutable_
<true> >::handle_type handle_type
;
67 d_heap_data(int i
):i(i
) {}
69 bool operator<(d_heap_data
const & rhs
) const
76 BOOST_AUTO_TEST_CASE( d_heap_handle_as_member
)
78 run_handle_as_member_test
<d_ary_heap
<d_heap_data
, arity
<4>, mutable_
<true> > >();
81 struct pairing_heap_data
83 typedef pairing_heap
<pairing_heap_data
>::handle_type handle_type
;
88 pairing_heap_data(int i
):i(i
) {}
90 bool operator<(pairing_heap_data
const & rhs
) const
97 BOOST_AUTO_TEST_CASE( pairing_heap_handle_as_member
)
99 run_handle_as_member_test
<pairing_heap
<pairing_heap_data
> >();
103 struct binomial_heap_data
105 typedef binomial_heap
<binomial_heap_data
>::handle_type handle_type
;
110 binomial_heap_data(int i
):i(i
) {}
112 bool operator<(binomial_heap_data
const & rhs
) const
119 BOOST_AUTO_TEST_CASE( binomial_heap_handle_as_member
)
121 run_handle_as_member_test
<binomial_heap
<binomial_heap_data
> >();
124 struct skew_heap_data
126 typedef skew_heap
<skew_heap_data
, mutable_
<true> >::handle_type handle_type
;
131 skew_heap_data(int i
):i(i
) {}
133 bool operator<(skew_heap_data
const & rhs
) const
140 BOOST_AUTO_TEST_CASE( skew_heap_handle_as_member
)
142 run_handle_as_member_test
<skew_heap
<skew_heap_data
, mutable_
<true> > >();