Hash_Map_Manager_T.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Hash_Map_Manager_T.h
00006  *
00007  *  $Id: Hash_Map_Manager_T.h 81549 2008-04-30 21:19:58Z hillj $
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_HASH_MAP_MANAGER_T_H
00014 #define ACE_HASH_MAP_MANAGER_T_H
00015 #include /**/ "ace/pre.h"
00016 
00017 #include /**/ "ace/config-all.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include "ace/Default_Constants.h"
00024 #include "ace/Functor_T.h"
00025 #include "ace/Log_Msg.h"
00026 #include <iterator>
00027 
00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00029 
00030 /**
00031  * @class ACE_Hash_Map_Entry
00032  *
00033  * @brief Define an entry in the hash table.
00034  */
00035 template <class EXT_ID, class INT_ID>
00036 class ACE_Hash_Map_Entry
00037 {
00038 public:
00039   // = Initialization and termination methods.
00040   /// Constructor.
00041   ACE_Hash_Map_Entry (const EXT_ID &ext_id,
00042                       const INT_ID &int_id,
00043                       ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next = 0,
00044                       ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev = 0);
00045 
00046   /// Constructor.
00047   ACE_Hash_Map_Entry (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next,
00048                       ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev);
00049 
00050   /// Destructor.
00051   ~ACE_Hash_Map_Entry (void);
00052 
00053   /// Key accessor.
00054   EXT_ID& key (void);
00055 
00056   /// Item accessor.
00057   INT_ID& item (void);
00058 
00059   /// Key used to look up an entry.
00060   /// @deprecated Use key()
00061   EXT_ID ext_id_;
00062 
00063   /// The contents of the entry itself.
00064   /// @deprecated Use item()
00065   INT_ID int_id_;
00066 
00067   /// Pointer to the next item in the bucket of overflow nodes.
00068   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next_;
00069 
00070   /// Pointer to the prev item in the bucket of overflow nodes.
00071   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev_;
00072 
00073   /// Dump the state of an object.
00074   void dump (void) const;
00075 };
00076 
00077 // Forward decl.
00078 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00079 class ACE_Hash_Map_Iterator_Base_Ex;
00080 
00081 // Forward decl.
00082 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00083 class ACE_Hash_Map_Const_Iterator_Base_Ex;
00084 
00085 // Forward decl.
00086 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00087 class ACE_Hash_Map_Iterator_Ex;
00088 
00089 // Forward decl.
00090 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00091 class ACE_Hash_Map_Const_Iterator_Ex;
00092 
00093 // Forward decl.
00094 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00095 class ACE_Hash_Map_Reverse_Iterator_Ex;
00096 
00097 // Forward decl.
00098 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00099 class ACE_Hash_Map_Const_Reverse_Iterator_Ex;
00100 
00101 // Forward decl.
00102 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00103 class ACE_Hash_Map_Bucket_Iterator;
00104 
00105 // Forward decl.
00106 class ACE_Allocator;
00107 
00108 /**
00109  * @class ACE_Hash_Map_Manager_Ex
00110  *
00111  * @brief Define a map abstraction that efficiently associates
00112  * @c EXT_ID type objects with @c INT_ID type objects.
00113  *
00114  * This implementation of a map uses a hash table.  Key hashing
00115  * is achieved through the @c HASH_KEY object and key comparison is
00116  * achieved through the @c COMPARE_KEYS object.
00117  * This class uses an ACE_Allocator to allocate memory.  The
00118  * user can make this a persistent class by providing an
00119  * ACE_Allocator with a persistable memory pool.
00120  */
00121 
00122 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00123 class ACE_Hash_Map_Manager_Ex
00124 {
00125 public:
00126   friend class ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
00127   friend class ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
00128   friend class ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
00129   friend class ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
00130   friend class ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
00131   friend class ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
00132   friend class ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
00133 
00134   typedef EXT_ID
00135           KEY;
00136   typedef INT_ID
00137           VALUE;
00138   typedef ACE_LOCK lock_type;
00139   typedef ACE_Hash_Map_Entry<EXT_ID, INT_ID>
00140           ENTRY;
00141 
00142   // = ACE-style iterator typedefs.
00143   typedef ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00144           ITERATOR;
00145   typedef ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00146           CONST_ITERATOR;
00147   typedef ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00148           REVERSE_ITERATOR;
00149   typedef ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00150           CONST_REVERSE_ITERATOR;
00151 
00152   // = STL-style iterator typedefs.
00153   typedef ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00154           iterator;
00155   typedef ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00156           const_iterator;
00157   typedef ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00158           reverse_iterator;
00159   typedef ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00160           const_reverse_iterator;
00161 
00162   // = STL-style typedefs/traits.
00163   typedef EXT_ID                             key_type;
00164   typedef INT_ID                             data_type;
00165   typedef ACE_Hash_Map_Entry<EXT_ID, INT_ID> value_type;
00166   typedef value_type &                       reference;
00167   typedef value_type const &                 const_reference;
00168   typedef value_type *                       pointer;
00169   typedef value_type const *                 const_pointer;
00170   typedef ptrdiff_t                          difference_type;
00171   typedef size_t                             size_type;
00172 
00173   // = Initialization and termination methods.
00174 
00175   /**
00176    * Initialize an ACE_Hash_Map_Manager_Ex with a default number of elements.
00177    *
00178    * @param table_alloc is a pointer to a memory allocator used for
00179    *        table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>).
00180    *        If @a table_alloc is 0 it defaults to ACE_Allocator::instance().
00181    * @param entry_alloc is a pointer to an additional allocator for
00182    *        entries, so it should be able to allocate 'size' / chunks
00183    *        of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each.
00184    *        If @a entry_alloc is 0 it defaults to the same allocator as
00185    *        @a table_alloc.
00186    */
00187   ACE_Hash_Map_Manager_Ex (ACE_Allocator *table_alloc = 0,
00188                            ACE_Allocator *entry_alloc = 0);
00189 
00190   /**
00191    * Initialize an ACE_Hash_Map_Manager_Ex with @a size elements.
00192    *
00193    * @param table_alloc is a pointer to a memory allocator used for
00194    *        table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>).
00195    *        If @a table_alloc is 0 it defaults to ACE_Allocator::instance().
00196    * @param entry_alloc is a pointer to an additional allocator for
00197    *        entries, so it should be able to allocate 'size' / chunks
00198    *        of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each.
00199    *        If @a entry_alloc is 0 it defaults to the same allocator as
00200    *        @a table_alloc.
00201    */
00202   ACE_Hash_Map_Manager_Ex (size_t size,
00203                            ACE_Allocator *table_alloc = 0,
00204                            ACE_Allocator *entry_alloc = 0);
00205 
00206   /**
00207    * Initialize an ACE_Hash_Map_Manager_Ex with @a size elements.
00208    * @param table_alloc is a pointer to a memory allocator used for
00209    *        table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>).
00210    *        If @a table_alloc is 0 it defaults to ACE_Allocator::instance().
00211    * @param entry_alloc is a pointer to an additional allocator for
00212    *        entries, so it should be able to allocate 'size' / chunks
00213    *        of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each.
00214    *        If @a entry_alloc is 0 then it defaults to the same allocator as
00215    *        @a table_alloc.
00216    * @return -1 on failure, 0 on success
00217    */
00218 
00219   int open (size_t size = ACE_DEFAULT_MAP_SIZE,
00220             ACE_Allocator *table_alloc = 0,
00221             ACE_Allocator *entry_alloc = 0);
00222 
00223   /// Close down the ACE_Hash_Map_Manager_Ex and release dynamically allocated
00224   /// resources.
00225   int close (void);
00226 
00227   /// Removes all the entries in the ACE_Hash_Map_Manager_Ex.
00228   int unbind_all (void);
00229 
00230   /// Cleanup the ACE_Hash_Map_Manager_Ex.
00231   ~ACE_Hash_Map_Manager_Ex (void);
00232 
00233   /**
00234    * Associate @a item with @a int_id.  If @a item is already in the
00235    * map then the map is not changed.
00236    *
00237    * @retval 0 if a new entry is bound successfully.
00238    * @retval 1 if an attempt is made to bind an existing entry.
00239    * @retval -1 if a failure occurs; check @c errno for more information.
00240    */
00241   int bind (const EXT_ID &item,
00242             const INT_ID &int_id);
00243 
00244   /**
00245    * Same as a normal bind, except the map entry is also passed back
00246    * to the caller.  The entry in this case will either be the newly
00247    * created entry, or the existing one.
00248    */
00249   int bind (const EXT_ID &ext_id,
00250             const INT_ID &int_id,
00251             ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
00252 
00253   /**
00254    * Associate @a ext_id with @a int_id if and only if @a ext_id is not
00255    * in the map.  If @a ext_id is already in the map then the @a int_id
00256    * parameter is assigned the existing value in the map.  Returns 0
00257    * if a new entry is bound successfully, returns 1 if an attempt is
00258    * made to bind an existing entry, and returns -1 if failures occur.
00259    */
00260   int trybind (const EXT_ID &ext_id,
00261                INT_ID &int_id);
00262 
00263   /**
00264    * Same as a normal trybind, except the map entry is also passed
00265    * back to the caller.  The entry in this case will either be the
00266    * newly created entry, or the existing one.
00267    */
00268   int trybind (const EXT_ID &ext_id,
00269                INT_ID &int_id,
00270                ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
00271 
00272   /**
00273    * Reassociate @a ext_id with @a int_id.  If @a ext_id is not in the
00274    * map then behaves just like <bind>.  Returns 0 if a new entry is
00275    * bound successfully, returns 1 if an existing entry was rebound,
00276    * and returns -1 if failures occur.
00277    */
00278   int rebind (const EXT_ID &ext_id,
00279               const INT_ID &int_id);
00280 
00281   /**
00282    * Same as a normal rebind, except the map entry is also passed back
00283    * to the caller.  The entry in this case will either be the newly
00284    * created entry, or the existing one.
00285    */
00286   int rebind (const EXT_ID &ext_id,
00287               const INT_ID &int_id,
00288               ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
00289 
00290   /**
00291    * Associate @a ext_id with @a int_id.  If @a ext_id is not in the map
00292    * then behaves just like <bind>.  Otherwise, store the old value of
00293    * @a int_id into the "out" parameter and rebind the new parameters.
00294    * Returns 0 if a new entry is bound successfully, returns 1 if an
00295    * existing entry was rebound, and returns -1 if failures occur.
00296    */
00297   int rebind (const EXT_ID &ext_id,
00298               const INT_ID &int_id,
00299               INT_ID &old_int_id);
00300 
00301   /**
00302    * Same as a normal rebind, except the map entry is also passed back
00303    * to the caller.  The entry in this case will either be the newly
00304    * created entry, or the existing one.
00305    */
00306   int rebind (const EXT_ID &ext_id,
00307               const INT_ID &int_id,
00308               INT_ID &old_int_id,
00309               ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
00310 
00311   /**
00312    * Associate @a ext_id with @a int_id.  If @a ext_id is not in the map
00313    * then behaves just like <bind>.  Otherwise, store the old values
00314    * of @a ext_id and @a int_id into the "out" parameters and rebind the
00315    * new parameters.  This is very useful if you need to have an
00316    * atomic way of updating ACE_Hash_Map_Entrys and you also need
00317    * full control over memory allocation.  Returns 0 if a new entry is
00318    * bound successfully, returns 1 if an existing entry was rebound,
00319    * and returns -1 if failures occur.
00320    */
00321   int rebind (const EXT_ID &ext_id,
00322               const INT_ID &int_id,
00323               EXT_ID &old_ext_id,
00324               INT_ID &old_int_id);
00325 
00326   /**
00327    * Same as a normal rebind, except the map entry is also passed back
00328    * to the caller.  The entry in this case will either be the newly
00329    * created entry, or the existing one.
00330    */
00331   int rebind (const EXT_ID &ext_id,
00332               const INT_ID &int_id,
00333               EXT_ID &old_ext_id,
00334               INT_ID &old_int_id,
00335               ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
00336 
00337   /// Locate @a ext_id and pass out parameter via @a int_id.
00338   /// Return 0 if found, returns -1 if not found.
00339   int find (const EXT_ID &ext_id,
00340             INT_ID &int_id) const;
00341 
00342   /// Returns 0 if the @a ext_id is in the mapping, otherwise -1.
00343   int find (const EXT_ID &ext_id) const;
00344 
00345   /// Locate @a ext_id and pass out parameter via @a entry.  If found,
00346   /// return 0, returns -1 if not found.
00347   int find (const EXT_ID &ext_id,
00348             ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry) const;
00349 
00350   /// Locate @a ext_id and pass out an iterator that points to its
00351   /// corresponding value.
00352   /**
00353    * @param pos @a pos will be set to @c end() if not found.
00354    */
00355   void find (EXT_ID const & ext_id, iterator & pos) const;
00356 
00357   /**
00358    * Unbind (remove) the @a ext_id from the map.  Don't return the
00359    * @a int_id to the caller (this is useful for collections where the
00360    * @a int_ids are *not* dynamically allocated...)
00361    */
00362   int unbind (const EXT_ID &ext_id);
00363 
00364   /// Break any association of @a ext_id.  Returns the value of @a int_id
00365   /// in case the caller needs to deallocate memory. Return 0 if the
00366   /// unbind was successful, and returns -1 if failures occur.
00367   int unbind (const EXT_ID &ext_id,
00368               INT_ID &int_id);
00369 
00370   /// Remove entry from map.
00371   /**
00372    * This unbind operation is fast relative to those that accept an
00373    * external ID parameter since no map lookup is performed.
00374    *
00375    * @return 0 if the unbind was successful, and -1 if failures
00376    *         occur.
00377    */
00378   int unbind (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry);
00379 
00380   /// Remove entry from map pointed to by @c iterator @a pos.
00381   /**
00382    * This unbind operation is fast relative to those that accept an
00383    * external ID parameter since no map lookup is performed.
00384    *
00385    * @return 0 if the unbind was successful, and -1 if failures
00386    *         occur.
00387    */
00388   int unbind (iterator pos);
00389 
00390   /// Returns the current number of ACE_Hash_Map_Entry objects in the
00391   /// hash table.
00392   size_t current_size (void) const;
00393 
00394   /// Return the size of the array that's used to point to the
00395   /// linked lists of ACE_Hash_Map_Entry objects in the hash table.
00396   size_t total_size (void) const;
00397 
00398   /**
00399    * Returns a reference to the underlying <ACE_LOCK>.  This makes it
00400    * possible to acquire the lock explicitly, which can be useful in
00401    * some cases if you instantiate the ACE_Atomic_Op with an
00402    * ACE_Recursive_Mutex or ACE_Process_Mutex, or if you need to
00403    * guard the state of an iterator.
00404    * @note The right name would be <lock>, but HP/C++ will choke on that!
00405    */
00406   ACE_LOCK &mutex (void);
00407 
00408   /// Dump the state of an object.
00409   void dump (void) const;
00410 
00411   // = STL styled iterator factory functions.
00412 
00413   /// Return forward iterator.
00414   iterator begin (void);
00415   iterator end (void);
00416   const_iterator begin (void) const;
00417   const_iterator end (void) const;
00418 
00419   /// Return reverse iterator.
00420   reverse_iterator rbegin (void);
00421   reverse_iterator rend (void);
00422   const_reverse_iterator rbegin (void) const;
00423   const_reverse_iterator rend (void) const;
00424 
00425 protected:
00426   // = The following methods do the actual work.
00427 
00428   /// Returns 1 if <id1> == <id2>, else 0.  This is defined as a
00429   /// separate method to facilitate template specialization.
00430   int equal (const EXT_ID &id1, const EXT_ID &id2);
00431 
00432   /// Compute the hash value of the @a ext_id.  This is defined as a
00433   /// separate method to facilitate template specialization.
00434   u_long hash (const EXT_ID &ext_id);
00435 
00436   // = These methods assume locks are held by private methods.
00437 
00438   /// Performs bind.  Must be called with locks held.
00439   int bind_i (const EXT_ID &ext_id,
00440               const INT_ID &int_id);
00441 
00442   /// Performs bind.  Must be called with locks held.
00443   int bind_i (const EXT_ID &ext_id,
00444               const INT_ID &int_id,
00445               ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
00446 
00447   /// Performs trybind.  Must be called with locks held.
00448   int trybind_i (const EXT_ID &ext_id,
00449                  INT_ID &int_id);
00450 
00451   /// Performs trybind.  Must be called with locks held.
00452   int trybind_i (const EXT_ID &ext_id,
00453                  INT_ID &int_id,
00454                  ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
00455 
00456   /// Performs rebind.  Must be called with locks held.
00457   int rebind_i (const EXT_ID &ext_id,
00458                 const INT_ID &int_id);
00459 
00460   /// Performs rebind.  Must be called with locks held.
00461   int rebind_i (const EXT_ID &ext_id,
00462                 const INT_ID &int_id,
00463                 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
00464 
00465   /// Performs rebind.  Must be called with locks held.
00466   int rebind_i (const EXT_ID &ext_id,
00467                 const INT_ID &int_id,
00468                 INT_ID &old_int_id);
00469 
00470   /// Performs rebind.  Must be called with locks held.
00471   int rebind_i (const EXT_ID &ext_id,
00472                 const INT_ID &int_id,
00473                 INT_ID &old_int_id,
00474                 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
00475 
00476   /// Performs rebind.  Must be called with locks held.
00477   int rebind_i (const EXT_ID &ext_id,
00478                 const INT_ID &int_id,
00479                 EXT_ID &old_ext_id,
00480                 INT_ID &old_int_id);
00481 
00482   /// Performs rebind.  Must be called with locks held.
00483   int rebind_i (const EXT_ID &ext_id,
00484                 const INT_ID &int_id,
00485                 EXT_ID &old_ext_id,
00486                 INT_ID &old_int_id,
00487                 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
00488 
00489   /// Performs a find of @a int_id using @a ext_id as the key.  Must be
00490   /// called with locks held.
00491   int find_i (const EXT_ID &ext_id,
00492               INT_ID &int_id);
00493 
00494   /// Performs a find using @a ext_id as the key.  Must be called with
00495   /// locks held.
00496   int find_i (const EXT_ID &ext_id);
00497 
00498   /// Performs a find using @a ext_id as the key.  Must be called with
00499   /// locks held.
00500   int find_i (const EXT_ID &ext_id,
00501               ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
00502 
00503   /// Performs unbind.  Must be called with locks held.
00504   int unbind_i (const EXT_ID &ext_id,
00505                 INT_ID &int_id);
00506 
00507   /// Performs unbind.  Must be called with locks held.
00508   int unbind_i (const EXT_ID &ext_id);
00509 
00510   /// Performs unbind.  Must be called with locks held.
00511   int unbind_i (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry);
00512 
00513   /**
00514    * Resize the map.  Must be called with locks held.
00515    * @note This method should never be called more than once or else all the
00516    * hashing will get screwed up as the size will change.
00517    */
00518   int create_buckets (size_t size);
00519 
00520   /// Close down a <Map_Manager_Ex>.  Must be called with
00521   /// locks held.
00522   int close_i (void);
00523 
00524   /// Removes all the entries in <Map_Manager_Ex>.  Must be called with
00525   /// locks held.
00526   int unbind_all_i (void);
00527 
00528   /// Pointer to a memory allocator used for table_, so it should
00529   /// supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>),
00530   ACE_Allocator *table_allocator_;
00531 
00532   /// Addidtional allocator for entries, so it should be able to
00533   /// allocate 'size' / chunks of sizeof(ACE_Hash_Map_Entry<EXT_ID,
00534   /// INT_ID>) bytes each.
00535   ACE_Allocator *entry_allocator_;
00536 
00537   /// Synchronization variable for the MT_SAFE
00538   /// @c ACE_Hash_Map_Manager_Ex.
00539   mutable ACE_LOCK lock_;
00540 
00541   /// Function object used for hashing keys.
00542   HASH_KEY hash_key_;
00543 
00544   /// Function object used for comparing keys.
00545   COMPARE_KEYS compare_keys_;
00546 
00547 protected:
00548   /// Returns the <ACE_Hash_Map_Entry> that corresponds to @a ext_id.
00549   int shared_find (const EXT_ID &ext_id,
00550                    ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry,
00551                    size_t &loc);
00552 
00553   /// Accessor of the underlying table
00554   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *table (void);
00555 
00556   /// Accessor of the current size attribute
00557   size_t cur_size (void) const;
00558 
00559 private:
00560   /**
00561    * Array of <ACE_Hash_Map_Entry> *s, each of which points to an
00562    * <ACE_Hash_Map_Entry> that serves as the beginning of a linked
00563    * list of <EXT_ID>s that hash to that bucket.
00564    */
00565   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *table_;
00566 
00567   /// Total size of the hash table.
00568   size_t total_size_;
00569 
00570   /// Current number of entries in the table
00571   /// @note That this can be larger than <total_size_> due to the
00572   /// bucket chaining).
00573   size_t cur_size_;
00574 
00575   // = Disallow these operations.
00576   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID,  HASH_KEY, COMPARE_KEYS, ACE_LOCK> &))
00577   ACE_UNIMPLEMENTED_FUNC (ACE_Hash_Map_Manager_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID,  HASH_KEY, COMPARE_KEYS, ACE_LOCK> &))
00578 };
00579 
00580 /**
00581  * @class ACE_Hash_Map_Iterator_Base_Ex
00582  *
00583  * @brief Base iterator for the ACE_Hash_Map_Manager_Ex
00584  *
00585  * This class factors out common code from its templatized
00586  * subclasses.
00587  */
00588 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00589 class ACE_Hash_Map_Iterator_Base_Ex
00590 {
00591 public:
00592   // = STL-style typedefs/traits.
00593   typedef ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00594           container_type;
00595 
00596   // = std::iterator_traits typedefs/traits.
00597   typedef typename container_type::value_type      value_type;
00598   typedef typename container_type::reference       reference;
00599   typedef typename container_type::pointer         pointer;
00600   typedef typename container_type::difference_type difference_type;
00601 
00602   // = Initialization method.
00603   /// Contructor.
00604   /**
00605    *  If @a head != @c false, the iterator constructed is positioned
00606    *  at the head of the map.  It is positioned at the end otherwise.
00607    *  @par
00608    */
00609   ACE_Hash_Map_Iterator_Base_Ex (
00610     ACE_Hash_Map_Manager_Ex<EXT_ID,
00611     INT_ID,
00612     HASH_KEY,
00613     COMPARE_KEYS,
00614     ACE_LOCK> &mm,
00615     bool head);
00616 
00617   /// Contructor.
00618   /**
00619    * This constructor positions the iterator to the given @a entry.
00620    */
00621   ACE_Hash_Map_Iterator_Base_Ex (
00622     ACE_Hash_Map_Manager_Ex<EXT_ID,
00623     INT_ID,
00624     HASH_KEY,
00625     COMPARE_KEYS,
00626     ACE_LOCK> & mm,
00627     ACE_Hash_Map_Entry<EXT_ID, INT_ID> * entry,
00628     size_t index);
00629 
00630   // = ITERATION methods.
00631 
00632   /// Pass back the next <entry> that hasn't been seen in the Set.
00633   /// Returns 0 when all items have been seen, else 1.
00634   int next (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&next_entry) const;
00635 
00636   /// Returns 1 when all items have been seen, else 0.
00637   int done (void) const;
00638 
00639   /// Returns a reference to the interal element @c this is pointing to.
00640   ACE_Hash_Map_Entry<EXT_ID, INT_ID>& operator* (void) const;
00641 
00642   /// Returns a pointer to the interal element @c this is pointing to.
00643   ACE_Hash_Map_Entry<EXT_ID, INT_ID>* operator-> (void) const;
00644 
00645   /// Returns reference the Hash_Map_Manager_Ex that is being iterated
00646   /// over.
00647   ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>& map (void);
00648 
00649   /// Check if two iterators point to the same position
00650   bool operator== (const ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
00651   bool operator!= (const ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
00652 
00653   /// Declare the dynamic allocation hooks.
00654   ACE_ALLOC_HOOK_DECLARE;
00655 
00656 protected:
00657   /// Move forward by one element in the set.  Returns 0 when there's
00658   /// no more item in the set after the current items, else 1.
00659   int forward_i (void);
00660 
00661   /// Move backward by one element in the set.  Returns 0 when there's
00662   /// no more item in the set before the current item, else 1.
00663   int reverse_i (void);
00664 
00665   /// Dump the state of an object.
00666   void dump_i (void) const;
00667 
00668   /// Map we are iterating over.
00669   ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *map_man_;
00670 
00671   /// Keeps track of how far we've advanced in the table.
00672   ssize_t index_;
00673 
00674   /// Keeps track of how far we've advanced in a linked list in each
00675   /// table slot.
00676   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next_;
00677 };
00678 
00679 /**
00680  * @class ACE_Hash_Map_Const_Iterator_Base_Ex
00681  *
00682  * @brief Base const iterator for the ACE_Hash_Map_Manager_Ex
00683  *
00684  * This class factors out common code from its templatized
00685  * subclasses.
00686  */
00687 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00688 class ACE_Hash_Map_Const_Iterator_Base_Ex
00689 {
00690 public:
00691   // = STL-style typedefs/traits.
00692   typedef ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00693           container_type;
00694 
00695   // = std::iterator_traits typedefs/traits.
00696   typedef typename container_type::value_type      value_type;
00697   typedef typename container_type::const_reference reference;
00698   typedef typename container_type::const_pointer   pointer;
00699   typedef typename container_type::difference_type difference_type;
00700 
00701   // = Initialization method.
00702   /// Contructor.  If head the iterator constructed is positioned
00703   /// at the head of the map, it is positioned at the end otherwise.
00704   ACE_Hash_Map_Const_Iterator_Base_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
00705                                        bool head);
00706 
00707   // = ITERATION methods.
00708 
00709   /// Pass back the next <entry> that hasn't been seen in the Set.
00710   /// Returns 0 when all items have been seen, else 1.
00711   int next (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&next_entry) const;
00712 
00713   /// Returns 1 when all items have been seen, else 0.
00714   int done (void) const;
00715 
00716   /// Returns a reference to the interal element @c this is pointing to.
00717   ACE_Hash_Map_Entry<EXT_ID, INT_ID>& operator* (void) const;
00718 
00719   /// Returns a pointer to the interal element @c this is pointing to.
00720   ACE_Hash_Map_Entry<EXT_ID, INT_ID>* operator-> (void) const;
00721 
00722   /// Returns reference the Hash_Map_Manager_Ex that is being iterated
00723   /// over.
00724   const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>& map (void);
00725 
00726   /// Check if two iterators point to the same position
00727   bool operator== (const ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
00728   bool operator!= (const ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
00729 
00730   /// Declare the dynamic allocation hooks.
00731   ACE_ALLOC_HOOK_DECLARE;
00732 
00733 protected:
00734   /// Move forward by one element in the set.  Returns 0 when there's
00735   /// no more item in the set after the current items, else 1.
00736   int forward_i (void);
00737 
00738   /// Move backward by one element in the set.  Returns 0 when there's
00739   /// no more item in the set before the current item, else 1.
00740   int reverse_i (void);
00741 
00742   /// Dump the state of an object.
00743   void dump_i (void) const;
00744 
00745   /// Map we are iterating over.
00746   const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *map_man_;
00747 
00748   /// Keeps track of how far we've advanced in the table.
00749   ssize_t index_;
00750 
00751   /// Keeps track of how far we've advanced in a linked list in each
00752   /// table slot.
00753   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next_;
00754 };
00755 
00756 /**
00757  * @class ACE_Hash_Map_Iterator_Ex
00758  *
00759  * @brief Forward iterator for the ACE_Hash_Map_Manager_Ex.
00760  *
00761  * This class does not perform any internal locking of the
00762  * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is
00763  * inherently inefficient and/or error-prone within an STL-style
00764  * iterator.  If you require locking, you can explicitly use an
00765  * ACE_Guard or ACE_Read_Guard on the ACE_Hash_Map_Manager_Ex's
00766  * internal lock, which is accessible via its <mutex> method.
00767  */
00768 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00769 class ACE_Hash_Map_Iterator_Ex : public ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00770 {
00771 public:
00772   // = STL-style traits/typedefs
00773   typedef typename ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::container_type
00774           container_type;
00775 
00776   // = STL-style traits/typedefs
00777   typedef std::bidirectional_iterator_tag          iterator_category;
00778   typedef typename container_type::value_type      value_type;
00779   typedef typename container_type::reference       reference;
00780   typedef typename container_type::pointer         pointer;
00781   typedef typename container_type::difference_type difference_type;
00782 
00783   // = Initialization method.
00784   ACE_Hash_Map_Iterator_Ex (ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
00785                             int tail = 0);
00786 
00787   /// Contructor.
00788   /**
00789    * This constructor positions the iterator to the given @a entry.
00790    */
00791   ACE_Hash_Map_Iterator_Ex (
00792     ACE_Hash_Map_Manager_Ex<EXT_ID,
00793     INT_ID,
00794     HASH_KEY,
00795     COMPARE_KEYS,
00796     ACE_LOCK> & mm,
00797     ACE_Hash_Map_Entry<EXT_ID, INT_ID> * entry,
00798     size_t index);
00799 
00800   // = Iteration methods.
00801   /// Move forward by one element in the set.  Returns 0 when all the
00802   /// items in the set have been seen, else 1.
00803   int advance (void);
00804 
00805   /// Dump the state of an object.
00806   void dump (void) const;
00807 
00808   // = STL styled iteration, compare, and reference functions.
00809 
00810   /// Prefix advance.
00811   ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator++ (void);
00812 
00813   /// Postfix advance.
00814   ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator++ (int);
00815 
00816   /// Prefix reverse.
00817   ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator-- (void);
00818 
00819   /// Postfix reverse.
00820   ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator-- (int);
00821 
00822   /// Declare the dynamic allocation hooks.
00823   ACE_ALLOC_HOOK_DECLARE;
00824 };
00825 
00826 /**
00827  * @class ACE_Hash_Map_Const_Iterator_Ex
00828  *
00829  * @brief Const forward iterator for the ACE_Hash_Map_Manager_Ex.
00830  *
00831  * This class does not perform any internal locking of the
00832  * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is
00833  * inherently inefficient and/or error-prone within an STL-style
00834  * iterator.  If you require locking, you can explicitly use an
00835  * ACE_Guard or ACE_Read_Guard on the ACE_Hash_Map_Manager_Ex's
00836  * internal lock, which is accessible via its <mutex> method.
00837  */
00838 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00839 class ACE_Hash_Map_Const_Iterator_Ex : public ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00840 {
00841 public:
00842   // = STL-style traits/typedefs
00843   typedef typename ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::container_type
00844           container_type;
00845 
00846   // = std::iterator_trait traits/typedefs
00847   typedef std::bidirectional_iterator_tag          iterator_category;
00848   typedef typename container_type::value_type      value_type;
00849   typedef typename container_type::reference       reference;
00850   typedef typename container_type::pointer         pointer;
00851   typedef typename container_type::difference_type difference_type;
00852 
00853   // = Initialization method.
00854   ACE_Hash_Map_Const_Iterator_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
00855                                   int tail = 0);
00856 
00857   // = Iteration methods.
00858   /// Move forward by one element in the set.  Returns 0 when all the
00859   /// items in the set have been seen, else 1.
00860   int advance (void);
00861 
00862   /// Dump the state of an object.
00863   void dump (void) const;
00864 
00865   // = STL styled iteration, compare, and reference functions.
00866 
00867   /// Prefix advance.
00868   ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator++ (void);
00869 
00870   /// Postfix advance.
00871   ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator++ (int);
00872 
00873   /// Prefix reverse.
00874   ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator-- (void);
00875 
00876   /// Postfix reverse.
00877   ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator-- (int);
00878 
00879   /// Declare the dynamic allocation hooks.
00880   ACE_ALLOC_HOOK_DECLARE;
00881 };
00882 
00883 /**
00884  * @class ACE_Hash_Map_Bucket_Iterator
00885  *
00886  * @brief Forward iterator for the ACE_Hash_Map_Manager_Ex which
00887  * only traverses a particular bucket.  The particular bucket is
00888  * specified by the <EXT_ID> parameter specified in the constructor.
00889  *
00890  * This class does not perform any internal locking of the
00891  * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is
00892  * inherently inefficient and/or error-prone within an STL-style
00893  * iterator.  If you require locking, you can explicitly use an
00894  * ACE_Guard or ACE_Read_Guard on the ACE_Hash_Map_Manager_Ex's
00895  * internal lock, which is accessible via its <mutex> method.
00896  *
00897  * Note that a creation method for this new iterator cannot be added
00898  * to the hash map, since this would require adding explicit template
00899  * instantiations for bucket iterators on platforms with broken
00900  * templates.
00901  */
00902 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00903 class ACE_Hash_Map_Bucket_Iterator
00904 {
00905 public:
00906   // = STL-style traits/typedefs
00907   typedef ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00908           container_type;
00909 
00910   // = std::iterator traits/typedefs
00911   typedef std::bidirectional_iterator_tag          iterator_category;
00912   typedef typename container_type::value_type      value_type;
00913   typedef typename container_type::reference       reference;
00914   typedef typename container_type::pointer         pointer;
00915   typedef typename container_type::difference_type difference_type;
00916 
00917   // = Initialization method.
00918   ACE_Hash_Map_Bucket_Iterator (ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
00919                                 const EXT_ID &ext_id,
00920                                 int tail = 0);
00921 
00922   // = STL styled iteration, compare, and reference functions.
00923 
00924   /// Prefix advance.
00925   ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator++ (void);
00926 
00927   /// Postfix advance.
00928   ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator++ (int);
00929 
00930   /// Prefix reverse.
00931   ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator-- (void);
00932 
00933   /// Postfix reverse.
00934   ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator-- (int);
00935 
00936   /// Returns a reference to the interal element @c this is pointing to.
00937   ACE_Hash_Map_Entry<EXT_ID, INT_ID>& operator* (void) const;
00938 
00939   /// Returns a pointer to the interal element @c this is pointing to.
00940   ACE_Hash_Map_Entry<EXT_ID, INT_ID>* operator-> (void) const;
00941 
00942   /// Returns reference the Hash_Map_Manager_Ex that is being iterated
00943   /// over.
00944   ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>& map (void);
00945 
00946   /// Check if two iterators point to the same position
00947   bool operator== (const ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
00948   bool operator!= (const ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
00949 
00950 protected:
00951   /// Move forward by one element in the set.  Returns 0 when there's
00952   /// no more item in the set after the current items, else 1.
00953   int forward_i (void);
00954 
00955   /// Move backward by one element in the set.  Returns 0 when there's
00956   /// no more item in the set before the current item, else 1.
00957   int reverse_i (void);
00958 
00959   /// Map we are iterating over.
00960   ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *map_man_;
00961 
00962   /// Keeps track of how far we've advanced in the table.
00963   ssize_t index_;
00964 
00965   /// Keeps track of how far we've advanced in a linked list in each
00966   /// table slot.
00967   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next_;
00968 };
00969 
00970 /**
00971  * @class ACE_Hash_Map_Reverse_Iterator_Ex
00972  *
00973  * @brief Reverse iterator for the ACE_Hash_Map_Manager_Ex.
00974  *
00975  * This class does not perform any internal locking of the
00976  * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is
00977  * inherently inefficient and/or error-prone within an STL-style
00978  * iterator.  If you require locking, you can explicitly use an
00979  * ACE_Guard or ACE_Read_Guard on the ACE_Hash_Map_Manager_Ex's
00980  * internal lock, which is accessible via its <mutex> method.
00981  */
00982 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
00983 class ACE_Hash_Map_Reverse_Iterator_Ex : public ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
00984 {
00985 public:
00986   // = STL-style traits/typedefs
00987   typedef typename ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::container_type
00988           container_type;
00989 
00990   // = std::iterator_traits typedefs
00991   typedef std::bidirectional_iterator_tag          iterator_category;
00992   typedef typename container_type::value_type      value_type;
00993   typedef typename container_type::reference       reference;
00994   typedef typename container_type::pointer         pointer;
00995   typedef typename container_type::difference_type difference_type;
00996 
00997   // = Initialization method.
00998   ACE_Hash_Map_Reverse_Iterator_Ex (ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
00999                                     bool head = false);
01000 
01001   // = Iteration methods.
01002   /// Move forward by one element in the set.  Returns 0 when all the
01003   /// items in the set have been seen, else 1.
01004   int advance (void);
01005 
01006   /// Dump the state of an object.
01007   void dump (void) const;
01008 
01009   // = STL styled iteration, compare, and reference functions.
01010 
01011   /// Prefix reverse.
01012   ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator++ (void);
01013 
01014   /// Postfix reverse.
01015   ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator++ (int);
01016 
01017   /// Prefix advance.
01018   ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator-- (void);
01019 
01020   /// Postfix advance.
01021   ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator-- (int);
01022 
01023   /// Declare the dynamic allocation hooks.
01024   ACE_ALLOC_HOOK_DECLARE;
01025 };
01026 
01027 /**
01028  * @class ACE_Hash_Map_Const_Reverse_Iterator_Ex
01029  *
01030  * @brief Const reverse iterator for the ACE_Hash_Map_Manager_Ex.
01031  *
01032  * This class does not perform any internal locking of the
01033  * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is
01034  * inherently inefficient and/or error-prone within an STL-style
01035  * iterator.  If you require locking, you can explicitly use an
01036  * ACE_Guard or ACE_Read_Guard on the ACE_Hash_Map_Manager_Ex's
01037  * internal lock, which is accessible via its <mutex> method.
01038  */
01039 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
01040 class ACE_Hash_Map_Const_Reverse_Iterator_Ex : public ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
01041 {
01042 public:
01043   // = STL-style traits/typedefs
01044   typedef typename ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::container_type
01045           container_type;
01046 
01047   // = std::iterator_traits typedefs
01048   typedef std::bidirectional_iterator_tag          iterator_category;
01049   typedef typename container_type::value_type      value_type;
01050   typedef typename container_type::reference       reference;
01051   typedef typename container_type::pointer         pointer;
01052   typedef typename container_type::difference_type difference_type;
01053 
01054   // = Initialization method.
01055   ACE_Hash_Map_Const_Reverse_Iterator_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
01056                                           bool head = false);
01057 
01058   // = Iteration methods.
01059   /// Move forward by one element in the set.  Returns 0 when all the
01060   /// items in the set have been seen, else 1.
01061   int advance (void);
01062 
01063   /// Dump the state of an object.
01064   void dump (void) const;
01065 
01066   // = STL styled iteration, compare, and reference functions.
01067 
01068   /// Prefix reverse.
01069   ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator++ (void);
01070 
01071   /// Postfix reverse.
01072   ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator++ (int);
01073 
01074   /// Prefix advance.
01075   ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator-- (void);
01076 
01077   /// Postfix advance.
01078   ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator-- (int);
01079 
01080   /// Declare the dynamic allocation hooks.
01081   ACE_ALLOC_HOOK_DECLARE;
01082 };
01083 
01084 /**
01085  * @class ACE_Hash_Map_Manager
01086  *
01087  * @brief Wrapper for backward compatibility.
01088  *
01089  * This implementation of a map uses a hash table.  This class
01090  * expects that the <EXT_ID> contains a method called <hash>.
01091  * In addition, the <EXT_ID> must support <operator==>.  Both of
01092  * these constraints can be alleviated via template
01093  * specialization, as shown in the $ACE_ROOT/tests/Conn_Test.cpp
01094  * test.
01095  *
01096  * <b> Requirements and Performance Characteristics</b>
01097  *   - Internal Structure
01098  *       Hash Table
01099  *   - Duplicates allowed?
01100  *       No
01101  *   - Random access allowed?
01102  *       Yes
01103  *   - Search speed
01104  *       O(1)
01105  *   - Insert/replace speed
01106  *       O(1), can be longer if the hash map has to resize
01107  *   - Iterator still valid after change to container?
01108  *       Yes
01109  *   - Frees memory for removed elements?
01110  *       Yes
01111  *   - Items inserted by
01112  *       Value
01113  *   - Requirements for key type
01114  *       -# Default constructor
01115  *       -# Copy constructor
01116  *       -# operator=
01117  *       -# operator==
01118  *   - Requirements for object type
01119  *       -# Default constructor
01120  *       -# Copy constructor
01121  *       -# operator=
01122  *       -# operator<
01123  */
01124 template <class EXT_ID, class INT_ID, class ACE_LOCK>
01125 class ACE_Hash_Map_Manager : public ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>
01126 {
01127 public:
01128 
01129   /**
01130    * Initialize a @c Hash_Map_Manager with default size elements.
01131    * @param table_alloc is a pointer to a memory allocator used for
01132    *        table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>).
01133    * @param entry_alloc is a pointer to an additional allocator for
01134    *        entries, so it should be able to allocate 'size' / chunks
01135    *        of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each.
01136    * If @c table_alloc is 0 it defaults to @c ACE_Allocator::instance().
01137    * If @c entry_alloc is 0 then it defaults to the same allocator as
01138    * @c table_alloc.
01139    */
01140   ACE_Hash_Map_Manager (ACE_Allocator *table_alloc = 0,
01141                         ACE_Allocator *entry_alloc = 0);
01142 
01143   /**
01144    * Initialize a @c Hash_Map_Manager with @c size elements.
01145    * @param table_alloc is a pointer to a memory allocator used for
01146    *        table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>).
01147    * @param entry_alloc is a pointer to an additional allocator for
01148    *        entries, so it should be able to allocate 'size' / chunks
01149    *        of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each.
01150    * If @c table_alloc is 0 it defaults to @c ACE_Allocator::instance().
01151    * If @c entry_alloc is 0 then it defaults to the same allocator as
01152    * @c table_alloc.
01153    */
01154   ACE_Hash_Map_Manager (size_t size,
01155                         ACE_Allocator *table_alloc = 0,
01156                         ACE_Allocator *entry_alloc = 0);
01157 
01158   // = The following two are necessary for template specialization of
01159   // ACE_Hash_Map_Manager to work.
01160   int equal (const EXT_ID &id1, const EXT_ID &id2);
01161   u_long hash (const EXT_ID &ext_id);
01162 };
01163 
01164 /**
01165  * @class ACE_Hash_Map_Iterator
01166  *
01167  * @brief Wrapper for backward compatibility.
01168  */
01169 template <class EXT_ID, class INT_ID, class ACE_LOCK>
01170 class ACE_Hash_Map_Iterator : public ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>
01171 {
01172 public:
01173   // = STL-style traits/typedefs
01174   typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::container_type
01175           container_type;
01176 
01177   typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::iterator_category
01178           iterator_category;
01179 
01180   typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::value_type         
01181           value_type;  
01182   
01183   typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::reference          
01184           reference;
01185 
01186   typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::pointer           
01187           pointer;
01188   
01189   typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::difference_type
01190           difference_type;
01191 
01192   // = Initialization method.
01193   /// Construct from map
01194   ACE_Hash_Map_Iterator (ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &mm,
01195                          int tail = 0);
01196 
01197   /// Construct from base
01198   ACE_Hash_Map_Iterator (const ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base);
01199 
01200   /// Assignment from base
01201   ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> &
01202   operator= (const ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base);
01203 };
01204 
01205 /**
01206  * @class ACE_Hash_Map_Const_Iterator
01207  *
01208  * @brief Wrapper for backward compatibility.
01209  */
01210 template <class EXT_ID, class INT_ID, class ACE_LOCK>
01211 class ACE_Hash_Map_Const_Iterator : public ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>
01212 {
01213 public:
01214   // = STL-style traits/typedefs
01215   typedef typename ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::container_type
01216           container_type;
01217 
01218   // = std::iterator_traits typedefs
01219   typedef typename ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::iterator_category 
01220           iterator_category;
01221 
01222   typedef typename ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::value_type        
01223           value_type;
01224 
01225   typedef typename ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::reference         
01226           reference;
01227 
01228   typedef typename ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::pointer           
01229           pointer;
01230 
01231   typedef typename ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::difference_type   
01232           difference_type;
01233 
01234   // = Initialization method.
01235   /// Construct from map
01236   ACE_Hash_Map_Const_Iterator (const ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &mm,
01237                                int tail = 0);
01238 
01239   /// Construct from base
01240   ACE_Hash_Map_Const_Iterator (const ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base);
01241 
01242   /// Assignment from base
01243   ACE_Hash_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> &
01244   operator= (const ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base);
01245 };
01246 
01247 /**
01248  * @class ACE_Hash_Map_Reverse_Iterator
01249  *
01250  * @brief Wrapper for backward compatibility.
01251  */
01252 template <class EXT_ID, class INT_ID, class ACE_LOCK>
01253 class ACE_Hash_Map_Reverse_Iterator : public ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>
01254 {
01255 public:
01256   // = STL-style traits/typedefs
01257   typedef typename ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::container_type
01258           container_type;
01259 
01260   // = std::iterator_traits typedefs
01261   typedef typename ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::iterator_category 
01262           iterator_category;
01263 
01264   typedef typename ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::value_type        
01265           value_type;
01266 
01267   typedef typename ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::reference         
01268           reference;
01269 
01270   typedef typename ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::pointer           
01271           pointer;
01272 
01273   typedef typename ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::difference_type   
01274           difference_type;
01275 
01276   // = Initialization method.
01277   ACE_Hash_Map_Reverse_Iterator (ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &mm,
01278                                  bool head = false);
01279 
01280   /// Construct from base
01281   ACE_Hash_Map_Reverse_Iterator (const ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base);
01282 
01283   /// Assignment from base
01284   ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> &
01285   operator= (const ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base);
01286 };
01287 
01288 ACE_END_VERSIONED_NAMESPACE_DECL
01289 
01290 #if defined (__ACE_INLINE__)
01291 #  include "ace/Hash_Map_Manager_T.inl"
01292 #endif /* __ACE_INLINE__ */
01293 
01294 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
01295 #include "ace/Hash_Map_Manager_T.cpp"
01296 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
01297 
01298 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
01299 #pragma implementation ("Hash_Map_Manager_T.cpp")
01300 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
01301 
01302 #include /**/ "ace/post.h"
01303 #endif /* ACE_HASH_MAP_MANAGER_T_H */

Generated on Tue Feb 2 17:18:39 2010 for ACE by  doxygen 1.4.7