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

Generated on Sun Jan 27 12:05:26 2008 for ACE by doxygen 1.3.6