AVLTree: Add convenience LeftMost/RightMost with no arguments.
They return the left and right most nodes of the entire tree, i.e. starting from the root node. Change-Id: I651a9db6d12308aef4c2ed71484958428e58c9bc Reviewed-on: https://review.haiku-os.org/c/haiku/+/2838 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
928d780bc9
commit
621f53700f
@@ -47,7 +47,9 @@ public:
|
|||||||
Value* Previous(Value* value) const;
|
Value* Previous(Value* value) const;
|
||||||
Value* Next(Value* value) const;
|
Value* Next(Value* value) const;
|
||||||
|
|
||||||
|
Value* LeftMost() const;
|
||||||
Value* LeftMost(Value* value) const;
|
Value* LeftMost(Value* value) const;
|
||||||
|
Value* RightMost() const;
|
||||||
Value* RightMost(Value* value) const;
|
Value* RightMost(Value* value) const;
|
||||||
|
|
||||||
inline Iterator GetIterator();
|
inline Iterator GetIterator();
|
||||||
@@ -258,6 +260,15 @@ AVLTree<Definition>::Next(Value* value) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename Definition>
|
||||||
|
inline typename AVLTree<Definition>::Value*
|
||||||
|
AVLTree<Definition>::LeftMost() const
|
||||||
|
{
|
||||||
|
AVLTreeNode* node = fTree.LeftMost();
|
||||||
|
return node != NULL ? _GetValue(node) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename Definition>
|
template<typename Definition>
|
||||||
inline typename AVLTree<Definition>::Value*
|
inline typename AVLTree<Definition>::Value*
|
||||||
AVLTree<Definition>::LeftMost(Value* value) const
|
AVLTree<Definition>::LeftMost(Value* value) const
|
||||||
@@ -270,6 +281,15 @@ AVLTree<Definition>::LeftMost(Value* value) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename Definition>
|
||||||
|
inline typename AVLTree<Definition>::Value*
|
||||||
|
AVLTree<Definition>::RightMost() const
|
||||||
|
{
|
||||||
|
AVLTreeNode* node = fTree.RightMost();
|
||||||
|
return node != NULL ? _GetValue(node) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename Definition>
|
template<typename Definition>
|
||||||
inline typename AVLTree<Definition>::Value*
|
inline typename AVLTree<Definition>::Value*
|
||||||
AVLTree<Definition>::RightMost(Value* value) const
|
AVLTree<Definition>::RightMost(Value* value) const
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ public:
|
|||||||
|
|
||||||
inline AVLTreeNode* Root() const { return fRoot; }
|
inline AVLTreeNode* Root() const { return fRoot; }
|
||||||
|
|
||||||
|
inline AVLTreeNode* LeftMost() const;
|
||||||
AVLTreeNode* LeftMost(AVLTreeNode* node) const;
|
AVLTreeNode* LeftMost(AVLTreeNode* node) const;
|
||||||
|
inline AVLTreeNode* RightMost() const;
|
||||||
AVLTreeNode* RightMost(AVLTreeNode* node) const;
|
AVLTreeNode* RightMost(AVLTreeNode* node) const;
|
||||||
|
|
||||||
AVLTreeNode* Previous(AVLTreeNode* node) const;
|
AVLTreeNode* Previous(AVLTreeNode* node) const;
|
||||||
@@ -190,11 +192,25 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline AVLTreeNode*
|
||||||
|
AVLTreeBase::LeftMost() const
|
||||||
|
{
|
||||||
|
return LeftMost(fRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline AVLTreeNode*
|
||||||
|
AVLTreeBase::RightMost() const
|
||||||
|
{
|
||||||
|
return RightMost(fRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetIterator
|
// GetIterator
|
||||||
inline AVLTreeIterator
|
inline AVLTreeIterator
|
||||||
AVLTreeBase::GetIterator() const
|
AVLTreeBase::GetIterator() const
|
||||||
{
|
{
|
||||||
return AVLTreeIterator(this, NULL, LeftMost(fRoot));
|
return AVLTreeIterator(this, NULL, LeftMost());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user