/* Stores pointer to current the entry in the provided entry structure * and advances the position of the iterator. Returns 1 when the current * entry is in fact an entry, 0 otherwise. */ int listTypeNext(listTypeIterator *li, listTypeEntry *entry) { /* Protect from converting when iterating */ serverAssert(li->subject->encoding == li->encoding); entry->li = li; if (li->encoding == OBJ_ENCODING_QUICKLIST) { return quicklistNext(li->iter, &entry->entry); } else { serverPanic("Unknown list encoding"); } return 0; }
//将列表类型的迭代器指向的entry保存在提供的listTypeEntry结构中,并且更新迭代器,1表示成功,0失败 int listTypeNext(listTypeIterator *li, listTypeEntry *entry) { /* Protect from converting when iterating */ //确保对象编码类型和迭代器中encoding成员相等 serverAssert(li->subject->encoding == li->encoding); //设置listTypeEntry的entry成员关联到当前列表类型的迭代器 entry->li = li; //对列表对象编码为quicklist类型操作 if (li->encoding == OBJ_ENCODING_QUICKLIST) { //保存当前的entry到listTypeEntry的entry成员,并更新迭代器 return quicklistNext(li->iter, &entry->entry); } else { serverPanic("Unknown list encoding"); } return 0; }