MCPcopy Create free account
hub / github.com/ElementsProject/elements / OneIn

Method OneIn

src/leveldb/util/random.h:53–53  ·  view source on GitHub ↗

Randomly returns true ~"1/n" of the time, and false otherwise. REQUIRES: n > 0

Source from the content-addressed store, hash-verified

51 // Randomly returns true ~"1/n" of the time, and false otherwise.
52 // REQUIRES: n > 0
53 bool OneIn(int n) { return (Next() % n) == 0; }
54
55 // Skewed: pick "base" uniformly from range [0,max_log] and then
56 // return "base" random bits. The effect is to pick a number in the

Callers 5

TESTFunction · 0.80
TESTFunction · 0.80
RandomKeyFunction · 0.80
MTThreadBodyFunction · 0.80
TESTFunction · 0.80

Calls

no outgoing calls

Tested by 5

TESTFunction · 0.64
TESTFunction · 0.64
RandomKeyFunction · 0.64
MTThreadBodyFunction · 0.64
TESTFunction · 0.64