AVLTree: Add Previous()/Next()

This commit is contained in:
Ingo Weinhold 2011-07-07 07:46:22 +02:00
parent 5deb28d6d2
commit e7346707c9

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()