summaryrefslogtreecommitdiff
path: root/src/util/random.h
diff options
context:
space:
mode:
authorajreynol <andrew.j.reynolds@gmail.com>2018-10-17 17:26:01 -0500
committerajreynol <andrew.j.reynolds@gmail.com>2018-10-17 17:26:01 -0500
commit808a3acef1d21c0fd4fdb99d13ab9341d46a56a1 (patch)
tree8253a67d4a543f55663a9e7a3a97eee684a687d6 /src/util/random.h
parente3649f220498a8c00babd82f91e4d2e5a98295d8 (diff)
parent1823d6d537a59d85a17f09f53c8128d934c420a3 (diff)
Merge branch 'master' of https://github.com/CVC4/CVC4 into extRewBv
Diffstat (limited to 'src/util/random.h')
-rw-r--r--src/util/random.h35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/util/random.h b/src/util/random.h
index 480271c03..e746666fc 100644
--- a/src/util/random.h
+++ b/src/util/random.h
@@ -26,29 +26,40 @@ namespace CVC4 {
class Random
{
public:
- Random(uint64_t seed) { setSeed(seed); }
+ using result_type = uint64_t;
- /* Get current RNG (singleton). */
+ /** Constructor. */
+ Random(uint64_t seed);
+
+ /** Get current RNG (singleton). */
static Random& getRandom()
{
static thread_local Random s_current(0);
return s_current;
}
- /* Set seed of Random. */
- void setSeed(uint64_t seed)
- {
- d_seed = seed == 0 ? ~seed : seed;
- d_state = d_seed;
- }
+ /** Get the minimum number that can be picked. */
+ static uint64_t min() { return 0u; }
+
+ /** Get the maximum number that can be picked. */
+ static uint64_t max() { return UINT64_MAX; }
+
+ /** Set seed of Random. */
+ void setSeed(uint64_t seed);
- /* Next random uint64_t number. */
+ /** Operator overload to pick random uin64_t number (see rand()). */
+ uint64_t operator()();
+
+ /** Next random uint64_t number. */
uint64_t rand();
- /* Pick random uint64_t number between from and to (inclusive). */
+
+ /** Pick random uint64_t number between from and to (inclusive). */
uint64_t pick(uint64_t from, uint64_t to);
- /* Pick random double number between from and to (inclusive). */
+
+ /** Pick random double number between from and to (inclusive). */
double pickDouble(double from, double to);
- /* Pick with given probability (yes / no). */
+
+ /** Pick with given probability (yes / no). */
bool pickWithProb(double probability);
private:
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback