Find the last node that is contained in the specified range. * Returns NULL when no element is contained in the range. */
| 692 | /* Find the last node that is contained in the specified range. |
| 693 | * Returns NULL when no element is contained in the range. */ |
| 694 | zskiplistNode *zslLastInLexRange(zskiplist *zsl, zlexrangespec *range) { |
| 695 | zskiplistNode *x; |
| 696 | int i; |
| 697 | |
| 698 | /* If everything is out of range, return early. */ |
| 699 | if (!zslIsInLexRange(zsl,range)) return NULL; |
| 700 | |
| 701 | x = zsl->header; |
| 702 | for (i = zsl->level-1; i >= 0; i--) { |
| 703 | /* Go forward while *IN* range. */ |
| 704 | while (x->level(i)->forward && |
| 705 | zslLexValueLteMax(x->level(i)->forward->ele,range)) |
| 706 | x = x->level(i)->forward; |
| 707 | } |
| 708 | |
| 709 | /* This is an inner range, so this node cannot be NULL. */ |
| 710 | serverAssert(x != NULL); |
| 711 | |
| 712 | /* Check if score >= min. */ |
| 713 | if (!zslLexValueGteMin(x->ele,range)) return NULL; |
| 714 | return x; |
| 715 | } |
| 716 | |
| 717 | /*----------------------------------------------------------------------------- |
| 718 | * Ziplist-backed sorted set API |
no test coverage detected