diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 11355e7..37626e6 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1369,6 +1369,48 @@ bool checkRangeVersionOfFirstGeq(Node *node, InternalVersionT readVersion) { return node->entry.rangeVersion <= readVersion; } +Node *nextPhysical(Node *node) { + Node *nextChild = getFirstChild(node); + if (nextChild != nullptr) { + return nextChild; + } + for (;;) { + int index = node->parentsIndex; + node = node->parent; + if (node == nullptr) { + return nullptr; + } + Node *nextChild = getChildGeq(node, index + 1); + if (nextChild != nullptr) { + return nextChild; + } + } +} + +Node *nextLogical(Node *node) { + Node *nextChild = getFirstChild(node); + if (nextChild != nullptr) { + node = nextChild; + goto downLeftSpine; + } + for (;;) { + int index = node->parentsIndex; + node = node->parent; + if (node == nullptr) { + return nullptr; + } + Node *nextChild = getChildGeq(node, index + 1); + if (nextChild != nullptr) { + node = nextChild; + goto downLeftSpine; + } + } +downLeftSpine: + for (; !node->entryPresent; node = getFirstChild(node)) { + } + return node; +} + // self must not be the root void maybeDecreaseCapacity(Node *&self, WriteContext *writeContext); @@ -1613,48 +1655,6 @@ TaggedNodePointer &getOrCreateChild(TaggedNodePointer &self, TrivialSpan &key, } } -Node *nextPhysical(Node *node) { - Node *nextChild = getFirstChild(node); - if (nextChild != nullptr) { - return nextChild; - } - for (;;) { - int index = node->parentsIndex; - node = node->parent; - if (node == nullptr) { - return nullptr; - } - Node *nextChild = getChildGeq(node, index + 1); - if (nextChild != nullptr) { - return nextChild; - } - } -} - -Node *nextLogical(Node *node) { - Node *nextChild = getFirstChild(node); - if (nextChild != nullptr) { - node = nextChild; - goto downLeftSpine; - } - for (;;) { - int index = node->parentsIndex; - node = node->parent; - if (node == nullptr) { - return nullptr; - } - Node *nextChild = getChildGeq(node, index + 1); - if (nextChild != nullptr) { - node = nextChild; - goto downLeftSpine; - } - } -downLeftSpine: - for (; !node->entryPresent; node = getFirstChild(node)) { - } - return node; -} - void freeAndMakeCapacity(Node *&self, int capacity, WriteContext *writeContext) { ++writeContext->accum.nodes_resized;