| 410 | } |
| 411 | |
| 412 | unsigned long zslDeleteRangeByLex(zskiplist *zsl, zlexrangespec *range, dict *dict) { |
| 413 | zskiplistNode *update[ZSKIPLIST_MAXLEVEL], *x; |
| 414 | unsigned long removed = 0; |
| 415 | int i; |
| 416 | |
| 417 | |
| 418 | x = zsl->header; |
| 419 | for (i = zsl->level-1; i >= 0; i--) { |
| 420 | while (x->level(i)->forward && |
| 421 | !zslLexValueGteMin(x->level(i)->forward->ele,range)) |
| 422 | x = x->level(i)->forward; |
| 423 | update[i] = x; |
| 424 | } |
| 425 | |
| 426 | /* Current node is the last with score < or <= min. */ |
| 427 | x = x->level(0)->forward; |
| 428 | |
| 429 | /* Delete nodes while in range. */ |
| 430 | while (x && zslLexValueLteMax(x->ele,range)) { |
| 431 | zskiplistNode *next = x->level(0)->forward; |
| 432 | zslDeleteNode(zsl,x,update); |
| 433 | dictDelete(dict,x->ele); |
| 434 | zslFreeNode(x); /* Here is where x->ele is actually released. */ |
| 435 | removed++; |
| 436 | x = next; |
| 437 | } |
| 438 | return removed; |
| 439 | } |
| 440 | |
| 441 | /* Delete all the elements with rank between start and end from the skiplist. |
| 442 | * Start and end are inclusive. Note that start and end need to be 1-based */ |
no test coverage detected