mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
integrating the existing state of TON Storage / TON Payments / CPS Fift development branches
This commit is contained in:
parent
040df63c98
commit
4e2624459b
153 changed files with 10760 additions and 1695 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/Slice.h"
|
||||
#include "td/utils/Span.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
|
@ -45,16 +46,31 @@ class Random {
|
|||
static int fast(int min, int max);
|
||||
static double fast(double min, double max);
|
||||
|
||||
class Fast {
|
||||
public:
|
||||
uint64 operator()() {
|
||||
return fast_uint64();
|
||||
}
|
||||
};
|
||||
class Xorshift128plus {
|
||||
public:
|
||||
explicit Xorshift128plus(uint64 seed);
|
||||
Xorshift128plus(uint64 seed_a, uint64 seed_b);
|
||||
uint64 operator()();
|
||||
int fast(int min, int max);
|
||||
int64 fast64(int64 min, int64 max);
|
||||
|
||||
private:
|
||||
uint64 seed_[2];
|
||||
};
|
||||
};
|
||||
|
||||
template <class T, class R>
|
||||
void random_shuffle(td::MutableSpan<T> v, R &rnd) {
|
||||
for (std::size_t i = 1; i < v.size(); i++) {
|
||||
auto pos = static_cast<std::size_t>(rnd() % (i + 1));
|
||||
std::swap(v[i], v[pos]);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue