BUGFIX (together with 64192,64193,64194):

Modifiable_priority_queue no longer depends on non-documented
boost code. This code has been copied into CGAL.

Modify boost's mutable_queue to have a constructor initializing
indices of elements not in the queue to the maximum number of elements.
Update pop to maintain this property
This commit is contained in:
Sébastien Loriot 2011-06-17 13:04:58 +00:00
parent 2254e9b4f8
commit acb0950398
4 changed files with 36 additions and 9 deletions

View File

@ -24,7 +24,7 @@
#ifdef CGAL_SURFACE_MESH_SIMPLIFICATION_USE_RELAXED_HEAP #ifdef CGAL_SURFACE_MESH_SIMPLIFICATION_USE_RELAXED_HEAP
#include <boost/pending/relaxed_heap.hpp> #include <boost/pending/relaxed_heap.hpp>
#else #else
#include <boost/pending/mutable_queue.hpp> #include <CGAL/internal/boost/mutable_queue.hpp>
namespace CGAL { namespace CGAL {
@ -32,15 +32,16 @@ namespace CGAL {
template <class IndexedType, template <class IndexedType,
class RandomAccessContainer = std::vector<IndexedType>, class RandomAccessContainer = std::vector<IndexedType>,
class Comp = std::less<typename RandomAccessContainer::value_type>, class Comp = std::less<typename RandomAccessContainer::value_type>,
class ID = boost::identity_property_map > class ID = ::boost::identity_property_map >
class mutable_queue_with_remove : public boost::mutable_queue<IndexedType,RandomAccessContainer,Comp,ID> class mutable_queue_with_remove : public internal::boost::mutable_queue<IndexedType,RandomAccessContainer,Comp,ID>
{ {
typedef boost::mutable_queue<IndexedType,RandomAccessContainer,Comp,ID> Base; typedef internal::boost::mutable_queue<IndexedType,RandomAccessContainer,Comp,ID> Base;
public: public:
typedef typename Base::size_type size_type; typedef typename Base::size_type size_type;
typedef typename Base::Node Node; typedef typename Base::Node Node;
mutable_queue_with_remove(size_type n, const Comp& x=Comp(), const ID& _id=ID()) : Base(n,x,_id) {} mutable_queue_with_remove(size_type n, const Comp& x=Comp(), const ID& _id=ID()) : Base(n,x,_id,true)
{}
void remove(const IndexedType& x){ void remove(const IndexedType& x){
//first place element at the top //first place element at the top

View File

@ -11,6 +11,11 @@
// $URL$ // $URL$
// $Id$ // $Id$
// //
// NOTE: this file have been taken from boost 1.46.1 for using
// with Modificable_priority_queue (to enhance the
// non-documented mutable_queue).
// original file is <boost/graph/detail/array_binary_tree.hpp>
//
#ifndef CGAL_INTERNAL_ARRAY_BINARY_TREE_HPP #ifndef CGAL_INTERNAL_ARRAY_BINARY_TREE_HPP
#define CGAL_INTERNAL_ARRAY_BINARY_TREE_HPP #define CGAL_INTERNAL_ARRAY_BINARY_TREE_HPP

View File

@ -11,6 +11,11 @@
// $URL$ // $URL$
// $Id$ // $Id$
// //
// NOTE: this file have been taken from boost 1.46.1 for using
// with Modificable_priority_queue (to enhance the
// non-documented mutable_queue).
// original file is <boost/pending/mutable_heap.hpp>
//
#ifndef CGAL_INTERNAL_BOOST_MUTABLE_HEAP_H #ifndef CGAL_INTERNAL_BOOST_MUTABLE_HEAP_H
#define CGAL_INTERNAL_BOOST_MUTABLE_HEAP_H #define CGAL_INTERNAL_BOOST_MUTABLE_HEAP_H

View File

@ -11,6 +11,11 @@
// $URL$ // $URL$
// $Id$ // $Id$
// //
// NOTE: this file have been taken from boost 1.46.1 for using
// with Modificable_priority_queue (to enhance the
// non-documented mutable_queue).
// original file is <boost/pending/mutable_queue.hpp>
//
#ifndef CGAL_INTERNAL_BOOST_MUTABLE_QUEUE_HPP #ifndef CGAL_INTERNAL_BOOST_MUTABLE_QUEUE_HPP
#define CGAL_INTERNAL_BOOST_MUTABLE_QUEUE_HPP #define CGAL_INTERNAL_BOOST_MUTABLE_QUEUE_HPP
@ -63,6 +68,14 @@ namespace boost {
: index_array(n), comp(x), id(_id) { : index_array(n), comp(x), id(_id) {
c.reserve(n); c.reserve(n);
} }
//SL: added this constructor so that index_array is filled with
// indices equals to n. Maintaining this property in pop allows
// to have a method to detect if an element is in the queue
mutable_queue(size_type n, const Comp& x, const ID& _id,bool)
: index_array(n,n), comp(x), id(_id) {
c.reserve(n);
}
template <class ForwardIterator> template <class ForwardIterator>
mutable_queue(ForwardIterator first, ForwardIterator last, mutable_queue(ForwardIterator first, ForwardIterator last,
const Comp& x, const ID& _id) const Comp& x, const ID& _id)
@ -75,7 +88,10 @@ namespace boost {
} }
bool empty() const { return c.empty(); } bool empty() const { return c.empty(); }
//SL: modified this function so that the element popped from the queue
// has its index set to the max number of element. That way we know
// that an element is not in the tree if its index is the max number
// of elements.
void pop() { void pop() {
value_type tmp = c.back(); value_type tmp = c.back();
c.back() = c.front(); c.back() = c.front();
@ -83,10 +99,10 @@ namespace boost {
size_type id_f = get(id, c.back()); size_type id_f = get(id, c.back());
size_type id_b = get(id, tmp); size_type id_b = get(id, tmp);
size_type i = index_array[ id_b ]; //SL was: size_type i = index_array[ id_b ];
index_array[ id_b ] = index_array[ id_f ]; index_array[ id_b ] = index_array[ id_f ];
index_array[ id_f ] = i; //SL was: index_array[ id_f ] = i;
index_array[ id_f ] = index_array.size(); /*SL added*/
c.pop_back(); c.pop_back();
Node node(c.begin(), c.end(), c.begin(), id); Node node(c.begin(), c.end(), c.begin(), id);
down_heap(node, comp, index_array); down_heap(node, comp, index_array);