Refactoring
This commit is contained in:
parent
a71f26d0d4
commit
9d9c090148
@ -52,29 +52,11 @@ void DataTree::ifRootHasOnlyOneChildReplaceRootWithItsChild() {
|
||||
}
|
||||
|
||||
void DataTree::deleteLastChildSubtree(DataInnerNode *node) {
|
||||
deleteSubtree(node->LastChild()->key());
|
||||
auto lastChild = _nodeStore->load(node->LastChild()->key());
|
||||
_nodeStore->removeSubtree(std::move(lastChild));
|
||||
node->removeLastChild();
|
||||
}
|
||||
|
||||
void DataTree::deleteSubtree(const Key &key) {
|
||||
auto node = _nodeStore->load(key);
|
||||
deleteChildrenOf(*node);
|
||||
_nodeStore->remove(std::move(node));
|
||||
}
|
||||
|
||||
void DataTree::deleteChildrenOf(const DataNode &node) {
|
||||
const DataInnerNode *node_inner = dynamic_cast<const DataInnerNode*>(&node);
|
||||
if (node_inner != nullptr) {
|
||||
deleteChildrenOf(*node_inner);
|
||||
}
|
||||
}
|
||||
|
||||
void DataTree::deleteChildrenOf(const DataInnerNode &node) {
|
||||
for(int i = 0; i < node.numChildren(); ++i) {
|
||||
deleteSubtree(node.getChild(i)->key());
|
||||
}
|
||||
}
|
||||
|
||||
unique_ptr<DataLeafNode> DataTree::addDataLeaf() {
|
||||
auto insertPosOrNull = algorithms::GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNull(_nodeStore, _rootNode.get());
|
||||
if (insertPosOrNull) {
|
||||
|
@ -43,9 +43,6 @@ private:
|
||||
std::unique_ptr<datanodestore::DataLeafNode> addDataLeafToFullTree();
|
||||
|
||||
void deleteLastChildSubtree(datanodestore::DataInnerNode *node);
|
||||
void deleteSubtree(const blockstore::Key &key);
|
||||
void deleteChildrenOf(const datanodestore::DataNode &node);
|
||||
void deleteChildrenOf(const datanodestore::DataInnerNode &node);
|
||||
void ifRootHasOnlyOneChildReplaceRootWithItsChild();
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DataTree);
|
||||
|
Loading…
Reference in New Issue
Block a user