AVLTree: Add Previous()/Next()

This commit is contained in:
Ingo Weinhold 2011-07-07 07:46:22 +02:00
parent d612248dcf
commit 20b22dfc3d

View File

@ -44,6 +44,9 @@ public:
Value* RootNode() const;
Value* Previous(Value* value) const;
Value* Next(Value* value) const;
inline Iterator GetIterator();
inline ConstIterator GetIterator() const;
@ -228,6 +231,30 @@ AVLTree<Definition>::RootNode() const
}
template<typename Definition>
inline typename AVLTree<Definition>::Value*
AVLTree<Definition>::Previous(Value* value) const
{
if (value == NULL)
return NULL;
AVLTreeNode* node = fTree.Previous(_GetAVLTreeNode(value));
return node != NULL ? _GetValue(node) : NULL;
}
template<typename Definition>
inline typename AVLTree<Definition>::Value*
AVLTree<Definition>::Next(Value* value) const
{
if (value == NULL)
return NULL;
AVLTreeNode* node = fTree.Next(_GetAVLTreeNode(value));
return node != NULL ? _GetValue(node) : NULL;
}
template<typename Definition>
inline typename AVLTree<Definition>::Iterator
AVLTree<Definition>::GetIterator()