MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / OneIn

Method OneIn

src/base/random.h:70–70  ·  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

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected