MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / intsetRandom

Function intsetRandom

src/intset.c:262–266  ·  view source on GitHub ↗

Return random member */

Source from the content-addressed store, hash-verified

260
261/* Return random member */
262int64_t intsetRandom(intset *is) {
263 uint32_t len = intrev32ifbe(is->length);
264 assert(len); /* avoid division by zero on corrupt intset payload. */
265 return _intsetGet(is,rand()%len);
266}
267
268/* Get the value at the given position. When this position is
269 * out of range the function returns 0, when in range it returns 1. */

Callers 1

setTypeRandomElementFunction · 0.85

Calls 1

_intsetGetFunction · 0.85

Tested by

no test coverage detected