Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83541 - in branches/release: boost/heap boost/heap/detail libs/heap libs/heap/test
From: tim_at_[hidden]
Date: 2013-03-24 09:34:20


Author: timblechmann
Date: 2013-03-24 09:34:19 EDT (Sun, 24 Mar 2013)
New Revision: 83541
URL: http://svn.boost.org/trac/boost/changeset/83541

Log:
heap: merge changes from trunk

Properties modified:
   branches/release/boost/heap/ (props changed)
   branches/release/libs/heap/ (props changed)
Text files modified:
   branches/release/boost/heap/detail/mutable_heap.hpp | 11 +++++++++
   branches/release/boost/heap/detail/stable_heap.hpp | 41 +++++++++++++++++++++++++++++++++++++--
   branches/release/boost/heap/heap_concepts.hpp | 9 +++++++
   branches/release/boost/heap/pairing_heap.hpp | 2
   branches/release/libs/heap/test/binomial_heap_test.cpp | 2 +
   branches/release/libs/heap/test/common_heap_tests.hpp | 36 +++++++++++++++++++++++++++++++++++
   branches/release/libs/heap/test/d_ary_heap_test.cpp | 6 +++++
   branches/release/libs/heap/test/fibonacci_heap_test.cpp | 2 +
   branches/release/libs/heap/test/pairing_heap_tests.cpp | 2 +
   branches/release/libs/heap/test/skew_heap_test.cpp | 2 +
   10 files changed, 107 insertions(+), 6 deletions(-)

Modified: branches/release/boost/heap/detail/mutable_heap.hpp
==============================================================================
--- branches/release/boost/heap/detail/mutable_heap.hpp (original)
+++ branches/release/boost/heap/detail/mutable_heap.hpp 2013-03-24 09:34:19 EDT (Sun, 24 Mar 2013)
@@ -16,7 +16,6 @@
 #include <list>
 #include <utility>
 
-#include <boost/noncopyable.hpp>
 #include <boost/iterator/iterator_adaptor.hpp>
 #include <boost/heap/detail/ordered_adaptor_iterator.hpp>
 
@@ -92,6 +91,16 @@
             iterator(rhs.iterator)
         {}
 
+ bool operator==(handle_type const & rhs) const
+ {
+ return iterator == rhs.iterator;
+ }
+
+ bool operator!=(handle_type const & rhs) const
+ {
+ return iterator != rhs.iterator;
+ }
+
     private:
         explicit handle_type(list_iterator const & it):
             iterator(it)

Modified: branches/release/boost/heap/detail/stable_heap.hpp
==============================================================================
--- branches/release/boost/heap/detail/stable_heap.hpp (original)
+++ branches/release/boost/heap/detail/stable_heap.hpp 2013-03-24 09:34:19 EDT (Sun, 24 Mar 2013)
@@ -217,6 +217,14 @@
     }
 #endif
 
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+ template <class... Args>
+ internal_type make_node(Args && ... val)
+ {
+ return internal_type(std::forward<Args>(val)...);
+ }
+#endif
+
     static T & get_value(internal_type & val)
     {
         return val;
@@ -283,7 +291,24 @@
 {
     typedef StabilityCounterType stability_counter_type;
     typedef T value_type;
- typedef std::pair<T, stability_counter_type> internal_type;
+
+ struct internal_type
+ {
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+ template <class ...Args>
+ internal_type(stability_counter_type cnt, Args && ... args):
+ first(std::forward<Args>(args)...), second(cnt)
+ {}
+#endif
+
+ internal_type(stability_counter_type const & cnt, T const & value):
+ first(value), second(cnt)
+ {}
+
+ T first;
+ stability_counter_type second;
+ };
+
     typedef size_holder<constant_time_size, size_t> size_holder_type;
     typedef Cmp value_compare;
 
@@ -356,7 +381,7 @@
         stability_counter_type count = ++counter_;
         if (counter_ == (std::numeric_limits<stability_counter_type>::max)())
             BOOST_THROW_EXCEPTION(std::runtime_error("boost::heap counter overflow"));
- return std::make_pair(val, count);
+ return internal_type(count, val);
     }
 
 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
@@ -366,7 +391,7 @@
         stability_counter_type count = ++counter_;
         if (counter_ == (std::numeric_limits<stability_counter_type>::max)())
             BOOST_THROW_EXCEPTION(std::runtime_error("boost::heap counter overflow"));
- return std::make_pair(std::forward<T>(args)..., count);
+ return internal_type (count, std::forward<Args>(args)...);
     }
 #endif
 
@@ -465,6 +490,16 @@
         return extractor::get_value(node_->value);
     }
 
+ bool operator==(node_handle const & rhs) const
+ {
+ return node_ == rhs.node_;
+ }
+
+ bool operator!=(node_handle const & rhs) const
+ {
+ return node_ != rhs.node_;
+ }
+
     node_pointer node_;
 };
 

Modified: branches/release/boost/heap/heap_concepts.hpp
==============================================================================
--- branches/release/boost/heap/heap_concepts.hpp (original)
+++ branches/release/boost/heap/heap_concepts.hpp 2013-03-24 09:34:19 EDT (Sun, 24 Mar 2013)
@@ -85,7 +85,8 @@
         BOOST_CONCEPT_ASSERT((boost::Assignable<typename MutablePriorityQueue::handle_type>));
 
         typename MutablePriorityQueue::value_type v;
- typename MutablePriorityQueue::handle_type h = c.push(v);
+ typename MutablePriorityQueue::handle_type h = c.push(v);
+ typename MutablePriorityQueue::handle_type h2 = c.push(v);
         c.update(h, v);
         c.increase(h, v);
         c.decrease(h, v);
@@ -93,9 +94,15 @@
         c.update(h);
         c.increase(h);
         c.decrease(h);
