Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

RB_Tree.i

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

Generated on Mon Jun 16 11:21:00 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002