MCPcopy Create free account
hub / github.com/apple/foundationdb / randomInt

Method randomInt

flow/DeterministicRandom.cpp:47–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47int DeterministicRandom::randomInt(int min, int maxPlusOne) {
48 ASSERT(min < maxPlusOne);
49 unsigned int range;
50 if (maxPlusOne < 0)
51 range = std::abs(maxPlusOne - min);
52 else {
53 range = maxPlusOne;
54 range -= min;
55 }
56 uint64_t v = (gen64() % range);
57 int i;
58 if (min < 0 && (-static_cast<unsigned int>(min + 1)) >= v)
59 i = -static_cast<int>(-static_cast<unsigned int>(min + 1) - v) - 1;
60 else
61 i = v + min;
62 if (randLog && useRandLog)
63 fprintf(randLog, "Rint %d\n", i);
64 return i;
65}
66
67int64_t DeterministicRandom::randomInt64(int64_t min, int64_t maxPlusOne) {
68 ASSERT(min < maxPlusOne);

Callers 15

StreamCipher.cppFile · 0.45
BaseCipherMethod · 0.45
BlobCipher.cppFile · 0.45
testRangeBasedForLoopFunction · 0.45
testIteratorIncrementFunction · 0.45
testReverseIteratorFunction · 0.45
testAppendFunction · 0.45
testCopyFunction · 0.45
flat_buffers.cppFile · 0.45
IndexedSet.cppFile · 0.45
writerFunction · 0.45
getRandomFilterMethod · 0.45

Calls 2

fprintfFunction · 0.85
absFunction · 0.50

Tested by 15

Future<Void> testClientFunction · 0.36
getMethod · 0.36
randomRemoteMethod · 0.36
getRandomKeyMethod · 0.36
_setupMethod · 0.36
randomRWKeyRangeFunction · 0.36
randomKeyFunction · 0.36
randomKeySelectorFunction · 0.36
randomLimitsFunction · 0.36
TestGetRange0Method · 0.36