mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-08 11:07:46 +08:00
integrating c++17 fixes from #959 (ref:https://github.com/flann-lib/flann/pull/392), fixed pop_t error (https://github.com/flann-lib/flann/commit/b6e37553de0dd47dc8fc9035ba5aef163981b6a4)
This commit is contained in:
@@ -115,8 +115,11 @@ public:
|
||||
count = 0;
|
||||
}
|
||||
|
||||
struct CompareT : public std::binary_function<T,T,bool>
|
||||
struct CompareT
|
||||
{
|
||||
using result_type = bool;
|
||||
using first_argument_type = T;
|
||||
using second_argument_type = T;
|
||||
bool operator()(const T& t_1, const T& t_2) const
|
||||
{
|
||||
return t_2 < t_1;
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <random>
|
||||
|
||||
#include "rtflann/util/dynamic_bitset.h"
|
||||
#include "rtflann/util/matrix.h"
|
||||
@@ -364,7 +365,9 @@ inline LshTable<unsigned char>::LshTable(unsigned int feature_size, unsigned int
|
||||
// A bit brutal but fast to code
|
||||
std::vector<size_t> indices(feature_size * CHAR_BIT);
|
||||
for (size_t i = 0; i < feature_size * CHAR_BIT; ++i) indices[i] = i;
|
||||
std::random_shuffle(indices.begin(), indices.end());
|
||||
std::random_device rd;
|
||||
std::mt19937 g(rd());
|
||||
std::shuffle(indices.begin(), indices.end(), g);
|
||||
|
||||
// Generate a random set of order of subsignature_size_ bits
|
||||
for (unsigned int i = 0; i < key_size_; ++i) {
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <random>
|
||||
|
||||
#include "rtflann/general.h"
|
||||
|
||||
@@ -76,13 +77,6 @@ inline int rand_int(int high = RAND_MAX, int low = 0)
|
||||
}
|
||||
|
||||
|
||||
class RandomGenerator
|
||||
{
|
||||
public:
|
||||
ptrdiff_t operator() (ptrdiff_t i) { return rand_int(i); }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Random number generator that returns a distinct number from
|
||||
* the [0,n) interval each time.
|
||||
@@ -110,14 +104,15 @@ public:
|
||||
*/
|
||||
void init(int n)
|
||||
{
|
||||
static RandomGenerator generator;
|
||||
// create and initialize an array of size n
|
||||
vals_.resize(n);
|
||||
size_ = n;
|
||||
for (int i = 0; i < size_; ++i) vals_[i] = i;
|
||||
|
||||
// shuffle the elements in the array
|
||||
std::random_shuffle(vals_.begin(), vals_.end(), generator);
|
||||
std::random_device rd;
|
||||
std::mt19937 g(rd());
|
||||
std::shuffle(vals_.begin(), vals_.end(), g);
|
||||
|
||||
counter_ = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user