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

Function zzlFirstInRange

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

Find pointer to the first element contained in the specified range. * Returns NULL when no element is contained in the range. */

Source from the content-addressed store, hash-verified

853/* Find pointer to the first element contained in the specified range.
854 * Returns NULL when no element is contained in the range. */
855unsigned char *zzlFirstInRange(unsigned char *zl, zrangespec *range) {
856 unsigned char *eptr = ziplistIndex(zl,0), *sptr;
857 double score;
858
859 /* If everything is out of range, return early. */
860 if (!zzlIsInRange(zl,range)) return NULL;
861
862 while (eptr != NULL) {
863 sptr = ziplistNext(zl,eptr);
864 serverAssert(sptr != NULL);
865
866 score = zzlGetScore(sptr);
867 if (zslValueGteMin(score,range)) {
868 /* Check if score <= max. */
869 if (zslValueLteMax(score,range))
870 return eptr;
871 return NULL;
872 }
873
874 /* Move to next element. */
875 eptr = ziplistNext(zl,sptr);
876 }
877
878 return NULL;
879}
880
881/* Find pointer to the last element contained in the specified range.
882 * Returns NULL when no element is contained in the range. */

Callers 5

geoGetPointsInRangeFunction · 0.85
zzlDeleteRangeByScoreFunction · 0.85
zcountCommandFunction · 0.85
zsetInitScoreRangeFunction · 0.85

Calls 6

ziplistIndexFunction · 0.85
zzlIsInRangeFunction · 0.85
ziplistNextFunction · 0.85
zzlGetScoreFunction · 0.85
zslValueGteMinFunction · 0.85
zslValueLteMaxFunction · 0.85

Tested by

no test coverage detected