mirror of https://github.com/CGAL/cgal
What's wrong with spatial sorting billions of points?
Change int to std::ptrdiff_t or difference_type.
This commit is contained in:
parent
2d77afd2e6
commit
e7eec7c62e
|
|
@ -14,7 +14,7 @@ stopping when there are less than \ccc{threshold} points.
|
||||||
\ccTagFullDeclarations
|
\ccTagFullDeclarations
|
||||||
\ccCreationVariable{o}
|
\ccCreationVariable{o}
|
||||||
\ccCreation
|
\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
|
\ccOperations
|
||||||
\ccThree{void;;}{A}{}
|
\ccThree{void;;}{A}{}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,8 @@
|
||||||
#define CGAL_HILBERT_SORT_2_H
|
#define CGAL_HILBERT_SORT_2_H
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
#include <CGAL/basic.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <cstddef>
|
||||||
#include <CGAL/Hilbert_sort_base.h>
|
#include <CGAL/Hilbert_sort_base.h>
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
@ -83,13 +82,13 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Kernel _k;
|
Kernel _k;
|
||||||
int _limit;
|
std::ptrdiff_t _limit;
|
||||||
|
|
||||||
template <int x, bool up> struct Cmp : public CGALi::Hilbert_cmp_2<Kernel,x,up>
|
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) {} };
|
{ Cmp (const Kernel &k) : CGALi::Hilbert_cmp_2<Kernel,x,up> (k) {} };
|
||||||
|
|
||||||
public:
|
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)
|
: _k(k), _limit (limit)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,8 @@
|
||||||
#define CGAL_HILBERT_SORT_3_H
|
#define CGAL_HILBERT_SORT_3_H
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
#include <CGAL/basic.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <cstddef>
|
||||||
#include <CGAL/Hilbert_sort_base.h>
|
#include <CGAL/Hilbert_sort_base.h>
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
@ -97,13 +96,13 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Kernel _k;
|
Kernel _k;
|
||||||
int _limit;
|
std::ptrdiff_t _limit;
|
||||||
|
|
||||||
template <int x, bool up> struct Cmp : public CGALi::Hilbert_cmp_3<Kernel,x,up>
|
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) {} };
|
{ Cmp (const Kernel &k) : CGALi::Hilbert_cmp_3<Kernel,x,up> (k) {} };
|
||||||
|
|
||||||
public:
|
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)
|
: _k(k), _limit (limit)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@
|
||||||
#define CGAL_MULTISCALE_SORT_H
|
#define CGAL_MULTISCALE_SORT_H
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
#include <CGAL/basic.h>
|
||||||
|
#include <iterator>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -28,11 +30,11 @@ template <class Sort>
|
||||||
class Multiscale_sort
|
class Multiscale_sort
|
||||||
{
|
{
|
||||||
Sort _sort;
|
Sort _sort;
|
||||||
int _threshold;
|
std::ptrdiff_t _threshold;
|
||||||
double _ratio;
|
double _ratio;
|
||||||
|
|
||||||
public:
|
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)
|
: _sort (sort), _threshold (threshold), _ratio (ratio)
|
||||||
{
|
{
|
||||||
CGAL_precondition (0. <= ratio && ratio <= 1.);
|
CGAL_precondition (0. <= ratio && ratio <= 1.);
|
||||||
|
|
@ -41,9 +43,10 @@ public:
|
||||||
template <class RandomAccessIterator>
|
template <class RandomAccessIterator>
|
||||||
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
|
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||||
{
|
{
|
||||||
|
typedef typename std::iterator_traits<RandomAccessIterator>::difference_type difference_type;
|
||||||
RandomAccessIterator middle = begin;
|
RandomAccessIterator middle = begin;
|
||||||
if (end - begin >= _threshold) {
|
if (end - begin >= _threshold) {
|
||||||
middle = begin + int ((end - begin) * _ratio);
|
middle = begin + difference_type ((end - begin) * _ratio);
|
||||||
this->operator() (begin, middle);
|
this->operator() (begin, middle);
|
||||||
}
|
}
|
||||||
_sort (middle, end);
|
_sort (middle, end);
|
||||||
|
|
@ -52,4 +55,4 @@ public:
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
#endif//CGAL_MULTISCALE_SORT_H
|
#endif // CGAL_MULTISCALE_SORT_H
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue