sl@0: // sl@0: //======================================================================= sl@0: // Copyright 1997, 1998, 1999, 2000 University of Notre Dame. sl@0: // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek sl@0: // sl@0: // Distributed under the Boost Software License, Version 1.0. (See sl@0: // accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: //======================================================================= sl@0: // sl@0: #ifndef BOOST_GRAPH_DETAIL_MUTABLE_HEAP_H sl@0: #define BOOST_GRAPH_DETAIL_MUTABLE_HEAP_H sl@0: sl@0: /* sl@0: There are a few things wrong with this set of functions. sl@0: sl@0: ExternalData should be removed, it is not part of the core sl@0: algorithm. It can be handled inside the tree nodes. sl@0: sl@0: The swap() should be replaced by assignment since its use is causing sl@0: the number of memory references to double. sl@0: sl@0: The min_element should be replaced by a fixed length loop sl@0: (fixed at d for d-heaps). sl@0: sl@0: The member functions of TreeNode should be changed to global sl@0: functions. sl@0: sl@0: These functions will be replaced by those in heap_tree.h sl@0: sl@0: */ sl@0: sl@0: namespace boost { sl@0: sl@0: template sl@0: inline TreeNode up_heap(TreeNode x, const Compare& comp, ExternalData& edata) { sl@0: while (x.has_parent() && comp(x, x.parent())) sl@0: x.swap(x.parent(), edata); sl@0: return x; sl@0: } sl@0: sl@0: template sl@0: inline TreeNode down_heap(TreeNode x, const Compare& comp, ExternalData& edata) { sl@0: while (x.children().size() > 0) { sl@0: typename TreeNode::children_type::iterator sl@0: child_iter = std::min_element(x.children().begin(), sl@0: x.children().end(), sl@0: comp); sl@0: if (comp(*child_iter, x)) sl@0: x.swap(*child_iter, edata); sl@0: else sl@0: break; sl@0: } sl@0: return x; sl@0: } sl@0: sl@0: template sl@0: inline void update_heap(TreeNode x, const Compare& comp, ExternalData& edata) { sl@0: x = down_heap(x, comp, edata); sl@0: (void)up_heap(x, comp, edata); sl@0: } sl@0: sl@0: } sl@0: #endif