MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zslFirstInLexRange

Function zslFirstInLexRange

app/redis-6.2.6/src/t_zset.c:668–690  ·  view source on GitHub ↗

Find the first node that is contained in the specified lex range. * Returns NULL when no element is contained in the range. */

Source from the content-addressed store, hash-verified

666/* Find the first node that is contained in the specified lex range.
667 * Returns NULL when no element is contained in the range. */
668zskiplistNode *zslFirstInLexRange(zskiplist *zsl, zlexrangespec *range) {
669 zskiplistNode *x;
670 int i;
671
672 /* If everything is out of range, return early. */
673 if (!zslIsInLexRange(zsl,range)) return NULL;
674
675 x = zsl->header;
676 for (i = zsl->level-1; i >= 0; i--) {
677 /* Go forward while *OUT* of range. */
678 while (x->level[i].forward &&
679 !zslLexValueGteMin(x->level[i].forward->ele,range))
680 x = x->level[i].forward;
681 }
682
683 /* This is an inner range, so the next node cannot be NULL. */
684 x = x->level[0].forward;
685 serverAssert(x != NULL);
686
687 /* Check if score <= max. */
688 if (!zslLexValueLteMax(x->ele,range)) return NULL;
689 return x;
690}
691
692/* Find the last node that is contained in the specified range.
693 * Returns NULL when no element is contained in the range. */

Callers 3

zlexcountCommandFunction · 0.85
zsetInitLexRangeFunction · 0.85

Calls 3

zslIsInLexRangeFunction · 0.85
zslLexValueGteMinFunction · 0.85
zslLexValueLteMaxFunction · 0.85

Tested by

no test coverage detected