From e7346707c984475369be2b28706ca251d95ed2c0 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 7 Jul 2011 07:46:22 +0200 Subject: [PATCH] AVLTree: Add Previous()/Next() --- headers/private/kernel/util/AVLTree.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/headers/private/kernel/util/AVLTree.h b/headers/private/kernel/util/AVLTree.h index eb8964e627..76d6b255eb 100644 --- a/headers/private/kernel/util/AVLTree.h +++ b/headers/private/kernel/util/AVLTree.h @@ -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::RootNode() const } +template +inline typename AVLTree::Value* +AVLTree::Previous(Value* value) const +{ + if (value == NULL) + return NULL; + + AVLTreeNode* node = fTree.Previous(_GetAVLTreeNode(value)); + return node != NULL ? _GetValue(node) : NULL; +} + + +template +inline typename AVLTree::Value* +AVLTree::Next(Value* value) const +{ + if (value == NULL) + return NULL; + + AVLTreeNode* node = fTree.Next(_GetAVLTreeNode(value)); + return node != NULL ? _GetValue(node) : NULL; +} + + template inline typename AVLTree::Iterator AVLTree::GetIterator()