MCPcopy Create free account
hub / github.com/couchbase/fleece / next

Method next

Fleece/Tree/MutableHashTree.cc:201–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199 { }
200
201 pair<slice,Value> next() {
202 while (unsigned(++current.index) >= current.parent.childCount()) {
203 if (depth > 0) {
204 // Pop the stack:
205 current = stack[--depth];
206 } else {
207 node.reset(); // at end
208 return {};
209 }
210 }
211
212 // Get the current node:
213 while (true) {
214 node = current.parent.childAtIndex(current.index);
215 if (node.isLeaf())
216 break;
217
218 // If it's an interior node, recurse into its children:
219 assert(depth < kMaxDepth);
220 stack[depth++] = current;
221 current = {node, 0};
222 }
223
224 // Return the current leaf's key/value:
225 if (node.isMutable()) {
226 auto leaf = ((MutableLeaf*)node.asMutable());
227 return {leaf->_key, leaf->_value};
228 } else {
229 auto &leaf = node.asImmutable()->leaf;
230 return {leaf.keyString(), leaf.value()};
231 }
232 }
233 };
234
235 }

Callers 2

iteratorMethod · 0.45
MutableHashTree.ccFile · 0.45

Calls 9

asImmutableMethod · 0.80
childCountMethod · 0.45
resetMethod · 0.45
childAtIndexMethod · 0.45
isLeafMethod · 0.45
isMutableMethod · 0.45
asMutableMethod · 0.45
keyStringMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected