mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-30 11:56:31 -05:00
Add podman release build tooling + misc build fixes (#1455)
This commit is contained in:
parent
344014aa81
commit
fa3266ca7f
90 changed files with 1207 additions and 3657 deletions
19
src/rnd.hpp
19
src/rnd.hpp
|
|
@ -19,7 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <random>
|
||||
|
||||
class RND
|
||||
{
|
||||
|
|
@ -31,4 +31,21 @@ public:
|
|||
static uint64_t rand64(const uint64_t max_);
|
||||
static uint64_t rand64(const uint64_t min_,
|
||||
const uint64_t max_);
|
||||
|
||||
template<typename T>
|
||||
static
|
||||
void
|
||||
shrink_to_rand_elem(std::vector<T> &v_)
|
||||
{
|
||||
static std::mt19937 gen(std::random_device{}());
|
||||
|
||||
if(v_.size() <= 1)
|
||||
return;
|
||||
|
||||
std::uniform_int_distribution<> dist(0,(v_.size() - 1));
|
||||
|
||||
std::swap(v_[0],v_[dist(gen)]);
|
||||
|
||||
v_.resize(1);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue