#pragma once
#include <stdint.h>
+#include <algorithm>
#include <random>
#include "rocksdb/rocksdb_namespace.h"
return Uniform(1 << Uniform(max_log + 1));
}
+ // Returns a random string of length "len"
+ std::string RandomString(int len);
+
+ // Generates a random string of len bytes using human-readable characters
+ std::string HumanReadableString(int len);
+
// Returns a Random instance for use by the current thread without
// additional locking
static Random* GetTLSInstance();
}
};
+// A seeded replacement for removed std::random_shuffle
+template <class RandomIt>
+void RandomShuffle(RandomIt first, RandomIt last, uint32_t seed) {
+ std::mt19937 rng(seed);
+ std::shuffle(first, last, rng);
+}
+
+// A replacement for removed std::random_shuffle
+template <class RandomIt>
+void RandomShuffle(RandomIt first, RandomIt last) {
+ RandomShuffle(first, last, std::random_device{}());
+}
+
} // namespace ROCKSDB_NAMESPACE