correct bug in postfix++ of interator in incremental neighbor search methods

This commit is contained in:
Sébastien Loriot 2010-08-18 12:53:25 +00:00
parent 677fa29eb8
commit 26e4e3ae68
2 changed files with 35 additions and 14 deletions

View File

@ -127,6 +127,15 @@ namespace CGAL {
}
template<class T>
struct Object_wrapper
{
T object;
Object_wrapper(const T& t):object(t){}
const T& operator* () const { return object; }
const T* operator-> () const { return &object; }
};
class iterator {
@ -185,11 +194,10 @@ namespace CGAL {
}
// postfix operator
iterator operator++(int)
Object_wrapper<Point_with_transformed_distance>
operator++(int)
{
iterator tmp(*this);
++(*this);
return tmp;
return (*ptr)++;
}
bool
@ -349,7 +357,15 @@ namespace CGAL {
Compute_the_next_nearest_neighbour();
return *this;
}
// postfix operator
Object_wrapper<Point_with_transformed_distance>
operator++(int)
{
Object_wrapper<Point_with_transformed_distance> result( *(Item_PriorityQueue.top()) );
++*this;
return result;
}
// Print statistics of the general priority search process.
std::ostream&

View File

@ -50,7 +50,14 @@ namespace CGAL {
typedef std::vector<Node_with_distance*> Node_with_distance_vector;
typedef std::vector<Point_with_transformed_distance*> Point_with_transformed_distance_vector;
template<class T>
struct Object_wrapper
{
T object;
Object_wrapper(const T& t):object(t){}
const T& operator* () const { return object; }
const T* operator-> () const { return &object; }
};
class Iterator_implementation {
@ -172,10 +179,10 @@ namespace CGAL {
}
// postfix operator
Point_with_transformed_distance
Object_wrapper<Point_with_transformed_distance>
operator++(int)
{
Point_with_transformed_distance result = *(Item_PriorityQueue.top());
Object_wrapper<Point_with_transformed_distance> result( *(Item_PriorityQueue.top()) );
++*this;
return result;
}
@ -200,12 +207,12 @@ namespace CGAL {
//destructor
~Iterator_implementation()
{
while (PriorityQueue.size()>0) {
while (!PriorityQueue.empty()) {
Node_with_distance* The_top=PriorityQueue.top();
PriorityQueue.pop();
delete The_top;
}
while (Item_PriorityQueue.size()>0) {
while (!Item_PriorityQueue.empty()) {
Point_with_transformed_distance* The_top=Item_PriorityQueue.top();
Item_PriorityQueue.pop();
delete The_top;
@ -436,12 +443,10 @@ namespace CGAL {
}
// postfix operator
iterator
Object_wrapper<Point_with_transformed_distance>
operator++(int)
{
iterator tmp(*this);
++(*this);
return tmp;
return (*Ptr_implementation)++;
}