Delete all the elements with score between min and max from the skiplist. * Both min and max can be inclusive or exclusive (see range->minex and * range->maxex). When inclusive a score >= min && score <= max is deleted. * Note that this function takes the reference to the hash table view of the * sorted set, in order to remove the elements from the hash table too. */
| 382 | * Note that this function takes the reference to the hash table view of the |
| 383 | * sorted set, in order to remove the elements from the hash table too. */ |
| 384 | unsigned long zslDeleteRangeByScore(zskiplist *zsl, zrangespec *range, dict *dict) { |
| 385 | zskiplistNode *update[ZSKIPLIST_MAXLEVEL], *x; |
| 386 | unsigned long removed = 0; |
| 387 | int i; |
| 388 | |
| 389 | x = zsl->header; |
| 390 | for (i = zsl->level-1; i >= 0; i--) { |
| 391 | while (x->level(i)->forward && |
| 392 | !zslValueGteMin(x->level(i)->forward->score, range)) |
| 393 | x = x->level(i)->forward; |
| 394 | update[i] = x; |
| 395 | } |
| 396 | |
| 397 | /* Current node is the last with score < or <= min. */ |
| 398 | x = x->level(0)->forward; |
| 399 | |
| 400 | /* Delete nodes while in range. */ |
| 401 | while (x && zslValueLteMax(x->score, range)) { |
| 402 | zskiplistNode *next = x->level(0)->forward; |
| 403 | zslDeleteNode(zsl,x,update); |
| 404 | dictDelete(dict,x->ele); |
| 405 | zslFreeNode(x); /* Here is where x->ele is actually released. */ |
| 406 | removed++; |
| 407 | x = next; |
| 408 | } |
| 409 | return removed; |
| 410 | } |
| 411 | |
| 412 | unsigned long zslDeleteRangeByLex(zskiplist *zsl, zlexrangespec *range, dict *dict) { |
| 413 | zskiplistNode *update[ZSKIPLIST_MAXLEVEL], *x; |
no test coverage detected