AVLTree: Add Previous()/Next()
This commit is contained in:
parent
d612248dcf
commit
20b22dfc3d
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user