From 8d24cfc6c29e928331c4714c928aa94449c5524b Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 5 Nov 2009 17:18:12 +0000 Subject: [PATCH] * Added Iterator::NextValuePointer(). * Made reference returned by _GetKey() const. That's sufficient. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33898 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/util/AVLTreeMap.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/headers/private/kernel/util/AVLTreeMap.h b/headers/private/kernel/util/AVLTreeMap.h index 18a5858e34..da25650d7b 100644 --- a/headers/private/kernel/util/AVLTreeMap.h +++ b/headers/private/kernel/util/AVLTreeMap.h @@ -74,7 +74,7 @@ private: NO_MEMORY = -1, OK = 0, HEIGHT_CHANGED = 1, - + LEFT = -1, BALANCED = 0, RIGHT = 1, @@ -288,7 +288,7 @@ protected: // strategy shortcuts inline Node* _Allocate(const Key& key, const Value& value); inline void _Free(Node* node); - inline Key& _GetKey(Node* node) const; + inline const Key& _GetKey(Node* node) const; inline Value& _GetValue(Node* node) const; inline AVLTreeNode* _GetAVLTreeNode(const Node* node) const; inline Node* _GetNode(const AVLTreeNode* node) const; @@ -311,12 +311,12 @@ public: : ConstIterator() { } - + inline Iterator(const Iterator& other) : ConstIterator(other) { } - + inline void Remove() { if (AVLTreeNode* node = ConstIterator::fTreeIterator.Remove()) { @@ -326,14 +326,14 @@ public: parent->_Free(parent->_GetNode(node)); } } - + private: inline Iterator(_AVL_TREE_MAP_CLASS_NAME* parent, const AVLTreeIterator& treeIterator) : ConstIterator(parent, treeIterator) { } - + friend class _AVL_TREE_MAP_CLASS_NAME; }; }; @@ -393,6 +393,13 @@ public: return Value(); } + inline Value* NextValuePointer() + { + if (AVLTreeNode* node = fTreeIterator.Next()) + return &fParent->_GetValue(fParent->_GetNode(node)); + return NULL; + } + inline Value Previous() { if (AVLTreeNode* node = fTreeIterator.Previous()) @@ -597,7 +604,7 @@ _AVL_TREE_MAP_CLASS_NAME::_Free(Node* node) // _GetKey _AVL_TREE_MAP_TEMPLATE_LIST -inline Key& +inline const Key& _AVL_TREE_MAP_CLASS_NAME::_GetKey(Node* node) const { return fStrategy.GetKey(node);