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

Function zslIsInLexRange

src/t_zset.cpp:650–664  ·  view source on GitHub ↗

Returns if there is a part of the zset is in the lex range. */

Source from the content-addressed store, hash-verified

648
649/* Returns if there is a part of the zset is in the lex range. */
650int zslIsInLexRange(zskiplist *zsl, zlexrangespec *range) {
651 zskiplistNode *x;
652
653 /* Test for ranges that will always be empty. */
654 int cmp = sdscmplex(range->min,range->max);
655 if (cmp > 0 || (cmp == 0 && (range->minex || range->maxex)))
656 return 0;
657 x = zsl->tail;
658 if (x == NULL || !zslLexValueGteMin(x->ele,range))
659 return 0;
660 x = zsl->header->level(0)->forward;
661 if (x == NULL || !zslLexValueLteMax(x->ele,range))
662 return 0;
663 return 1;
664}
665
666/* Find the first node that is contained in the specified lex range.
667 * Returns NULL when no element is contained in the range. */

Callers 2

zslFirstInLexRangeFunction · 0.85
zslLastInLexRangeFunction · 0.85

Calls 4

sdscmplexFunction · 0.85
zslLexValueGteMinFunction · 0.85
zslLexValueLteMaxFunction · 0.85
levelMethod · 0.80

Tested by

no test coverage detected