+
+ equal = (h == h2);
+ not_equal = (h != h2);
+
+ h2 = h;
     }
 
     C c;
+ bool equal, not_equal;
 };
 
 }}

Modified: branches/release/boost/heap/pairing_heap.hpp
==============================================================================
--- branches/release/boost/heap/pairing_heap.hpp (original)
+++ branches/release/boost/heap/pairing_heap.hpp 2013-03-24 09:34:19 EDT (Sun, 24 Mar 2013)
@@ -375,7 +375,7 @@
 
         node_pointer n = allocator_type::allocate(1);
 
- new(n) node(super_t::make_node(std::forward<T>(args)...));
+ new(n) node(super_t::make_node(std::forward<Args>(args)...));
 
         merge_node(n);
         return handle_type(n);

Modified: branches/release/libs/heap/test/binomial_heap_test.cpp
==============================================================================
--- branches/release/libs/heap/test/binomial_heap_test.cpp (original)
+++ branches/release/libs/heap/test/binomial_heap_test.cpp 2013-03-24 09:34:19 EDT (Sun, 24 Mar 2013)
@@ -57,6 +57,8 @@
     run_binomial_heap_test<false, true>();
     run_binomial_heap_test<true, false>();
     run_binomial_heap_test<true, true>();
+
+ RUN_EMPLACE_TEST(binomial_heap);
 }
 
 BOOST_AUTO_TEST_CASE( binomial_heap_compare_lookup_test )

Modified: branches/release/libs/heap/test/common_heap_tests.hpp
==============================================================================
--- branches/release/libs/heap/test/common_heap_tests.hpp (original)
+++ branches/release/libs/heap/test/common_heap_tests.hpp 2013-03-24 09:34:19 EDT (Sun, 24 Mar 2013)
@@ -449,4 +449,40 @@
     }
 };
 
+
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+
+class thing {
+public:
+ thing( int a_, int b_, int c_ ) : a(a_), b(b_), c(c_) {}
+public:
+ int a;
+ int b;
+ int c;
+};
+
+class cmpthings {
+public:
+ bool operator() ( const thing& lhs, const thing& rhs ) const {
+ return lhs.a > rhs.a;
+ }
+ bool operator() ( const thing& lhs, const thing& rhs ) {
+ return lhs.a > rhs.a;
+ }
+};
+
+#define RUN_EMPLACE_TEST(HEAP_TYPE) \
+ do { \
+ cmpthings ord; \
+ boost::heap::HEAP_TYPE<thing, boost::heap::compare<cmpthings> > vpq(ord); \
+ vpq.emplace(5, 6, 7); \
+ boost::heap::HEAP_TYPE<thing, boost::heap::compare<cmpthings>, boost::heap::stable<true> > vpq2(ord); \
+ vpq2.emplace(5, 6, 7); \
+ } while(0);
+
+#else
+#define RUN_EMPLACE_TEST(HEAP_TYPE)
+#endif
+
+
 #endif // COMMON_HEAP_TESTS_HPP_INCLUDED

Modified: branches/release/libs/heap/test/d_ary_heap_test.cpp
==============================================================================
--- branches/release/libs/heap/test/d_ary_heap_test.cpp (original)
+++ branches/release/libs/heap/test/d_ary_heap_test.cpp 2013-03-24 09:34:19 EDT (Sun, 24 Mar 2013)
@@ -50,6 +50,12 @@
 
         run_stable_heap_tests<stable_pri_queue>();
     }
+
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+ cmpthings ord;
+ boost::heap::d_ary_heap<thing, boost::heap::arity<D>, boost::heap::compare<cmpthings>, boost::heap::stable<stable> > vpq(ord);
+ vpq.emplace(5, 6, 7);
+#endif
 }
 
 

Modified: branches/release/libs/heap/test/fibonacci_heap_test.cpp
==============================================================================
--- branches/release/libs/heap/test/fibonacci_heap_test.cpp (original)
+++ branches/release/libs/heap/test/fibonacci_heap_test.cpp 2013-03-24 09:34:19 EDT (Sun, 24 Mar 2013)
@@ -61,6 +61,8 @@
 
     run_fibonacci_heap_test<false, false>();
     run_fibonacci_heap_test<false, true>();
+
+ RUN_EMPLACE_TEST(fibonacci_heap);
 }
 
 BOOST_AUTO_TEST_CASE( fibonacci_heap_compare_lookup_test )

Modified: branches/release/libs/heap/test/pairing_heap_tests.cpp
==============================================================================
--- branches/release/libs/heap/test/pairing_heap_tests.cpp (original)
+++ branches/release/libs/heap/test/pairing_heap_tests.cpp 2013-03-24 09:34:19 EDT (Sun, 24 Mar 2013)
@@ -59,6 +59,8 @@
     run_pairing_heap_test<false, true>();
     run_pairing_heap_test<true, false>();
     run_pairing_heap_test<true, true>();
+
+ RUN_EMPLACE_TEST(pairing_heap);
 }
 
 BOOST_AUTO_TEST_CASE( pairing_heap_compare_lookup_test )

Modified: branches/release/libs/heap/test/skew_heap_test.cpp
==============================================================================
--- branches/release/libs/heap/test/skew_heap_test.cpp (original)
+++ branches/release/libs/heap/test/skew_heap_test.cpp 2013-03-24 09:34:19 EDT (Sun, 24 Mar 2013)
@@ -97,6 +97,8 @@
     run_skew_heap_test<false, true, false>();
     run_skew_heap_test<true, false, false>();
     run_skew_heap_test<true, true, false>();
+
+ RUN_EMPLACE_TEST(skew_heap);
 }
 
 BOOST_AUTO_TEST_CASE( skew_heap_mutable_test )


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk