Add IteratorBase::type

This commit is contained in:
2024-11-22 15:29:24 -08:00
parent 1fccb65bd8
commit 22632fc9f2

View File

@@ -1887,10 +1887,12 @@ void downsize(Node *self, WriteContext *writeContext) {
template <class T> struct Iterator; template <class T> struct Iterator;
// Higher-level handle to a position in the tree // Higher-level handle to a position in the tree. Can represent the position of
// an entry associated with a node or a leaf.
struct IteratorBase { struct IteratorBase {
explicit IteratorBase(Node *node) : node(node) {} explicit IteratorBase(Node *node)
: node(node), type(node ? node->getType() : Type_Node0) {}
bool entryPresent() { return node->entryPresent; } bool entryPresent() { return node->entryPresent; }
Entry getEntry() { Entry getEntry() {
@@ -1938,6 +1940,7 @@ struct IteratorBase {
protected: protected:
Node *node; Node *node;
Type type;
// index into children array of particular leaf type // index into children array of particular leaf type
int index; int index;
}; };
@@ -1964,7 +1967,7 @@ template <class T> struct Iterator : IteratorBase {
}; };
TrivialSpan IteratorBase::partialKey() { TrivialSpan IteratorBase::partialKey() {
switch (node->getType()) { switch (type) {
case Type_Node0: case Type_Node0:
return as<Node0>().partialKey(); return as<Node0>().partialKey();
case Type_Node3: case Type_Node3:
@@ -1981,7 +1984,7 @@ TrivialSpan IteratorBase::partialKey() {
} }
IteratorBase IteratorBase::getFirstChild() { IteratorBase IteratorBase::getFirstChild() {
switch (node->getType()) { switch (type) {
case Type_Node0: case Type_Node0:
return as<Node0>().getFirstChild(); return as<Node0>().getFirstChild();
case Type_Node3: case Type_Node3:
@@ -1999,7 +2002,7 @@ IteratorBase IteratorBase::getFirstChild() {
IteratorBase::ChildAndMaxVersion IteratorBase::ChildAndMaxVersion
IteratorBase::getChildAndMaxVersion(int index) { IteratorBase::getChildAndMaxVersion(int index) {
switch (node->getType()) { switch (type) {
case Type_Node0: case Type_Node0:
return as<Node0>().getChildAndMaxVersion(index); return as<Node0>().getChildAndMaxVersion(index);
case Type_Node3: case Type_Node3:
@@ -2016,7 +2019,7 @@ IteratorBase::getChildAndMaxVersion(int index) {
} }
IteratorBase IteratorBase::getChildGeq(int index) { IteratorBase IteratorBase::getChildGeq(int index) {
switch (node->getType()) { switch (type) {
case Type_Node0: case Type_Node0:
return as<Node0>().getChildGeq(index); return as<Node0>().getChildGeq(index);
case Type_Node3: case Type_Node3: