RB_Tree.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // RB_Tree.inl,v 4.6 2006/06/06 03:58:27 jtc Exp
00004 
00005 #include "ace/Guard_T.h"
00006 #include "ace/Malloc_Base.h"
00007 #include "ace/Log_Msg.h"
00008 
00009 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00010 
00011 /////////////////////////////////////////////////////
00012 // template class ACE_RB_Tree_Node<EXT_ID, INT_ID> //
00013 /////////////////////////////////////////////////////
00014 
00015 // Key accessor.
00016 
00017 template <class EXT_ID, class INT_ID>
00018 ACE_INLINE EXT_ID &
00019 ACE_RB_Tree_Node<EXT_ID, INT_ID>::key ()
00020 {
00021   ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::key");
00022   return k_;
00023 }
00024 
00025 
00026 // Item accessor.
00027 
00028 template <class EXT_ID, class INT_ID>
00029 ACE_INLINE INT_ID &
00030 ACE_RB_Tree_Node<EXT_ID, INT_ID>::item ()
00031 {
00032   ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>:item");
00033   return t_;
00034 }
00035 
00036 
00037 // Set color of the node.
00038 
00039 template <class EXT_ID, class INT_ID>
00040 ACE_INLINE void
00041 ACE_RB_Tree_Node<EXT_ID, INT_ID>::color (ACE_RB_Tree_Node_Base::RB_Tree_Node_Color c)
00042 {
00043   ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::color mutator");
00044   color_ = c;
00045 }
00046 
00047 
00048 // Get color of the node.
00049 
00050 template <class EXT_ID, class INT_ID>
00051 ACE_INLINE ACE_RB_Tree_Node_Base::RB_Tree_Node_Color
00052 ACE_RB_Tree_Node<EXT_ID, INT_ID>::color ()
00053 {
00054   ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::color accessor");
00055   return color_;
00056 }
00057 
00058 
00059 // Accessor for node's parent pointer.
00060 
00061 template <class EXT_ID, class INT_ID>
00062 ACE_INLINE ACE_RB_Tree_Node<EXT_ID, INT_ID> *
00063 ACE_RB_Tree_Node<EXT_ID, INT_ID>::parent ()
00064 {
00065   ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::parent accessor");
00066   return parent_;
00067 }
00068 
00069 
00070 // Mutator for node's parent pointer.
00071 
00072 template <class EXT_ID, class INT_ID>
00073 ACE_INLINE void
00074 ACE_RB_Tree_Node<EXT_ID, INT_ID>::parent (ACE_RB_Tree_Node<EXT_ID, INT_ID> * p)
00075 {
00076   ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::parent mutator");
00077   parent_ = p;
00078 }
00079 
00080 
00081 
00082 // Accessor for node's left child pointer.
00083 
00084 template <class EXT_ID, class INT_ID>
00085 ACE_INLINE ACE_RB_Tree_Node<EXT_ID, INT_ID> *
00086 ACE_RB_Tree_Node<EXT_ID, INT_ID>::left ()
00087 {
00088   ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::left accessor");
00089   return left_;
00090 }
00091 
00092 
00093 // Mutator for node's left child pointer.
00094 
00095 template <class EXT_ID, class INT_ID>
00096 ACE_INLINE void
00097 ACE_RB_Tree_Node<EXT_ID, INT_ID>::left (ACE_RB_Tree_Node<EXT_ID, INT_ID> * l)
00098 {
00099   ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::left mutator");
00100   left_ = l;
00101 }
00102 
00103 
00104 // Accessor for node's right child pointer.
00105 
00106 template <class EXT_ID, class INT_ID>
00107 ACE_INLINE ACE_RB_Tree_Node<EXT_ID, INT_ID> *
00108 ACE_RB_Tree_Node<EXT_ID, INT_ID>::right ()
00109 {
00110   ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::right accessor");
00111   return right_;
00112 }
00113 
00114 
00115 // Mutator for node's right child pointer.
00116 
00117 template <class EXT_ID, class INT_ID>
00118 ACE_INLINE void
00119 ACE_RB_Tree_Node<EXT_ID, INT_ID>::right (ACE_RB_Tree_Node<EXT_ID, INT_ID> * r)
00120 {
00121   ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::right mutator");
00122   right_ = r;
00123 }
00124 
00125 
00126 ////////////////////////////////////////////////////////////////////////
00127 // template class ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> //
00128 ////////////////////////////////////////////////////////////////////////
00129 
00130 
00131 // Initialize an RB Tree.
00132 
00133 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00134 ACE_INLINE int
00135 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::open (ACE_Allocator *alloc)
00136 {
00137   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::open");
00138   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00139 
00140   // Calling this->close_i () ensures we release previously allocated
00141   // memory before allocating new memory.
00142   this->close_i ();
00143 
00144   // If we were passed an allocator use it,
00145   // otherwise use the default instance.
00146 
00147   if (alloc == 0)
00148     alloc = ACE_Allocator::instance ();
00149 
00150   this->allocator_ = alloc;
00151 
00152   return 0;
00153 }
00154 
00155 // Close down an RB_Tree and release dynamically allocated
00156 // resources.
00157 
00158 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00159 ACE_INLINE int
00160 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::close (void)
00161 {
00162   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::close");
00163   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00164 
00165   return this->close_i ();
00166 }
00167 
00168 
00169 // Associate <ext_id> with <int_id>.  If <ext_id> is already in the
00170 // tree then the <ACE_RB_Tree_Node> is not changed.  Returns 0 if a
00171 // new entry is bound successfully, returns 1 if an attempt is made
00172 // to bind an existing entry, and returns -1 if failures occur.
00173 
00174 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00175 ACE_INLINE int
00176 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::bind (const EXT_ID &ext_id,
00177                                                            const INT_ID &int_id)
00178 {
00179   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::bind (const EXT_ID &item, const INT_ID &int_id)");
00180   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00181 
00182   ACE_RB_Tree_Node<EXT_ID, INT_ID> *entry;
00183   return this->insert_i (ext_id, int_id, entry);
00184 }
00185 
00186 
00187 // Same as a normal bind, except the tree entry is also passed back
00188 // to the caller.  The entry in this case will either be the newly
00189 // created entry, or the existing one.
00190 
00191 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00192 ACE_INLINE int
00193 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::bind (const EXT_ID &ext_id,
00194                                                            const INT_ID &int_id,
00195                                                            ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)
00196 {
00197   ACE_TRACE ("ACE_RB_Tree::bind (const EXT_ID &ext_id, const INT_ID &int_id, "
00198              "ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)");
00199   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00200 
00201   return this->insert_i (ext_id, int_id, entry);
00202 }
00203 
00204 
00205 // Associate <ext_id> with <int_id> if and only if <ext_id> is not
00206 // in the tree.  If <ext_id> is already in the tree then the <int_id>
00207 // parameter is assigned the existing value in the tree.  Returns 0
00208 // if a new entry is bound successfully, returns 1 if an attempt is
00209 // made to bind an existing entry, and returns -1 if failures occur.
00210 
00211 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00212 ACE_INLINE int
00213 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::trybind (const EXT_ID &ext_id,
00214                                                               INT_ID &int_id)
00215 {
00216   ACE_TRACE ("ACE_RB_Tree::trybind (const EXT_ID &ext_id, INT_ID &int_id)");
00217   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00218 
00219   ACE_RB_Tree_Node<EXT_ID, INT_ID> *entry;
00220   int result = this->insert_i (ext_id, int_id, entry);
00221 
00222   if (result == 1)
00223     {
00224       int_id = entry->item ();
00225     }
00226 
00227   return result;
00228 }
00229 
00230 
00231 // Same as a normal trybind, except the tree entry is also passed
00232 // back to the caller.  The entry in this case will either be the
00233 // newly created entry, or the existing one.
00234 
00235 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00236 ACE_INLINE int
00237 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::trybind (const EXT_ID &ext_id,
00238                                                               INT_ID &int_id,
00239                                                               ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)
00240 {
00241   ACE_TRACE ("ACE_RB_Tree::trybind (const EXT_ID &ext_id, INT_ID &int_id, "
00242              "ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)");
00243   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00244 
00245   int result = this->insert_i (ext_id, int_id, entry);
00246 
00247   if (result == 1)
00248     {
00249       int_id = entry->item ();
00250     }
00251 
00252 
00253   return result;
00254 }
00255 
00256 
00257 // Reassociate <ext_id> with <int_id>.  If <ext_id> is not in the
00258 // tree then behaves just like <bind>.  Returns 0 if a new entry is
00259 // bound successfully, returns 1 if an existing entry was rebound,
00260 // and returns -1 if failures occur.
00261 
00262 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00263 ACE_INLINE int
00264 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::rebind (const EXT_ID &ext_id,
00265                                                              const INT_ID &int_id)
00266 {
00267   ACE_TRACE ("ACE_RB_Tree::rebind (const EXT_ID &ext_id, const INT_ID &int_id)");
00268   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00269 
00270   ACE_RB_Tree_Node<EXT_ID, INT_ID> *entry;
00271   int result = this->insert_i (ext_id, int_id, entry);
00272 
00273   if (result == 1)
00274     {
00275       entry->key () = ext_id;
00276       entry->item () = int_id;
00277     }
00278 
00279   return result;
00280 }
00281 
00282 
00283 // Same as a normal rebind, except the tree entry is also passed back
00284 // to the caller.  The entry in this case will either be the newly
00285 // created entry, or the existing one.
00286 
00287 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00288 ACE_INLINE int
00289 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::rebind (const EXT_ID &ext_id,
00290                                                              const INT_ID &int_id,
00291                                                              ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)
00292 {
00293   ACE_TRACE ("ACE_RB_Tree::rebind (const EXT_ID &ext_id, const INT_ID &int_id, "
00294              "ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)");
00295   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00296 
00297   int result = this->insert_i (ext_id, int_id, entry);
00298 
00299   if (result == 1)
00300     {
00301       entry->key () = ext_id;
00302       entry->item () = int_id;
00303     }
00304 
00305   return result;
00306 }
00307 
00308 
00309 // Associate <ext_id> with <int_id>.  If <ext_id> is not in the tree
00310 // then behaves just like <bind>.  Otherwise, store the old value of
00311 // <int_id> into the "out" parameter and rebind the new parameters.
00312 // Returns 0 if a new entry is bound successfully, returns 1 if an
00313 // existing entry was rebound, and returns -1 if failures occur.
00314 
00315 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00316 ACE_INLINE int
00317 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::rebind (const EXT_ID &ext_id,
00318                                                              const INT_ID &int_id,
00319                                                              INT_ID &old_int_id)
00320 {
00321   ACE_TRACE ("ACE_RB_Tree::rebind (const EXT_ID &ext_id, "
00322              "const INT_ID &int_id, INT_ID &old_int_id)");
00323   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00324 
00325   ACE_RB_Tree_Node<EXT_ID, INT_ID> *entry;
00326   int result = this->insert_i (ext_id, int_id, entry);
00327 
00328   if (result == 1)
00329     {
00330       old_int_id = entry->item ();
00331       entry->key () = ext_id;
00332       entry->item () = int_id;
00333     }
00334 
00335   return result;
00336 }
00337 
00338 
00339 // Same as a normal rebind, except the tree entry is also passed back
00340 // to the caller.  The entry in this case will either be the newly
00341 // created entry, or the existing one.
00342 
00343 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00344 ACE_INLINE int
00345 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::rebind (const EXT_ID &ext_id,
00346                                                              const INT_ID &int_id,
00347                                                              INT_ID &old_int_id,
00348                                                              ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)
00349 {
00350   ACE_TRACE ("ACE_RB_Tree::rebind (const EXT_ID &ext_id, const INT_ID &int_id,"
00351              "INT_ID &old_int_id, ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)");
00352   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00353 
00354   int result = this->insert_i (ext_id, int_id, entry);
00355 
00356   if (result == 1)
00357     {
00358       old_int_id = entry->item ();
00359       entry->key () = ext_id;
00360       entry->item () = int_id;
00361     }
00362 
00363   return result;
00364 }
00365 
00366 
00367 // Associate <ext_id> with <int_id>.  If <ext_id> is not in the tree
00368 // then behaves just like <bind>.  Otherwise, store the old values
00369 // of <ext_id> and <int_id> into the "out" parameters and rebind the
00370 // new parameters.  This is very useful if you need to have an
00371 // atomic way of updating <ACE_RB_Tree_Nodes> and you also need
00372 // full control over memory allocation.  Returns 0 if a new entry is
00373 // bound successfully, returns 1 if an existing entry was rebound,
00374 // and returns -1 if failures occur.
00375 
00376 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00377 ACE_INLINE int
00378 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::rebind (const EXT_ID &ext_id,
00379                                                              const INT_ID &int_id,
00380                                                              EXT_ID &old_ext_id,
00381                                                              INT_ID &old_int_id)
00382 {
00383   ACE_TRACE ("ACE_RB_Tree::rebind (const EXT_ID &ext_id, const INT_ID &int_id,"
00384              "EXT_ID &old_ext_id, INT_ID &old_int_id)");
00385   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00386 
00387   ACE_RB_Tree_Node<EXT_ID, INT_ID> *entry;
00388   int result = this->insert_i (ext_id, int_id, entry);
00389 
00390   if (result == 1)
00391     {
00392       old_ext_id = entry->key ();
00393       old_int_id = entry->item ();
00394       entry->key () = ext_id;
00395       entry->item () = int_id;
00396     }
00397 
00398   return result;
00399 }
00400 
00401 
00402 // Same as a normal rebind, except the tree entry is also passed back
00403 // to the caller.  The entry in this case will either be the newly
00404 // created entry, or the existing one.
00405 
00406 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00407 ACE_INLINE int
00408 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::rebind (const EXT_ID &ext_id,
00409                                                              const INT_ID &int_id,
00410                                                              EXT_ID &old_ext_id,
00411                                                              INT_ID &old_int_id,
00412                                                              ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)
00413 {
00414   ACE_TRACE ("ACE_RB_Tree::rebind (const EXT_ID &ext_id, const INT_ID &int_id, "
00415              "EXT_ID &old_ext_id, INT_ID &old_int_id, "
00416              "ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)");
00417   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00418 
00419   int result = this->insert_i (ext_id, int_id, entry);
00420 
00421   if (result == 1)
00422     {
00423       old_ext_id = entry->key ();
00424       old_int_id = entry->item ();
00425       entry->key () = ext_id;
00426       entry->item () = int_id;
00427     }
00428 
00429   return result;
00430 }
00431 
00432 
00433 // Locate <ext_id> and pass out parameter via <int_id>.  If found,
00434 // return 0, returns -1 if not found.
00435 
00436 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00437 ACE_INLINE int
00438 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find (const EXT_ID &ext_id,
00439                                                            INT_ID &int_id)
00440 {
00441   ACE_TRACE ("ACE_RB_Tree::find (const EXT_ID &ext_id, INT_ID &int_id)");
00442   ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00443 
00444   ACE_RB_Tree_Node<EXT_ID, INT_ID> *entry = 0;
00445 
00446   int result = this->find_i (ext_id, entry);
00447   if (result == 0)
00448     {
00449       int_id = entry->item ();
00450     }
00451 
00452   return result;
00453 }
00454 
00455 // Locate <ext_id> and pass out parameter via <entry>.  If found,
00456 // return 0, returns -1 if not found.
00457 
00458 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00459 ACE_INLINE int
00460 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find (const EXT_ID &ext_id,
00461                                                            ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)
00462 {
00463   ACE_TRACE ("ACE_RB_Tree::find (const EXT_ID &ext_id, ACE_RB_Tree_Node<EXT_ID, INT_ID> *&entry)");
00464   ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00465 
00466   return this->find_i (ext_id, entry);
00467 }
00468 
00469 
00470 // Unbind (remove) the <ext_id> from the tree.  Don't return the
00471 // <int_id> to the caller (this is useful for collections where the
00472 // <int_id>s are *not* dynamically allocated...).
00473 
00474 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00475 ACE_INLINE int
00476 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::unbind (const EXT_ID &ext_id)
00477 {
00478   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::unbind (const EXT_ID &ext_id)");
00479   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00480 
00481   INT_ID int_id;
00482   int result = this->remove_i (ext_id, int_id);
00483 
00484   // Remap the return codes from the internal method: this
00485   // is maintained this way in support of deprecated methods,
00486   // and will be cleaned up when these methods are removed.
00487   switch (result)
00488     {
00489       case 1:
00490         // If the node was found and deleted, return success.
00491         return 0;
00492       case 0:
00493         // If nothing was found, set errno and break.
00494         errno = ENOENT;
00495         break;
00496       case -1:
00497         // If an error happened, just break.
00498         break;
00499     }
00500 
00501   // Return an error if we didn't already return success.
00502   return -1;
00503 }
00504 
00505 
00506 // Break any association of <ext_id>.  Returns the value of <int_id>
00507 // in case the caller needs to deallocate memory.
00508 
00509 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00510 ACE_INLINE int
00511 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::unbind (const EXT_ID &ext_id,
00512                                                              INT_ID &int_id)
00513 {
00514   ACE_TRACE ("ACE_RB_Tree::unbind (const EXT_ID &ext_id, INT_ID &int_id)");
00515   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00516 
00517   int result = this->remove_i (ext_id, int_id);
00518 
00519   // Remap the return codes from the internal method: this
00520   // is maintained this way in support of deprecated methods,
00521   // and will be cleaned up when these methods are removed.
00522   switch (result)
00523     {
00524       case 1:
00525         // If the node was found and deleted, return success.
00526         return 0;
00527       case 0:
00528         // If nothing was found, set errno and break.
00529         errno = ENOENT;
00530         break;
00531       case -1:
00532         // If an error happened, just break.
00533         break;
00534     }
00535 
00536   // Return an error if we didn't already return success.
00537   return -1;
00538 }
00539 
00540 
00541 // Remove entry from the tree.  This method should be used with *extreme*
00542 // caution, and only for optimization purposes.  The node being passed
00543 // in had better have been allocated by the tree that is unbinding it.
00544 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00545 ACE_INLINE int
00546 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::unbind (ACE_RB_Tree_Node<EXT_ID, INT_ID> *entry)
00547 {
00548   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::unbind (ACE_RB_Tree_Node<EXT_ID, INT_ID> *entry)");
00549   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00550 
00551   return this->remove_i (entry);
00552 }
00553 
00554 
00555 // Returns a reference to the underlying <ACE_LOCK>.  This makes it
00556 // possible to acquire the lock explicitly, which can be useful in
00557 // some cases if you instantiate the <ACE_Atomic_Op> with an
00558 // <ACE_Recursive_Mutex> or <ACE_Process_Mutex>, or if you need to
00559 // guard the state of an iterator.  NOTE: the right name would be
00560 // <lock>, but HP/C++ will choke on that!
00561 
00562 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00563 ACE_INLINE ACE_LOCK &
00564 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::mutex (void)
00565 {
00566   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::mutex");
00567   return this->lock_;
00568 }
00569 
00570 
00571 // Dump the state of an object.
00572 
00573 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00574 ACE_INLINE void
00575 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump (void) const
00576 {
00577 #if defined (ACE_HAS_DUMP)
00578   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump");
00579   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00580   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("\ncurrent_size_ = %d\n"), this->current_size_));
00581   this->allocator_->dump ();
00582   this->lock_.dump ();
00583   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("\nDumping nodes from root\n")));
00584   this->dump_i (this->root_);
00585   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00586 #endif /* ACE_HAS_DUMP */
00587 }
00588 
00589 
00590 // Return forward iterator positioned at first node in tree.
00591 
00592 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00593 ACE_INLINE ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>
00594 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::begin (void)
00595 {
00596   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::begin");
00597 
00598   return ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> (*this);
00599 }
00600 
00601 
00602 // Return forward iterator positioned at last node in tree.
00603 
00604 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00605 ACE_INLINE ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>
00606 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::end (void)
00607 {
00608   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::end");
00609 
00610   return ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> ();
00611 }
00612 
00613 
00614 // Return reverse iterator positioned at last node in tree.
00615 
00616 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00617 ACE_INLINE ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>
00618 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::rbegin (void)
00619 {
00620   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::rbegin");
00621 
00622   return ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> (*this);
00623 }
00624 
00625 
00626 // Return reverse iterator positioned at first node in tree.
00627 
00628 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00629 ACE_INLINE ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>
00630 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::rend (void)
00631 {
00632   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::rend");
00633 
00634   return ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> ();
00635 }
00636 
00637 
00638 // Returns a pointer to the item corresponding to the given key,
00639 // or 0 if it cannot find the key in the tree.  DEPRECATED.
00640 
00641 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00642 ACE_INLINE INT_ID*
00643 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find (const EXT_ID &k)
00644 {
00645   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::find (const EXT_ID &k)");
00646 
00647   // The reinterpret cast is to ensure that when this deprecated
00648   // method is removed, and is replaced (as planned) by a find method
00649   // that takes the same argument signature but returns an int, that
00650   // the compiler will cough if this return macro is not changed to
00651   // just return an int (whose value will be -1).  Please leave this
00652   // as is.
00653   ACE_READ_GUARD_RETURN (ACE_LOCK,
00654                          ace_mon,
00655                          this->lock_,
00656                          reinterpret_cast<INT_ID*> (0L));
00657 
00658   ACE_RB_Tree_Node<EXT_ID, INT_ID> *entry = 0;
00659   int result = this->find_i (k, entry);
00660   return (result == 0) ? &(entry->item ()) : 0;
00661 }
00662 
00663 // Inserts a *copy* of the key and the item into the tree:
00664 // both the key type EXT_ID and the item type INT_ID must have well
00665 // defined semantics for copy construction and < comparison.
00666 // This method returns a pointer to the inserted item copy,
00667 // or 0 if an error occurred.  NOTE: if an identical key
00668 // already exists in the tree, no new item is created, and
00669 // the returned pointer addresses the existing item
00670 // associated with the existing key.   DEPRECATED.
00671 
00672 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00673 ACE_INLINE INT_ID*
00674 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert (const EXT_ID &k, const INT_ID &t)
00675 {
00676   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert");
00677   ACE_WRITE_GUARD_RETURN (ACE_LOCK,
00678                           ace_mon,
00679                           this->lock_,
00680                           reinterpret_cast<INT_ID*> (0L));
00681 
00682   return this->insert_i (k, t);
00683 }
00684 
00685 
00686 // Removes the item associated with the given key from the
00687 // tree and destroys it.  Returns 1 if it found the item
00688 // and successfully destroyed it, 0 if it did not find the
00689 // item, or -1 if an error occurred.  DEPRECATED.
00690 
00691 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00692 ACE_INLINE int
00693 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove (const EXT_ID &k)
00694 {
00695   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove");
00696   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00697 
00698   INT_ID i;
00699   return this->remove_i (k, i);
00700 }
00701 
00702 
00703 // Destroys all nodes and sets the root pointer null.  DEPRECATED
00704 
00705 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00706 ACE_INLINE void
00707 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::clear ()
00708 {
00709   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::clear");
00710   ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_);
00711 
00712   this->close_i ();
00713 }
00714 
00715 // Returns the current number of nodes in the tree.
00716 
00717 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00718 ACE_INLINE size_t
00719 ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::current_size () const
00720 {
00721   ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::current_size");
00722   return current_size_;
00723 }
00724 
00725 
00726 ///////////////////////////////////////////////////////////////////////
00727 // template class                                                    //
00728 // ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> //
00729 ///////////////////////////////////////////////////////////////////////
00730 
00731 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00732 ACE_INLINE
00733 ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (void)
00734   : tree_ (0), node_ (0)
00735 {
00736   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (void)");
00737 }
00738 
00739 // Returns 1 when the iteration has completed, otherwise 0.
00740 
00741 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00742 ACE_INLINE int
00743 ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::done (void) const
00744 {
00745   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::done");
00746 
00747   return node_ ? 0 : 1;
00748 }
00749 
00750 
00751 // STL-like iterator dereference operator: returns a reference
00752 // to the node underneath the iterator.
00753 
00754 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00755 ACE_INLINE ACE_RB_Tree_Node<EXT_ID, INT_ID> &
00756 ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator* (void) const
00757 {
00758   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator*");
00759   return *(this->node_);
00760 }
00761 
00762 
00763 // STL-like iterator dereference operator: returns a reference
00764 // to the node underneath the iterator.
00765 
00766 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00767 ACE_INLINE ACE_RB_Tree_Node<EXT_ID, INT_ID> *
00768 ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator-> (void) const
00769 {
00770   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator->");
00771   return this->node_;
00772 }
00773 
00774 
00775 // Returns a reference to the tree over which we're iterating.
00776 
00777 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>ACE_INLINE const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &
00778 ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::tree (void)
00779 {
00780   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::tree");
00781   return *tree_;
00782 }
00783 
00784 
00785 // Comparison operator: returns 1 if both iterators point to the same position, otherwise 0.
00786 
00787 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00788 ACE_INLINE bool
00789 ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator==
00790   (const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &rbt) const
00791 {
00792   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator==");
00793   return (this->node_ == rbt.node_) ? true : false;
00794 }
00795 
00796 
00797 // Comparison operator: returns 1 if the iterators point to different positions, otherwise 0.
00798 
00799 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00800 ACE_INLINE bool
00801 ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator!=
00802   (const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &rbt) const
00803 {
00804   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator!=");
00805   return (this->node_ == rbt.node_) ? false : true;
00806 }
00807 
00808 
00809 // Move forward by one element in the tree.  Returns 0 when
00810 // there are no more elements in the tree, otherwise 1.
00811 
00812 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00813 ACE_INLINE int
00814 ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::forward_i (void)
00815 {
00816   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::forward_i");
00817 
00818   if (node_)
00819     {
00820       node_ = tree_->RB_tree_successor (node_);
00821     }
00822 
00823   return node_ ? 1 : 0;
00824 }
00825 
00826 
00827 // Move back by one element in the tree.  Returns 0 when
00828 // there are no more elements in the tree, otherwise 1.
00829 
00830 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00831 ACE_INLINE int
00832 ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::reverse_i (void)
00833 {
00834   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::reverse_i");
00835 
00836   if (node_)
00837     {
00838       node_ = tree_->RB_tree_predecessor (node_);
00839     }
00840 
00841   return node_ ? 1 : 0;
00842 }
00843 
00844 
00845 //////////////////////////////////////////////////////////////////
00846 // template class                                               //
00847 // ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> //
00848 //////////////////////////////////////////////////////////////////
00849 
00850 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00851 ACE_INLINE
00852 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator (void)
00853   : ACE_RB_Tree_Iterator_Base<EXT_ID,INT_ID,COMPARE_KEYS,ACE_LOCK> ()
00854 {
00855   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator (void)");
00856 }
00857 
00858 // Move forward by one element in the tree.  Returns
00859 // 0 when all elements have been seen, else 1.
00860 
00861 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00862 ACE_INLINE int
00863 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::advance (void)
00864 {
00865   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::advance");
00866 
00867   return this->forward_i ();
00868 }
00869 
00870 
00871 // Dump the state of an object.
00872 
00873 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00874 ACE_INLINE void
00875 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump (void) const
00876 {
00877 #if defined (ACE_HAS_DUMP)
00878   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump");
00879 
00880   this->dump_i ();
00881 #endif /* ACE_HAS_DUMP */
00882 }
00883 
00884 
00885 // Prefix advance.
00886 
00887 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00888 ACE_INLINE ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &
00889 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator++ (void)
00890 {
00891   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> operator++ (void)");
00892 
00893   this->forward_i ();
00894   return *this;
00895 }
00896 
00897 
00898 // Postfix advance.
00899 
00900 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00901 ACE_INLINE ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>
00902 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator++ (int)
00903 {
00904   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> operator++ (int)");
00905 
00906   ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> retv (*this);
00907   ++*this;
00908   return retv;
00909 }
00910 
00911 
00912 // Prefix reverse.
00913 
00914 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00915 ACE_INLINE ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &
00916 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator-- (void)
00917 {
00918   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> operator-- (void)");
00919 
00920   this->reverse_i ();
00921   return *this;
00922 }
00923 
00924 
00925 // Postfix reverse.
00926 
00927 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00928 ACE_INLINE ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>
00929 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator-- (int)
00930 {
00931   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> operator-- (int)");
00932 
00933   ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> retv (*this);
00934   --*this;
00935   return retv;
00936 }
00937 
00938 
00939 // Passes back the <entry> under the iterator.  Returns 0 if
00940 // the iteration has completed, otherwise 1.  This method must
00941 // be declared and defined in both the derived forward and
00942 // reverse iterator classes rather than in the base iterator
00943 // class because of a method signature resolution problem
00944 // caused by the existence of the deprecated next (void)
00945 // method in the derived forward iterator class.  When that
00946 // deprecated method is removed, this method should be removed
00947 // from the derived classes and placed in the base class.
00948 
00949 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00950 ACE_INLINE int
00951 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::next (ACE_RB_Tree_Node<EXT_ID, INT_ID> *&next_entry) const
00952 {
00953   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::next");
00954 
00955   if (this->node_)
00956     {
00957       next_entry = this->node_;
00958       return 1;
00959     }
00960 
00961   return 0;
00962 }
00963 
00964 
00965 // Accessor for key of node under iterator (if any). DEPRECATED.
00966 
00967 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00968 ACE_INLINE EXT_ID *
00969 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::key ()
00970 {
00971   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::key");
00972   return this->node_ ? (&(this->node_->key ())) : 0;
00973 }
00974 
00975 
00976 // Accessor for item of node under iterator (if any). DEPRECATED.
00977 
00978 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00979 ACE_INLINE INT_ID *
00980 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::item ()
00981 {
00982   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::item");
00983   return this->node_ ? (&(this->node_->item ())) : 0;
00984 }
00985 
00986 
00987 // Move to the first item in the tree. DEPRECATED.
00988 
00989 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
00990 ACE_INLINE int
00991 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::first ()
00992 {
00993   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::first");
00994   this->node_ = this->tree_->RB_tree_minimum (this->tree_->root_);
00995   return this->node_ ? 1 : 0;
00996 }
00997 
00998 
00999 // Move to the last item in the tree. DEPRECATED.
01000 
01001 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01002 ACE_INLINE int
01003 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::last ()
01004 {
01005   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::last");
01006   this->node_ = this->tree_->RB_tree_maximum (this->tree_->root_);
01007   return this->node_ ? 1 : 0;
01008 }
01009 
01010 
01011 // Moves to the next item in the tree,
01012 // returns 1 if there is a next item, 0 otherwise. DEPRECATED.
01013 
01014 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01015 ACE_INLINE int
01016 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::next ()
01017 {
01018   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::next");
01019   this->node_ = this->tree_->RB_tree_successor (this->node_);
01020   return this->node_ ? 1 : 0;
01021 }
01022 
01023 
01024 // Moves to the previous item in the tree,
01025 // returns 1 if there is a previous item, 0 otherwise. DEPRECATED.
01026 
01027 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01028 ACE_INLINE int
01029 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::previous ()
01030 {
01031   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::previous");
01032   this->node_ = this->tree_->RB_tree_predecessor (this->node_);
01033   return this->node_ ? 1 : 0;
01034 }
01035 
01036 
01037 // Returns 0 if the iterator is positioned over a valid ACE_RB_Tree
01038 // node, returns 1 if not. DEPRECATED.
01039 
01040 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01041 ACE_INLINE int
01042 ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::is_done ()
01043 {
01044   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::is_done");
01045   return this->node_ ? 0 : 1;
01046 }
01047 
01048 
01049 //////////////////////////////////////////////////////////////////////////
01050 // template class                                                       //
01051 // ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> //
01052 //////////////////////////////////////////////////////////////////////////
01053 
01054 
01055 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01056 ACE_INLINE
01057 ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Reverse_Iterator (void)
01058   : ACE_RB_Tree_Iterator_Base<EXT_ID,INT_ID,COMPARE_KEYS,ACE_LOCK> ()
01059 {
01060   ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Reverse_Iterator (void)");
01061 }
01062 
01063 // Move forward by one element in the tree.  Returns
01064 // 0 when all elements have been seen, else 1.
01065 
01066 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01067 ACE_INLINE int
01068 ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::advance (void)
01069 {
01070   ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::advance");
01071 
01072   return this->reverse_i ();
01073 }
01074 
01075 
01076 // Dump the state of an object.
01077 
01078 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01079 ACE_INLINE void
01080 ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump (void) const
01081 {
01082 #if defined (ACE_HAS_DUMP)
01083   ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump");
01084 
01085   this->dump_i ();
01086 #endif /* ACE_HAS_DUMP */
01087 }
01088 
01089 
01090 // Prefix advance.
01091 
01092 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01093 ACE_INLINE ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &
01094 ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator++ (void)
01095 {
01096   ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator++ (void)");
01097 
01098   this->reverse_i ();
01099   return *this;
01100 }
01101 
01102 
01103 // Postfix advance.
01104 
01105 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01106 ACE_INLINE ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>
01107 ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator++ (int)
01108 {
01109   ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator++ (int)");
01110 
01111   ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> retv (*this);
01112   ++*this;
01113   return retv;
01114 }
01115 
01116 
01117 // Prefix reverse.
01118 
01119 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01120 ACE_INLINE ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &
01121 ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator-- (void)
01122 {
01123   ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator-- (void)");
01124 
01125   this->forward_i ();
01126   return *this;
01127 }
01128 
01129 
01130 // Postfix reverse.
01131 
01132 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01133 ACE_INLINE ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>
01134 ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator-- (int)
01135 {
01136   ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator-- (int)");
01137 
01138   ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> retv (*this);
01139   --*this;
01140   return retv;
01141 }
01142 
01143 
01144 // Passes back the <entry> under the iterator.  Returns 0 if
01145 // the iteration has completed, otherwise 1.  This method must
01146 // be declared and defined in both the derived forward and
01147 // reverse iterator classes rather than in the base iterator
01148 // class because of a method signature resolution problem
01149 // caused by the existence of the deprecated next (void)
01150 // method in the derived forward iterator class.  When that
01151 // deprecated method is removed, this method should be removed
01152 // from the derived classes and placed in the base class.
01153 
01154 template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
01155 ACE_INLINE int
01156 ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::next (ACE_RB_Tree_Node<EXT_ID, INT_ID> *&next_entry) const
01157 {
01158   ACE_TRACE ("ACE_RB_Tree_Reverse_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::next");
01159 
01160   if (this->node_)
01161     {
01162       next_entry = this->node_;
01163       return 1;
01164     }
01165 
01166   return 0;
01167 }
01168 
01169 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:42:00 2006 for ACE by doxygen 1.3.6