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

Function zslDeleteNode

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

Internal function used by zslDelete, zslDeleteRangeByScore and * zslDeleteRangeByRank. */

Source from the content-addressed store, hash-verified

189/* Internal function used by zslDelete, zslDeleteRangeByScore and
190 * zslDeleteRangeByRank. */
191void zslDeleteNode(zskiplist *zsl, zskiplistNode *x, zskiplistNode **update) {
192 int i;
193 for (i = 0; i < zsl->level; i++) {
194 if (update[i]->level[i].forward == x) {
195 update[i]->level[i].span += x->level[i].span - 1;
196 update[i]->level[i].forward = x->level[i].forward;
197 } else {
198 update[i]->level[i].span -= 1;
199 }
200 }
201 if (x->level[0].forward) {
202 x->level[0].forward->backward = x->backward;
203 } else {
204 zsl->tail = x->backward;
205 }
206 while(zsl->level > 1 && zsl->header->level[zsl->level-1].forward == NULL)
207 zsl->level--;
208 zsl->length--;
209}
210
211/* Delete an element with matching score/element from the skiplist.
212 * The function returns 1 if the node was found and deleted, otherwise

Callers 5

zslDeleteFunction · 0.85
zslUpdateScoreFunction · 0.85
zslDeleteRangeByScoreFunction · 0.85
zslDeleteRangeByLexFunction · 0.85
zslDeleteRangeByRankFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected