diff --git a/Spatial_searching/include/CGAL/Incremental_neighbor_search.h b/Spatial_searching/include/CGAL/Incremental_neighbor_search.h index f1c4321f760..b7de0a45aa5 100644 --- a/Spatial_searching/include/CGAL/Incremental_neighbor_search.h +++ b/Spatial_searching/include/CGAL/Incremental_neighbor_search.h @@ -127,6 +127,15 @@ namespace CGAL { } + template + 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 + 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 + operator++(int) + { + Object_wrapper result( *(Item_PriorityQueue.top()) ); + ++*this; + return result; + } // Print statistics of the general priority search process. std::ostream& diff --git a/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h b/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h index eac3a988ddf..3c8fded3b2c 100644 --- a/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h +++ b/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h @@ -50,7 +50,14 @@ namespace CGAL { typedef std::vector Node_with_distance_vector; typedef std::vector Point_with_transformed_distance_vector; - + template + 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 operator++(int) { - Point_with_transformed_distance result = *(Item_PriorityQueue.top()); + Object_wrapper 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 operator++(int) { - iterator tmp(*this); - ++(*this); - return tmp; + return (*Ptr_implementation)++; }