Add random_shuffle to the high level functions

This commit is contained in:
Andreas Fabri 2010-01-27 13:48:02 +00:00
parent 6e1b0d9e98
commit 0874e2604e
2 changed files with 22 additions and 0 deletions

View File

@ -25,6 +25,11 @@
#include <CGAL/Hilbert_sort_2.h>
#include <CGAL/Hilbert_sort_3.h>
#include <boost/random.hpp>
#include <boost/random/linear_congruential.hpp>
#include <algorithm>
CGAL_BEGIN_NAMESPACE
namespace internal {
@ -33,6 +38,8 @@ namespace internal {
void hilbert_sort (RandomAccessIterator begin, RandomAccessIterator end,
const Kernel &k, typename Kernel::Point_2 *)
{
boost::random_number_generator<boost::rand48> rng(boost::rand48(0L));
std::random_shuffle(begin,end, rng);
(Hilbert_sort_2<Kernel> (k)) (begin, end);
}
@ -40,6 +47,8 @@ namespace internal {
void hilbert_sort (RandomAccessIterator begin, RandomAccessIterator end,
const Kernel &k, typename Kernel::Point_3 *)
{
boost::random_number_generator<boost::rand48> rng(boost::rand48(0L));
std::random_shuffle(begin,end, rng);
(Hilbert_sort_3<Kernel> (k)) (begin, end);
}
}

View File

@ -27,6 +27,11 @@
#include <CGAL/Multiscale_sort.h>
#include <boost/random.hpp>
#include <boost/random/linear_congruential.hpp>
#include <algorithm>
CGAL_BEGIN_NAMESPACE
namespace internal {
@ -36,6 +41,10 @@ namespace internal {
const Kernel &k, typename Kernel::Point_2 *)
{
typedef Hilbert_sort_2<Kernel> Sort;
boost::random_number_generator<boost::rand48> rng(boost::rand48(0L));
std::random_shuffle(begin,end,rng);
(Multiscale_sort<Sort> (Sort (k, 4), 16, 0.25)) (begin, end);
}
@ -44,6 +53,10 @@ namespace internal {
const Kernel &k, typename Kernel::Point_3 *)
{
typedef Hilbert_sort_3<Kernel> Sort;
boost::random_number_generator<boost::rand48> rng(boost::rand48(0L));
std::random_shuffle(begin,end, rng);
(Multiscale_sort<Sort> (Sort (k, 8), 64, 0.125)) (begin, end);
}
}