Delete the element 'ele' from the sorted set, returning 1 if the element * existed and was deleted, 0 otherwise (the element was not there). */
| 1486 | /* Delete the element 'ele' from the sorted set, returning 1 if the element |
| 1487 | * existed and was deleted, 0 otherwise (the element was not there). */ |
| 1488 | int zsetDel(robj *zobj, sds ele) { |
| 1489 | if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { |
| 1490 | unsigned char *eptr; |
| 1491 | |
| 1492 | if ((eptr = zzlFind((unsigned char*)zobj->m_ptr,ele,NULL)) != NULL) { |
| 1493 | zobj->m_ptr = zzlDelete((unsigned char*)zobj->m_ptr,eptr); |
| 1494 | return 1; |
| 1495 | } |
| 1496 | } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { |
| 1497 | zset *zs = (zset*)ptrFromObj(zobj); |
| 1498 | if (zsetRemoveFromSkiplist(zs, ele)) { |
| 1499 | if (htNeedsResize(zs->dict)) dictResize(zs->dict); |
| 1500 | return 1; |
| 1501 | } |
| 1502 | } else { |
| 1503 | serverPanic("Unknown sorted set encoding"); |
| 1504 | } |
| 1505 | return 0; /* No such element found. */ |
| 1506 | } |
| 1507 | |
| 1508 | /* Given a sorted set object returns the 0-based rank of the object or |
| 1509 | * -1 if the object does not exist. |
no test coverage detected