Move to the next entry in the set. Returns the object at the current * position. * * Since set elements can be internally be stored as SDS strings or * simple arrays of integers, setTypeNext returns the encoding of the * set object you are iterating, and will populate the appropriate pointer * (sdsele) or (llele) accordingly. * * Note that both the sdsele and llele pointers should be passe
| 155 | * |
| 156 | * When there are no longer elements -1 is returned. */ |
| 157 | int setTypeNext(setTypeIterator *si, const char **sdsele, int64_t *llele) { |
| 158 | if (si->encoding == OBJ_ENCODING_HT) { |
| 159 | dictEntry *de = dictNext(si->di); |
| 160 | if (de == NULL) return -1; |
| 161 | *sdsele = (sds)dictGetKey(de); |
| 162 | *llele = -123456789; /* Not needed. Defensive. */ |
| 163 | } else if (si->encoding == OBJ_ENCODING_INTSET) { |
| 164 | if (!intsetGet((intset*)si->subject->m_ptr,si->ii++,llele)) |
| 165 | return -1; |
| 166 | *sdsele = NULL; /* Not needed. Defensive. */ |
| 167 | } else { |
| 168 | serverPanic("Wrong set encoding in setTypeNext"); |
| 169 | } |
| 170 | return si->encoding; |
| 171 | } |
| 172 | |
| 173 | /* The not copy on write friendly version but easy to use version |
| 174 | * of setTypeNext() is setTypeNextObject(), returning new SDS |
no test coverage detected