diff options
Diffstat (limited to 'boost/heap/binomial_heap.hpp')
-rw-r--r-- | boost/heap/binomial_heap.hpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/boost/heap/binomial_heap.hpp b/boost/heap/binomial_heap.hpp index 8ebc7d056f..7e0760f4a2 100644 --- a/boost/heap/binomial_heap.hpp +++ b/boost/heap/binomial_heap.hpp @@ -10,6 +10,7 @@ #define BOOST_HEAP_BINOMIAL_HEAP_HPP #include <algorithm> +#include <utility> #include <vector> #include <boost/assert.hpp> @@ -19,6 +20,10 @@ #include <boost/heap/detail/stable_heap.hpp> #include <boost/heap/detail/tree_iterator.hpp> +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + #ifndef BOOST_DOXYGEN_INVOKED #ifdef BOOST_HEAP_SANITYCHECKS #define BOOST_HEAP_ASSERT BOOST_ASSERT @@ -61,7 +66,7 @@ struct make_binomial_heap_base base_type(arg) {} -#ifdef BOOST_HAS_RVALUE_REFS +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES type(type const & rhs): base_type(rhs), allocator_type(rhs) {} @@ -126,6 +131,7 @@ class binomial_heap: typedef typename super_t::internal_type internal_type; typedef typename super_t::size_holder_type size_holder; + typedef typename super_t::stability_counter_type stability_counter_type; typedef typename base_maker::allocator_argument allocator_argument; template <typename Heap1, typename Heap2> @@ -245,7 +251,7 @@ public: return *this; } -#ifdef BOOST_HAS_RVALUE_REFS +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES /// \copydoc boost::heap::priority_queue::priority_queue(priority_queue &&) binomial_heap(binomial_heap && rhs): super_t(std::move(rhs)), top_element(rhs.top_element) @@ -353,7 +359,7 @@ public: return handle_type(n); } -#if defined(BOOST_HAS_RVALUE_REFS) && !defined(BOOST_NO_VARIADIC_TEMPLATES) +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) /** * \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place. Returns handle to element. * @@ -394,11 +400,15 @@ public: if (element->child_count()) { size_type sz = (1 << element->child_count()) - 1; + binomial_heap children(value_comp(), element->children, sz); - if (trees.empty()) + if (trees.empty()) { + stability_counter_type stability_count = super_t::get_stability_count(); swap(children); - else + super_t::set_stability_count(stability_count); + } else merge_and_clear_nodes(children); + } if (trees.empty()) @@ -528,7 +538,7 @@ public: rhs.set_size(0); rhs.top_element = NULL; - super_t::set_stability_count(std::max(super_t::get_stability_count(), + super_t::set_stability_count((std::max)(super_t::get_stability_count(), rhs.get_stability_count())); rhs.set_stability_count(0); } |