diff options
author | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-16 23:54:19 +0000 |
---|---|---|
committer | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-16 23:54:19 +0000 |
commit | 8c22336bb9544e7227d3847986ecd20e031c9a2f (patch) | |
tree | 602f34efa65df133129f750454f2c9e09f6cc901 /ace/RB_Tree.i | |
parent | f226d4e96b1c27a75a1dcabcb39f5317b799f97e (diff) | |
download | ATCD-8c22336bb9544e7227d3847986ecd20e031c9a2f.tar.gz |
Added test, less than functor, better comments, etc. to RB_Tree class
Diffstat (limited to 'ace/RB_Tree.i')
-rw-r--r-- | ace/RB_Tree.i | 133 |
1 files changed, 83 insertions, 50 deletions
diff --git a/ace/RB_Tree.i b/ace/RB_Tree.i index ce6c15dfa0a..b423d77d5dd 100644 --- a/ace/RB_Tree.i +++ b/ace/RB_Tree.i @@ -1,152 +1,185 @@ /* -*- C++ -*- */ // $Id$ -///////////////////////////////////////// -// template class RB_Tree_Node<KEY, T> // -///////////////////////////////////////// +///////////////////////////////////////////// +// template class ACE_RB_Tree_Node<KEY, T> // +///////////////////////////////////////////// + +// Key accessor. template <class KEY, class T> ACE_INLINE KEY & -RB_Tree_Node<KEY, T>::key () +ACE_RB_Tree_Node<KEY, T>::key () { return k_; } - // key accessor + + +// Item accessor. template <class KEY, class T> ACE_INLINE T & -RB_Tree_Node<KEY, T>::item () +ACE_RB_Tree_Node<KEY, T>::item () { return t_; } - // item accessor + + +// Set color of the node. template <class KEY, class T> ACE_INLINE void -RB_Tree_Node<KEY, T>::color (RB_Tree_Node_Base::RB_Tree_Node_Color c) +ACE_RB_Tree_Node<KEY, T>::color (ACE_RB_Tree_Node_Base::RB_Tree_Node_Color c) { color_ = c; } - // set color of the node + + +// Get color of the node. template <class KEY, class T> -ACE_INLINE RB_Tree_Node_Base::RB_Tree_Node_Color -RB_Tree_Node<KEY, T>::color () +ACE_INLINE ACE_RB_Tree_Node_Base::RB_Tree_Node_Color +ACE_RB_Tree_Node<KEY, T>::color () { return color_; } - // get color of the node -template <class KEY, class T> ACE_INLINE RB_Tree_Node<KEY, T> * -RB_Tree_Node<KEY, T>::parent () +// Accessor for node's parent pointer. + +template <class KEY, class T> ACE_INLINE ACE_RB_Tree_Node<KEY, T> * +ACE_RB_Tree_Node<KEY, T>::parent () { return parent_; } - // accessor for node's parent pointer + + +// Mutator for node's parent pointer. template <class KEY, class T> ACE_INLINE void -RB_Tree_Node<KEY, T>::parent (RB_Tree_Node<KEY, T> * p) +ACE_RB_Tree_Node<KEY, T>::parent (ACE_RB_Tree_Node<KEY, T> * p) { parent_ = p; } - // mutator for node's parent pointer + + + +// Accessor for node's left child pointer. -template <class KEY, class T> ACE_INLINE RB_Tree_Node<KEY, T> * -RB_Tree_Node<KEY, T>::left () +template <class KEY, class T> ACE_INLINE ACE_RB_Tree_Node<KEY, T> * +ACE_RB_Tree_Node<KEY, T>::left () { return left_; } - // accessor for node's left child pointer + + +// Mutator for node's left child pointer. template <class KEY, class T> ACE_INLINE void -RB_Tree_Node<KEY, T>::left (RB_Tree_Node<KEY, T> * l) +ACE_RB_Tree_Node<KEY, T>::left (ACE_RB_Tree_Node<KEY, T> * l) { left_ = l; } - // mutator for node's left child pointer -template <class KEY, class T> ACE_INLINE RB_Tree_Node<KEY, T> * -RB_Tree_Node<KEY, T>::right () + +// Accessor for node's right child pointer. + +template <class KEY, class T> ACE_INLINE ACE_RB_Tree_Node<KEY, T> * +ACE_RB_Tree_Node<KEY, T>::right () { return right_; } - // accessor for node's right child pointer + + +// Mutator for node's right child pointer. template <class KEY, class T> ACE_INLINE void -RB_Tree_Node<KEY, T>::right (RB_Tree_Node<KEY, T> * r) +ACE_RB_Tree_Node<KEY, T>::right (ACE_RB_Tree_Node<KEY, T> * r) { right_ = r; } - // mutator for node's right child pointer -//////////////////////////////////// -// template class RB_Tree<KEY, T> // -//////////////////////////////////// + +//////////////////////////////////////// +// template class ACE_RB_Tree<KEY, T> // +//////////////////////////////////////// + + +// Destroys all nodes and sets the root pointer null. template <class KEY, class T> ACE_INLINE void -RB_Tree<KEY, T>::clear () +ACE_RB_Tree<KEY, T>::clear () { delete root_; root_ = 0; } - // destroys all nodes and sets the root pointer null. -///////////////////////////////////////////// -// template class RB_Tree_Iterator<KEY, T> // -///////////////////////////////////////////// +///////////////////////////////////////////////// +// template class ACE_RB_Tree_Iterator<KEY, T> // +///////////////////////////////////////////////// +// Accessor for key of node under iterator (if any). + template <class KEY, class T> ACE_INLINE KEY * -RB_Tree_Iterator<KEY, T>::key () +ACE_RB_Tree_Iterator<KEY, T>::key () { return node_ ? (&(node_->key ())) : 0; } - // accessor for key of node under iterator (if any) + + +// Accessor for item of node under iterator (if any). template <class KEY, class T> ACE_INLINE T * -RB_Tree_Iterator<KEY, T>::item () +ACE_RB_Tree_Iterator<KEY, T>::item () { return node_ ? (&(node_->item ())) : 0; } - // accessor for item of node under iterator (if any) + + +// Move to the first item in the tree. template <class KEY, class T> ACE_INLINE int -RB_Tree_Iterator<KEY, T>::first () +ACE_RB_Tree_Iterator<KEY, T>::first () { node_ = tree_.RB_tree_minimum (tree_.root_); return node_ ? 1 : 0; } - // move to the first item in the tree + + +// Move to the last item in the tree. template <class KEY, class T> ACE_INLINE int -RB_Tree_Iterator<KEY, T>::last () +ACE_RB_Tree_Iterator<KEY, T>::last () { node_ = tree_.RB_tree_maximum (tree_.root_); return node_ ? 1 : 0; } - // move to the last item in the tree + + +// Moves to the next item in the tree, +// returns 1 if there is a next item, 0 otherwise. template <class KEY, class T> ACE_INLINE int -RB_Tree_Iterator<KEY, T>::next () +ACE_RB_Tree_Iterator<KEY, T>::next () { node_ = tree_.RB_tree_successor (node_); return node_ ? 1 : 0; } - // move to the next item in the tree - // returns 1 if there is a next item, 0 otherwise + + +// Moves to the previous item in the tree, +// returns 1 if there is a previous item, 0 otherwise. template <class KEY, class T> ACE_INLINE int -RB_Tree_Iterator<KEY, T>::previous () +ACE_RB_Tree_Iterator<KEY, T>::previous () { node_ = tree_.RB_tree_predecessor (node_); return node_ ? 1 : 0; } - // move to the previous item in the tree - // returns 1 if there is a previous item, 0 otherwise template <class KEY, class T> ACE_INLINE int -RB_Tree_Iterator<KEY, T>::is_done () +ACE_RB_Tree_Iterator<KEY, T>::is_done () { return node_ ? 0 : 1; } |