MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / intsetRemove

Function intsetRemove

src/intset.c:236–253  ·  view source on GitHub ↗

Delete integer from intset */

Source from the content-addressed store, hash-verified

234
235/* Delete integer from intset */
236intset *intsetRemove(intset *is, int64_t value, int *success) {
237 uint8_t valenc = _intsetValueEncoding(value);
238 uint32_t pos;
239 if (success) *success = 0;
240
241 if (valenc <= intrev32ifbe(is->encoding) && intsetSearch(is,value,&pos)) {
242 uint32_t len = intrev32ifbe(is->length);
243
244 /* We know we can delete */
245 if (success) *success = 1;
246
247 /* Overwrite value with tail and update length */
248 if (pos < (len-1)) intsetMoveTail(is,pos+1,pos);
249 is = intsetResize(is,len-1);
250 is->length = intrev32ifbe(len-1);
251 }
252 return is;
253}
254
255/* Determine whether a value belongs to this set */
256uint8_t intsetFind(intset *is, int64_t value) {

Callers 4

intsetTestFunction · 0.85
setTypeRemoveFunction · 0.85
spopWithCountCommandFunction · 0.85
spopCommandFunction · 0.85

Calls 4

_intsetValueEncodingFunction · 0.85
intsetSearchFunction · 0.85
intsetMoveTailFunction · 0.85
intsetResizeFunction · 0.85

Tested by

no test coverage detected