Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82569 - branches/release/boost/heap
From: tim_at_[hidden]
Date: 2013-01-20 13:02:39


Author: timblechmann
Date: 2013-01-20 13:02:39 EST (Sun, 20 Jan 2013)
New Revision: 82569
URL: http://svn.boost.org/trac/boost/changeset/82569

Log:
heap: merge fix from trunk

Properties modified:
   branches/release/boost/heap/ (props changed)
Text files modified:
   branches/release/boost/heap/fibonacci_heap.hpp | 41 +++++++++++++++++++--------------------
   1 files changed, 20 insertions(+), 21 deletions(-)

Modified: branches/release/boost/heap/fibonacci_heap.hpp
==============================================================================
--- branches/release/boost/heap/fibonacci_heap.hpp (original)
+++ branches/release/boost/heap/fibonacci_heap.hpp 2013-01-20 13:02:39 EST (Sun, 20 Jan 2013)
@@ -397,16 +397,7 @@
         node_pointer element = top_element;
         roots.erase(node_list_type::s_iterator_to(*element));
 
- add_children_to_root(element);
-
- element->~node();
- allocator_type::deallocate(element, 1);
-
- size_holder::decrement();
- if (!empty())
- consolidate();
- else
- top_element = NULL;
+ finish_erase_or_pop(element);
     }
 
     /**
@@ -542,21 +533,15 @@
      * */
     void erase(handle_type const & handle)
     {
- node_pointer n = handle.node_;
- node_pointer parent = n->get_parent();
+ node_pointer element = handle.node_;
+ node_pointer parent = element->get_parent();
 
         if (parent)
- parent->children.erase(node_list_type::s_iterator_to(*n));
+ parent->children.erase(node_list_type::s_iterator_to(*element));
         else
- roots.erase(node_list_type::s_iterator_to(*n));
-
- add_children_to_root(n);
- consolidate();
+ roots.erase(node_list_type::s_iterator_to(*element));
 
- n->~node();
- allocator_type::deallocate(n, 1);
-
- size_holder::decrement();
+ finish_erase_or_pop(element);
     }
 
     /// \copydoc boost::heap::priority_queue::begin
@@ -757,6 +742,20 @@
         while (it != roots.end());
     }
 
+ void finish_erase_or_pop(node_pointer erased_node)
+ {
+ add_children_to_root(erased_node);
+
+ erased_node->~node();
+ allocator_type::deallocate(erased_node, 1);
+
+ size_holder::decrement();
+ if (!empty())
+ consolidate();
+ else
+ top_element = NULL;
+ }
+
     mutable node_pointer top_element;
     node_list_type roots;
 #endif


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