What's wrong with spatial sorting billions of points?

Change int to std::ptrdiff_t or difference_type.
This commit is contained in:
Sylvain Pion 2008-11-28 09:07:23 +00:00
parent 2d77afd2e6
commit e7eec7c62e
4 changed files with 14 additions and 13 deletions

View File

@ -14,7 +14,7 @@ stopping when there are less than \ccc{threshold} points.
\ccTagFullDeclarations
\ccCreationVariable{o}
\ccCreation
\ccConstructor{Multiscale_sort (const Sort &sort = Sort(), int threshold = 1, double ratio = 0.5)}{constructs an instance with \ccc{traits} as traits class instance.}
\ccConstructor{Multiscale_sort (const Sort &sort = Sort(), std::ptrdiff_t threshold = 1, double ratio = 0.5)}{constructs an instance with \ccc{traits} as traits class instance.}
\ccOperations
\ccThree{void;;}{A}{}

View File

@ -21,9 +21,8 @@
#define CGAL_HILBERT_SORT_2_H
#include <CGAL/basic.h>
#include <functional>
#include <cstddef>
#include <CGAL/Hilbert_sort_base.h>
CGAL_BEGIN_NAMESPACE
@ -83,13 +82,13 @@ public:
private:
Kernel _k;
int _limit;
std::ptrdiff_t _limit;
template <int x, bool up> struct Cmp : public CGALi::Hilbert_cmp_2<Kernel,x,up>
{ Cmp (const Kernel &k) : CGALi::Hilbert_cmp_2<Kernel,x,up> (k) {} };
public:
Hilbert_sort_2 (const Kernel &k = Kernel(), int limit = 1)
Hilbert_sort_2 (const Kernel &k = Kernel(), std::ptrdiff_t limit = 1)
: _k(k), _limit (limit)
{}

View File

@ -21,9 +21,8 @@
#define CGAL_HILBERT_SORT_3_H
#include <CGAL/basic.h>
#include <functional>
#include <cstddef>
#include <CGAL/Hilbert_sort_base.h>
CGAL_BEGIN_NAMESPACE
@ -97,13 +96,13 @@ public:
private:
Kernel _k;
int _limit;
std::ptrdiff_t _limit;
template <int x, bool up> struct Cmp : public CGALi::Hilbert_cmp_3<Kernel,x,up>
{ Cmp (const Kernel &k) : CGALi::Hilbert_cmp_3<Kernel,x,up> (k) {} };
public:
Hilbert_sort_3 (const Kernel &k = Kernel(), int limit = 1)
Hilbert_sort_3 (const Kernel &k = Kernel(), std::ptrdiff_t limit = 1)
: _k(k), _limit (limit)
{}

View File

@ -21,6 +21,8 @@
#define CGAL_MULTISCALE_SORT_H
#include <CGAL/basic.h>
#include <iterator>
#include <cstddef>
CGAL_BEGIN_NAMESPACE
@ -28,11 +30,11 @@ template <class Sort>
class Multiscale_sort
{
Sort _sort;
int _threshold;
std::ptrdiff_t _threshold;
double _ratio;
public:
Multiscale_sort (const Sort &sort = Sort(), int threshold = 1, double ratio = 0.5)
Multiscale_sort (const Sort &sort = Sort(), std::ptrdiff_t threshold = 1, double ratio = 0.5)
: _sort (sort), _threshold (threshold), _ratio (ratio)
{
CGAL_precondition (0. <= ratio && ratio <= 1.);
@ -41,9 +43,10 @@ public:
template <class RandomAccessIterator>
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
{
typedef typename std::iterator_traits<RandomAccessIterator>::difference_type difference_type;
RandomAccessIterator middle = begin;
if (end - begin >= _threshold) {
middle = begin + int ((end - begin) * _ratio);
middle = begin + difference_type ((end - begin) * _ratio);
this->operator() (begin, middle);
}
_sort (middle, end);
@ -52,4 +55,4 @@ public:
CGAL_END_NAMESPACE
#endif//CGAL_MULTISCALE_SORT_H
#endif // CGAL_MULTISCALE_SORT_H