Commit 72e74070 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Cosmetic improvements to Sampler and DynamicSampler

parent 7bb82a5b
......@@ -105,8 +105,9 @@ public:
else
{
pos = _free.back();
_items[_idx[pos]] = v;
_valid[_idx[pos]] = true;
auto i = _idx[pos];
_items[i] = v;
_valid[i] = true;
_tree[pos] = w;
_free.pop_back();
}
......@@ -160,7 +161,7 @@ public:
return _items[i];
}
bool is_valid(size_t i)
bool is_valid(size_t i) const
{
return (i < _items.size() && _valid[i]);
}
......
......@@ -134,7 +134,7 @@ private:
// uniform sampling from containers
template <class Iter, class RNG>
auto& uniform_sample(Iter begin, const Iter& end, RNG& rng)
auto&& uniform_sample(Iter begin, const Iter& end, RNG& rng)
{
auto N = end - begin;
std::uniform_int_distribution<size_t> i_rand(0, N - 1);
......@@ -143,7 +143,7 @@ auto& uniform_sample(Iter begin, const Iter& end, RNG& rng)
}
template <class Container, class RNG>
auto& uniform_sample(Container& v, RNG& rng)
auto&& uniform_sample(Container& v, RNG& rng)
{
return uniform_sample(v.begin(), v.end(), rng);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment