Document return values
[ACE_TAO.git] / ACE / ace / Hash_Map_Manager_T.h
blob045c2935020d00a5cb8b0e64552de9614116356e
1 // // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Hash_Map_Manager_T.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
9 //=============================================================================
11 #ifndef ACE_HASH_MAP_MANAGER_T_H
12 #define ACE_HASH_MAP_MANAGER_T_H
13 #include /**/ "ace/pre.h"
15 #include /**/ "ace/config-all.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Default_Constants.h"
22 #include "ace/Functor_T.h"
23 #include "ace/Log_Category.h"
24 #include <iterator>
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 /**
29 * @class ACE_Hash_Map_Entry
31 * @brief Define an entry in the hash table.
33 template <class EXT_ID, class INT_ID>
34 class ACE_Hash_Map_Entry
36 public:
37 /// Constructor.
38 ACE_Hash_Map_Entry (const EXT_ID &ext_id,
39 const INT_ID &int_id,
40 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next = 0,
41 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev = 0);
43 /// Constructor.
44 ACE_Hash_Map_Entry (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next,
45 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev);
47 /// Destructor.
48 ~ACE_Hash_Map_Entry ();
50 /// Key accessor.
51 EXT_ID& key ();
53 /// Read-only key accessor.
54 const EXT_ID& key () const;
56 /// Item accessor.
57 INT_ID& item ();
59 /// Read-only item accessor.
60 const INT_ID& item () const;
62 /// Key used to look up an entry.
63 /// @deprecated Use key()
64 EXT_ID ext_id_;
66 /// The contents of the entry itself.
67 /// @deprecated Use item()
68 INT_ID int_id_;
70 /// Pointer to the next item in the bucket of overflow nodes.
71 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next_;
73 /// Pointer to the prev item in the bucket of overflow nodes.
74 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev_;
76 /// Dump the state of an object.
77 void dump () const;
80 // Forward decl.
81 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
82 class ACE_Hash_Map_Iterator_Base_Ex;
84 // Forward decl.
85 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
86 class ACE_Hash_Map_Const_Iterator_Base_Ex;
88 // Forward decl.
89 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
90 class ACE_Hash_Map_Iterator_Ex;
92 // Forward decl.
93 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
94 class ACE_Hash_Map_Const_Iterator_Ex;
96 // Forward decl.
97 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
98 class ACE_Hash_Map_Reverse_Iterator_Ex;
100 // Forward decl.
101 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
102 class ACE_Hash_Map_Const_Reverse_Iterator_Ex;
104 // Forward decl.
105 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
106 class ACE_Hash_Map_Bucket_Iterator;
108 // Forward decl.
109 class ACE_Allocator;
112 * @class ACE_Hash_Map_Manager_Ex
114 * @brief Define a map abstraction that efficiently associates
115 * @c EXT_ID type objects with @c INT_ID type objects.
117 * This implementation of a map uses a hash table. Key hashing
118 * is achieved through the @c HASH_KEY object and key comparison is
119 * achieved through the @c COMPARE_KEYS object.
120 * This class uses an ACE_Allocator to allocate memory. The
121 * user can make this a persistent class by providing an
122 * ACE_Allocator with a persistable memory pool.
125 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
126 class ACE_Hash_Map_Manager_Ex
128 public:
129 friend class ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
130 friend class ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
131 friend class ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
132 friend class ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
133 friend class ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
134 friend class ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
135 friend class ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
137 typedef EXT_ID
138 KEY;
139 typedef INT_ID
140 VALUE;
141 typedef ACE_LOCK lock_type;
142 typedef ACE_Hash_Map_Entry<EXT_ID, INT_ID>
143 ENTRY;
145 // = ACE-style iterator typedefs.
146 typedef ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
147 ITERATOR;
148 typedef ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
149 CONST_ITERATOR;
150 typedef ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
151 REVERSE_ITERATOR;
152 typedef ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
153 CONST_REVERSE_ITERATOR;
155 // = STL-style iterator typedefs.
156 typedef ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
157 iterator;
158 typedef ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
159 const_iterator;
160 typedef ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
161 reverse_iterator;
162 typedef ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
163 const_reverse_iterator;
165 // = STL-style typedefs/traits.
166 typedef EXT_ID key_type;
167 typedef INT_ID data_type;
168 typedef ACE_Hash_Map_Entry<EXT_ID, INT_ID> value_type;
169 typedef value_type & reference;
170 typedef value_type const & const_reference;
171 typedef value_type * pointer;
172 typedef value_type const * const_pointer;
173 typedef ptrdiff_t difference_type;
174 typedef size_t size_type;
177 * Initialize an ACE_Hash_Map_Manager_Ex with a default number of elements.
179 * @param table_alloc is a pointer to a memory allocator used for
180 * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>).
181 * If @a table_alloc is 0 it defaults to ACE_Allocator::instance().
182 * @param entry_alloc is a pointer to an additional allocator for
183 * entries, so it should be able to allocate 'size' / chunks
184 * of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each.
185 * If @a entry_alloc is 0 it defaults to the same allocator as
186 * @a table_alloc.
188 ACE_Hash_Map_Manager_Ex (ACE_Allocator *table_alloc = 0,
189 ACE_Allocator *entry_alloc = 0);
192 * Initialize an ACE_Hash_Map_Manager_Ex with @a size elements.
194 * @param table_alloc is a pointer to a memory allocator used for
195 * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>).
196 * If @a table_alloc is 0 it defaults to ACE_Allocator::instance().
197 * @param entry_alloc is a pointer to an additional allocator for
198 * entries, so it should be able to allocate 'size' / chunks
199 * of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each.
200 * If @a entry_alloc is 0 it defaults to the same allocator as
201 * @a table_alloc.
203 ACE_Hash_Map_Manager_Ex (size_t size,
204 ACE_Allocator *table_alloc = 0,
205 ACE_Allocator *entry_alloc = 0);
208 * Initialize an ACE_Hash_Map_Manager_Ex with @a size elements.
209 * @param table_alloc is a pointer to a memory allocator used for
210 * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>).
211 * If @a table_alloc is 0 it defaults to ACE_Allocator::instance().
212 * @param entry_alloc is a pointer to an additional allocator for
213 * entries, so it should be able to allocate 'size' / chunks
214 * of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each.
215 * If @a entry_alloc is 0 then it defaults to the same allocator as
216 * @a table_alloc.
217 * @return -1 on failure, 0 on success
220 int open (size_t size = ACE_DEFAULT_MAP_SIZE,
221 ACE_Allocator *table_alloc = 0,
222 ACE_Allocator *entry_alloc = 0);
224 /// Close down the ACE_Hash_Map_Manager_Ex and release dynamically allocated
225 /// resources.
226 int close ();
228 /// Removes all the entries in the ACE_Hash_Map_Manager_Ex.
229 int unbind_all ();
231 /// Cleanup the ACE_Hash_Map_Manager_Ex.
232 ~ACE_Hash_Map_Manager_Ex ();
235 * Associate @a item with @a int_id. If @a item is already in the
236 * map then the map is not changed.
238 * @retval 0 if a new entry is bound successfully.
239 * @retval 1 if an attempt is made to bind an existing entry.
240 * @retval -1 if a failure occurs; check @c errno for more information.
242 int bind (const EXT_ID &item,
243 const INT_ID &int_id);
246 * Same as a normal bind, except the map entry is also passed back
247 * to the caller. The entry in this case will either be the newly
248 * created entry, or the existing one.
250 int bind (const EXT_ID &ext_id,
251 const INT_ID &int_id,
252 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
255 * Associate @a ext_id with @a int_id if and only if @a ext_id is not
256 * in the map. If @a ext_id is already in the map then the @a int_id
257 * parameter is assigned the existing value in the map. Returns 0
258 * if a new entry is bound successfully, returns 1 if an attempt is
259 * made to bind an existing entry, and returns -1 if failures occur.
261 int trybind (const EXT_ID &ext_id,
262 INT_ID &int_id);
265 * Same as a normal trybind, except the map entry is also passed
266 * back to the caller. The entry in this case will either be the
267 * newly created entry, or the existing one.
269 int trybind (const EXT_ID &ext_id,
270 INT_ID &int_id,
271 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
274 * Reassociate @a ext_id with @a int_id. If @a ext_id is not in the
275 * map then behaves just like <bind>. Returns 0 if a new entry is
276 * bound successfully, returns 1 if an existing entry was rebound,
277 * and returns -1 if failures occur.
279 int rebind (const EXT_ID &ext_id,
280 const INT_ID &int_id);
283 * Same as a normal rebind, except the map entry is also passed back
284 * to the caller. The entry in this case will either be the newly
285 * created entry, or the existing one.
287 int rebind (const EXT_ID &ext_id,
288 const INT_ID &int_id,
289 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
292 * Associate @a ext_id with @a int_id. If @a ext_id is not in the map
293 * then behaves just like <bind>. Otherwise, store the old value of
294 * @a int_id into the "out" parameter and rebind the new parameters.
295 * Returns 0 if a new entry is bound successfully, returns 1 if an
296 * existing entry was rebound, and returns -1 if failures occur.
298 int rebind (const EXT_ID &ext_id,
299 const INT_ID &int_id,
300 INT_ID &old_int_id);
303 * Same as a normal rebind, except the map entry is also passed back
304 * to the caller. The entry in this case will either be the newly
305 * created entry, or the existing one.
307 int rebind (const EXT_ID &ext_id,
308 const INT_ID &int_id,
309 INT_ID &old_int_id,
310 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
313 * Associate @a ext_id with @a int_id. If @a ext_id is not in the map
314 * then behaves just like <bind>. Otherwise, store the old values
315 * of @a ext_id and @a int_id into the "out" parameters and rebind the
316 * new parameters. This is very useful if you need to have an
317 * atomic way of updating ACE_Hash_Map_Entrys and you also need
318 * full control over memory allocation. Returns 0 if a new entry is
319 * bound successfully, returns 1 if an existing entry was rebound,
320 * and returns -1 if failures occur.
322 int rebind (const EXT_ID &ext_id,
323 const INT_ID &int_id,
324 EXT_ID &old_ext_id,
325 INT_ID &old_int_id);
328 * Same as a normal rebind, except the map entry is also passed back
329 * to the caller. The entry in this case will either be the newly
330 * created entry, or the existing one.
332 int rebind (const EXT_ID &ext_id,
333 const INT_ID &int_id,
334 EXT_ID &old_ext_id,
335 INT_ID &old_int_id,
336 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
338 /// Locate @a ext_id and pass out parameter via @a int_id.
339 /// Return 0 if found, returns -1 if not found.
340 int find (const EXT_ID &ext_id,
341 INT_ID &int_id) const;
343 /// Returns 0 if the @a ext_id is in the mapping, otherwise -1.
344 int find (const EXT_ID &ext_id) const;
346 /// Locate @a ext_id and pass out parameter via @a entry. If found,
347 /// return 0, returns -1 if not found.
348 int find (const EXT_ID &ext_id,
349 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry) const;
351 /// Locate @a ext_id and pass out an iterator that points to its
352 /// corresponding value.
354 * @param pos @a pos will be set to @c end() if not found.
356 void find (EXT_ID const & ext_id, iterator & pos) const;
359 * Unbind (remove) the @a ext_id from the map. Don't return the
360 * @a int_id to the caller (this is useful for collections where the
361 * @a int_ids are *not* dynamically allocated...)
363 int unbind (const EXT_ID &ext_id);
365 /// Break any association of @a ext_id. Returns the value of @a int_id
366 /// in case the caller needs to deallocate memory. Return 0 if the
367 /// unbind was successful, and returns -1 if failures occur.
368 int unbind (const EXT_ID &ext_id,
369 INT_ID &int_id);
371 /// Remove entry from map.
373 * This unbind operation is fast relative to those that accept an
374 * external ID parameter since no map lookup is performed.
376 * @return 0 if the unbind was successful, and -1 if failures
377 * occur.
379 int unbind (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry);
381 /// Remove entry from map pointed to by @c iterator @a pos.
383 * This unbind operation is fast relative to those that accept an
384 * external ID parameter since no map lookup is performed.
386 * @return 0 if the unbind was successful, and -1 if failures
387 * occur.
389 int unbind (iterator pos);
391 /// Returns the current number of ACE_Hash_Map_Entry objects in the
392 /// hash table.
393 size_t current_size () const;
395 /// Return the size of the array that's used to point to the
396 /// linked lists of ACE_Hash_Map_Entry objects in the hash table.
397 size_t total_size () const;
400 * Returns a reference to the underlying <ACE_LOCK>. This makes it
401 * possible to acquire the lock explicitly, which can be useful in
402 * some cases if you instantiate the ACE_Atomic_Op with an
403 * ACE_Recursive_Mutex or ACE_Process_Mutex, or if you need to
404 * guard the state of an iterator.
405 * @note The right name would be <lock>, but HP/C++ will choke on that!
407 ACE_LOCK &mutex ();
409 /// Dump the state of an object.
410 void dump () const;
412 // = STL styled iterator factory functions.
414 /// Return forward iterator.
415 iterator begin ();
416 iterator end ();
417 const_iterator begin () const;
418 const_iterator end () const;
420 /// Return reverse iterator.
421 reverse_iterator rbegin ();
422 reverse_iterator rend ();
423 const_reverse_iterator rbegin () const;
424 const_reverse_iterator rend () const;
426 /// Declare the dynamic allocation hooks.
427 ACE_ALLOC_HOOK_DECLARE;
429 protected:
430 // = The following methods do the actual work.
432 /// Returns 1 if <id1> == <id2>, else 0. This is defined as a
433 /// separate method to facilitate template specialization.
434 int equal (const EXT_ID &id1, const EXT_ID &id2);
436 /// Compute the hash value of the @a ext_id. This is defined as a
437 /// separate method to facilitate template specialization.
438 u_long hash (const EXT_ID &ext_id);
440 // = These methods assume locks are held by private methods.
442 /// Performs bind. Must be called with locks held.
443 int bind_i (const EXT_ID &ext_id,
444 const INT_ID &int_id);
446 /// Performs bind. Must be called with locks held.
447 int bind_i (const EXT_ID &ext_id,
448 const INT_ID &int_id,
449 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
451 /// Performs trybind. Must be called with locks held.
452 int trybind_i (const EXT_ID &ext_id,
453 INT_ID &int_id);
455 /// Performs trybind. Must be called with locks held.
456 int trybind_i (const EXT_ID &ext_id,
457 INT_ID &int_id,
458 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
460 /// Performs rebind. Must be called with locks held.
461 int rebind_i (const EXT_ID &ext_id,
462 const INT_ID &int_id);
464 /// Performs rebind. Must be called with locks held.
465 int rebind_i (const EXT_ID &ext_id,
466 const INT_ID &int_id,
467 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
469 /// Performs rebind. Must be called with locks held.
470 int rebind_i (const EXT_ID &ext_id,
471 const INT_ID &int_id,
472 INT_ID &old_int_id);
474 /// Performs rebind. Must be called with locks held.
475 int rebind_i (const EXT_ID &ext_id,
476 const INT_ID &int_id,
477 INT_ID &old_int_id,
478 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
480 /// Performs rebind. Must be called with locks held.
481 int rebind_i (const EXT_ID &ext_id,
482 const INT_ID &int_id,
483 EXT_ID &old_ext_id,
484 INT_ID &old_int_id);
486 /// Performs rebind. Must be called with locks held.
487 int rebind_i (const EXT_ID &ext_id,
488 const INT_ID &int_id,
489 EXT_ID &old_ext_id,
490 INT_ID &old_int_id,
491 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
493 /// Performs a find of @a int_id using @a ext_id as the key. Must be
494 /// called with locks held.
495 int find_i (const EXT_ID &ext_id,
496 INT_ID &int_id);
498 /// Performs a find using @a ext_id as the key. Must be called with
499 /// locks held.
500 int find_i (const EXT_ID &ext_id);
502 /// Performs a find using @a ext_id as the key. Must be called with
503 /// locks held.
504 int find_i (const EXT_ID &ext_id,
505 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
507 /// Performs unbind. Must be called with locks held.
508 int unbind_i (const EXT_ID &ext_id,
509 INT_ID &int_id);
511 /// Performs unbind. Must be called with locks held.
512 int unbind_i (const EXT_ID &ext_id);
514 /// Performs unbind. Must be called with locks held.
515 int unbind_i (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry);
518 * Resize the map. Must be called with locks held.
519 * @note This method should never be called more than once or else all the
520 * hashing will get screwed up as the size will change.
522 int create_buckets (size_t size);
524 /// Close down a <Map_Manager_Ex>. Must be called with
525 /// locks held.
526 int close_i ();
528 /// Removes all the entries in <Map_Manager_Ex>. Must be called with
529 /// locks held.
530 int unbind_all_i ();
532 /// Pointer to a memory allocator used for table_, so it should
533 /// supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>),
534 ACE_Allocator *table_allocator_;
536 /// Addidtional allocator for entries, so it should be able to
537 /// allocate 'size' / chunks of sizeof(ACE_Hash_Map_Entry<EXT_ID,
538 /// INT_ID>) bytes each.
539 ACE_Allocator *entry_allocator_;
541 /// Synchronization variable for the MT_SAFE
542 /// @c ACE_Hash_Map_Manager_Ex.
543 mutable ACE_LOCK lock_;
545 /// Function object used for hashing keys.
546 HASH_KEY hash_key_;
548 /// Function object used for comparing keys.
549 COMPARE_KEYS compare_keys_;
551 protected:
552 /// Returns the ACE_Hash_Map_Entry that corresponds to @a ext_id.
553 int shared_find (const EXT_ID &ext_id,
554 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry,
555 size_t &loc);
557 /// Accessor of the underlying table
558 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *table ();
560 private:
562 * Array of ACE_Hash_Map_Entry *s, each of which points to an
563 * ACE_Hash_Map_Entry that serves as the beginning of a linked
564 * list of <EXT_ID>s that hash to that bucket.
566 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *table_;
568 /// Total size of the hash table.
569 size_t total_size_;
571 /// Current number of entries in the table
572 /// @note That this can be larger than <total_size_> due to the
573 /// bucket chaining).
574 size_t cur_size_;
576 // = Disallow these operations.
577 void operator= (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) = delete;
578 ACE_Hash_Map_Manager_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) = delete;
582 * @class ACE_Hash_Map_Iterator_Base_Ex
584 * @brief Base iterator for the ACE_Hash_Map_Manager_Ex
586 * This class factors out common code from its templatized
587 * subclasses.
589 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
590 class ACE_Hash_Map_Iterator_Base_Ex
592 public:
593 // = STL-style typedefs/traits.
594 typedef ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
595 container_type;
597 // = std::iterator_traits typedefs/traits.
598 typedef typename container_type::value_type value_type;
599 typedef typename container_type::reference reference;
600 typedef typename container_type::pointer pointer;
601 typedef typename container_type::difference_type difference_type;
603 /// Constructor.
605 * If @a head != @c false, the iterator constructed is positioned
606 * at the head of the map. It is positioned at the end otherwise.
607 * @par
609 ACE_Hash_Map_Iterator_Base_Ex (
610 ACE_Hash_Map_Manager_Ex<EXT_ID,
611 INT_ID,
612 HASH_KEY,
613 COMPARE_KEYS,
614 ACE_LOCK> &mm,
615 bool head);
617 /// Constructor.
619 * This constructor positions the iterator to the given @a entry.
621 ACE_Hash_Map_Iterator_Base_Ex (
622 ACE_Hash_Map_Manager_Ex<EXT_ID,
623 INT_ID,
624 HASH_KEY,
625 COMPARE_KEYS,
626 ACE_LOCK> & mm,
627 ACE_Hash_Map_Entry<EXT_ID, INT_ID> * entry,
628 size_t index);
630 // = ITERATION methods.
632 /// Pass back the next <entry> that hasn't been seen in the Set.
633 /// Returns 0 when all items have been seen, else 1.
634 int next (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&next_entry) const;
636 /// Returns 1 when all items have been seen, else 0.
637 int done () const;
639 /// Returns a reference to the interal element @c this is pointing to.
640 ACE_Hash_Map_Entry<EXT_ID, INT_ID>& operator* () const;
642 /// Returns a pointer to the interal element @c this is pointing to.
643 ACE_Hash_Map_Entry<EXT_ID, INT_ID>* operator-> () const;
645 /// Returns reference the Hash_Map_Manager_Ex that is being iterated
646 /// over.
647 ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>& map ();
649 /// Check if two iterators point to the same position
650 bool operator== (const ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
651 bool operator!= (const ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
653 /// Declare the dynamic allocation hooks.
654 ACE_ALLOC_HOOK_DECLARE;
656 protected:
657 /// Move forward by one element in the set. Returns 0 when there's
658 /// no more item in the set after the current items, else 1.
659 int forward_i ();
661 /// Move backward by one element in the set. Returns 0 when there's
662 /// no more item in the set before the current item, else 1.
663 int reverse_i ();
665 /// Dump the state of an object.
666 void dump_i () const;
668 /// Map we are iterating over.
669 ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *map_man_;
671 /// Keeps track of how far we've advanced in the table.
672 ssize_t index_;
674 /// Keeps track of how far we've advanced in a linked list in each
675 /// table slot.
676 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next_;
680 * @class ACE_Hash_Map_Const_Iterator_Base_Ex
682 * @brief Base const iterator for the ACE_Hash_Map_Manager_Ex
684 * This class factors out common code from its templatized
685 * subclasses.
687 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
688 class ACE_Hash_Map_Const_Iterator_Base_Ex
690 public:
691 // = STL-style typedefs/traits.
692 typedef ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
693 container_type;
695 // = std::iterator_traits typedefs/traits.
696 typedef typename container_type::value_type value_type;
697 typedef typename container_type::const_reference reference;
698 typedef typename container_type::const_pointer pointer;
699 typedef typename container_type::difference_type difference_type;
701 /// Constructor. If head the iterator constructed is positioned
702 /// at the head of the map, it is positioned at the end otherwise.
703 ACE_Hash_Map_Const_Iterator_Base_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
704 bool head);
706 // = ITERATION methods.
708 /// Pass back the next <entry> that hasn't been seen in the Set.
709 /// Returns 0 when all items have been seen, else 1.
710 int next (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&next_entry) const;
712 /// Returns 1 when all items have been seen, else 0.
713 int done () const;
715 /// Returns a reference to the interal element @c this is pointing to.
716 ACE_Hash_Map_Entry<EXT_ID, INT_ID>& operator* () const;
718 /// Returns a pointer to the interal element @c this is pointing to.
719 ACE_Hash_Map_Entry<EXT_ID, INT_ID>* operator-> () const;
721 /// Returns reference the Hash_Map_Manager_Ex that is being iterated
722 /// over.
723 const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>& map ();
725 /// Check if two iterators point to the same position
726 bool operator== (const ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
727 bool operator!= (const ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
729 /// Declare the dynamic allocation hooks.
730 ACE_ALLOC_HOOK_DECLARE;
732 protected:
733 /// Move forward by one element in the set. Returns 0 when there's
734 /// no more item in the set after the current items, else 1.
735 int forward_i ();
737 /// Move backward by one element in the set. Returns 0 when there's
738 /// no more item in the set before the current item, else 1.
739 int reverse_i ();
741 /// Dump the state of an object.
742 void dump_i () const;
744 /// Map we are iterating over.
745 const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *map_man_;
747 /// Keeps track of how far we've advanced in the table.
748 ssize_t index_;
750 /// Keeps track of how far we've advanced in a linked list in each
751 /// table slot.
752 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next_;
756 * @class ACE_Hash_Map_Iterator_Ex
758 * @brief Forward iterator for the ACE_Hash_Map_Manager_Ex.
760 * This class does not perform any internal locking of the
761 * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is
762 * inherently inefficient and/or error-prone within an STL-style
763 * iterator. If you require locking, you can explicitly use an
764 * ACE_GUARD or ACE_READ_GUARD on the ACE_Hash_Map_Manager_Ex's
765 * internal lock, which is accessible via its mutex() method.
767 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
768 class ACE_Hash_Map_Iterator_Ex : public ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
770 public:
771 // = STL-style traits/typedefs
772 typedef typename ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::container_type
773 container_type;
775 // = STL-style traits/typedefs
776 typedef std::bidirectional_iterator_tag iterator_category;
777 typedef typename container_type::value_type value_type;
778 typedef typename container_type::reference reference;
779 typedef typename container_type::pointer pointer;
780 typedef typename container_type::difference_type difference_type;
782 ACE_Hash_Map_Iterator_Ex (ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
783 int tail = 0);
785 /// Constructor.
787 * This constructor positions the iterator to the given @a entry.
789 ACE_Hash_Map_Iterator_Ex (
790 ACE_Hash_Map_Manager_Ex<EXT_ID,
791 INT_ID,
792 HASH_KEY,
793 COMPARE_KEYS,
794 ACE_LOCK> & mm,
795 ACE_Hash_Map_Entry<EXT_ID, INT_ID> * entry,
796 size_t index);
798 // = Iteration methods.
799 /// Move forward by one element in the set. Returns 0 when all the
800 /// items in the set have been seen, else 1.
801 int advance ();
803 /// Dump the state of an object.
804 void dump () const;
806 // = STL styled iteration, compare, and reference functions.
808 /// Prefix advance.
809 ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator++ ();
811 /// Postfix advance.
812 ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator++ (int);
814 /// Prefix reverse.
815 ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator-- ();
817 /// Postfix reverse.
818 ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator-- (int);
820 /// Declare the dynamic allocation hooks.
821 ACE_ALLOC_HOOK_DECLARE;
825 * @class ACE_Hash_Map_Const_Iterator_Ex
827 * @brief Const forward iterator for the ACE_Hash_Map_Manager_Ex.
829 * This class does not perform any internal locking of the
830 * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is
831 * inherently inefficient and/or error-prone within an STL-style
832 * iterator. If you require locking, you can explicitly use an
833 * ACE_GUARD or ACE_READ_GUARD on the ACE_Hash_Map_Manager_Ex's
834 * internal lock, which is accessible via its mutex() method.
836 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
837 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>
839 public:
840 // = STL-style traits/typedefs
841 typedef typename ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::container_type
842 container_type;
844 // = std::iterator_trait traits/typedefs
845 typedef std::bidirectional_iterator_tag iterator_category;
846 typedef typename container_type::value_type value_type;
847 typedef typename container_type::reference reference;
848 typedef typename container_type::pointer pointer;
849 typedef typename container_type::difference_type difference_type;
851 ACE_Hash_Map_Const_Iterator_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
852 int tail = 0);
854 // = Iteration methods.
855 /// Move forward by one element in the set. Returns 0 when all the
856 /// items in the set have been seen, else 1.
857 int advance ();
859 /// Dump the state of an object.
860 void dump () const;
862 // = STL styled iteration, compare, and reference functions.
864 /// Prefix advance.
865 ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator++ ();
867 /// Postfix advance.
868 ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator++ (int);
870 /// Prefix reverse.
871 ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator-- ();
873 /// Postfix reverse.
874 ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator-- (int);
876 /// Declare the dynamic allocation hooks.
877 ACE_ALLOC_HOOK_DECLARE;
881 * @class ACE_Hash_Map_Bucket_Iterator
883 * @brief Forward iterator for the ACE_Hash_Map_Manager_Ex which
884 * only traverses a particular bucket. The particular bucket is
885 * specified by the <EXT_ID> parameter specified in the constructor.
887 * This class does not perform any internal locking of the
888 * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is
889 * inherently inefficient and/or error-prone within an STL-style
890 * iterator. If you require locking, you can explicitly use an
891 * ACE_GUARD or ACE_READ_GUARD on the ACE_Hash_Map_Manager_Ex's
892 * internal lock, which is accessible via its mutex() method.
894 * Note that a creation method for this new iterator cannot be added
895 * to the hash map, since this would require adding explicit template
896 * instantiations for bucket iterators on platforms with broken
897 * templates.
899 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
900 class ACE_Hash_Map_Bucket_Iterator
902 public:
903 // = STL-style traits/typedefs
904 typedef ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
905 container_type;
907 // = std::iterator traits/typedefs
908 typedef std::bidirectional_iterator_tag iterator_category;
909 typedef typename container_type::value_type value_type;
910 typedef typename container_type::reference reference;
911 typedef typename container_type::pointer pointer;
912 typedef typename container_type::difference_type difference_type;
914 ACE_Hash_Map_Bucket_Iterator (ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
915 const EXT_ID &ext_id,
916 int tail = 0);
918 // = STL styled iteration, compare, and reference functions.
920 /// Prefix advance.
921 ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator++ ();
923 /// Postfix advance.
924 ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator++ (int);
926 /// Prefix reverse.
927 ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator-- ();
929 /// Postfix reverse.
930 ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator-- (int);
932 /// Returns a reference to the interal element @c this is pointing to.
933 ACE_Hash_Map_Entry<EXT_ID, INT_ID>& operator* () const;
935 /// Returns a pointer to the interal element @c this is pointing to.
936 ACE_Hash_Map_Entry<EXT_ID, INT_ID>* operator-> () const;
938 /// Returns reference the Hash_Map_Manager_Ex that is being iterated
939 /// over.
940 ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>& map ();
942 /// Check if two iterators point to the same position
943 bool operator== (const ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
944 bool operator!= (const ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
946 protected:
947 /// Move forward by one element in the set. Returns 0 when there's
948 /// no more item in the set after the current items, else 1.
949 int forward_i ();
951 /// Move backward by one element in the set. Returns 0 when there's
952 /// no more item in the set before the current item, else 1.
953 int reverse_i ();
955 /// Map we are iterating over.
956 ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *map_man_;
958 /// Keeps track of how far we've advanced in the table.
959 ssize_t index_;
961 /// Keeps track of how far we've advanced in a linked list in each
962 /// table slot.
963 ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next_;
967 * @class ACE_Hash_Map_Reverse_Iterator_Ex
969 * @brief Reverse iterator for the ACE_Hash_Map_Manager_Ex.
971 * This class does not perform any internal locking of the
972 * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is
973 * inherently inefficient and/or error-prone within an STL-style
974 * iterator. If you require locking, you can explicitly use an
975 * ACE_GUARD or ACE_READ_GUARD on the ACE_Hash_Map_Manager_Ex's
976 * internal lock, which is accessible via its mutex() method.
978 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
979 class ACE_Hash_Map_Reverse_Iterator_Ex : public ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
981 public:
982 // = STL-style traits/typedefs
983 typedef typename ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::container_type
984 container_type;
986 // = std::iterator_traits typedefs
987 typedef std::bidirectional_iterator_tag iterator_category;
988 typedef typename container_type::value_type value_type;
989 typedef typename container_type::reference reference;
990 typedef typename container_type::pointer pointer;
991 typedef typename container_type::difference_type difference_type;
993 // = Initialization method.
994 ACE_Hash_Map_Reverse_Iterator_Ex (ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
995 bool head = false);
997 /// Move forward by one element in the set. Returns 0 when all the
998 /// items in the set have been seen, else 1.
999 int advance ();
1001 /// Dump the state of an object.
1002 void dump () const;
1004 // = STL styled iteration, compare, and reference functions.
1006 /// Prefix reverse.
1007 ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator++ ();
1009 /// Postfix reverse.
1010 ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator++ (int);
1012 /// Prefix advance.
1013 ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator-- ();
1015 /// Postfix advance.
1016 ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator-- (int);
1018 /// Declare the dynamic allocation hooks.
1019 ACE_ALLOC_HOOK_DECLARE;
1023 * @class ACE_Hash_Map_Const_Reverse_Iterator_Ex
1025 * @brief Const reverse iterator for the ACE_Hash_Map_Manager_Ex.
1027 * This class does not perform any internal locking of the
1028 * ACE_Hash_Map_Manager_Ex it is iterating upon since locking is
1029 * inherently inefficient and/or error-prone within an STL-style
1030 * iterator. If you require locking, you can explicitly use an
1031 * ACE_GUARD or ACE_READ_GUARD on the ACE_Hash_Map_Manager_Ex's
1032 * internal lock, which is accessible via its <mutex> method.
1034 template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
1035 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>
1037 public:
1038 // = STL-style traits/typedefs
1039 typedef typename ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::container_type
1040 container_type;
1042 // = std::iterator_traits typedefs
1043 typedef std::bidirectional_iterator_tag iterator_category;
1044 typedef typename container_type::value_type value_type;
1045 typedef typename container_type::reference reference;
1046 typedef typename container_type::pointer pointer;
1047 typedef typename container_type::difference_type difference_type;
1049 // = Initialization method.
1050 ACE_Hash_Map_Const_Reverse_Iterator_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
1051 bool head = false);
1053 /// Move forward by one element in the set. Returns 0 when all the
1054 /// items in the set have been seen, else 1.
1055 int advance ();
1057 /// Dump the state of an object.
1058 void dump () const;
1060 // = STL styled iteration, compare, and reference functions.
1062 /// Prefix reverse.
1063 ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator++ ();
1065 /// Postfix reverse.
1066 ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator++ (int);
1068 /// Prefix advance.
1069 ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator-- ();
1071 /// Postfix advance.
1072 ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator-- (int);
1074 /// Declare the dynamic allocation hooks.
1075 ACE_ALLOC_HOOK_DECLARE;
1079 * @class ACE_Hash_Map_Manager
1081 * @brief Wrapper for backward compatibility.
1083 * This implementation of a map uses a hash table. This class
1084 * expects that the <EXT_ID> contains a method called <hash>.
1085 * In addition, the <EXT_ID> must support <operator==>. Both of
1086 * these constraints can be alleviated via template
1087 * specialization, as shown in the $ACE_ROOT/tests/Conn_Test.cpp
1088 * test.
1090 * <b> Requirements and Performance Characteristics</b>
1091 * - Internal Structure
1092 * Hash Table
1093 * - Duplicates allowed?
1094 * No
1095 * - Random access allowed?
1096 * Yes
1097 * - Search speed
1098 * O(1)
1099 * - Insert/replace speed
1100 * O(1), can be longer if the hash map has to resize
1101 * - Iterator still valid after change to container?
1102 * Yes
1103 * - Frees memory for removed elements?
1104 * Yes
1105 * - Items inserted by
1106 * Value
1107 * - Requirements for key type
1108 * -# Default constructor
1109 * -# Copy constructor
1110 * -# operator=
1111 * -# operator==
1112 * - Requirements for object type
1113 * -# Default constructor
1114 * -# Copy constructor
1115 * -# operator=
1116 * -# operator<
1118 template <class EXT_ID, class INT_ID, class ACE_LOCK>
1119 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>
1121 public:
1123 * Initialize a @c Hash_Map_Manager with default size elements.
1124 * @param table_alloc is a pointer to a memory allocator used for
1125 * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>).
1126 * @param entry_alloc is a pointer to an additional allocator for
1127 * entries, so it should be able to allocate 'size' / chunks
1128 * of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each.
1129 * If @c table_alloc is 0 it defaults to @c ACE_Allocator::instance().
1130 * If @c entry_alloc is 0 then it defaults to the same allocator as
1131 * @c table_alloc.
1133 ACE_Hash_Map_Manager (ACE_Allocator *table_alloc = 0,
1134 ACE_Allocator *entry_alloc = 0);
1137 * Initialize a @c Hash_Map_Manager with @c size elements.
1138 * @param table_alloc is a pointer to a memory allocator used for
1139 * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>).
1140 * @param entry_alloc is a pointer to an additional allocator for
1141 * entries, so it should be able to allocate 'size' / chunks
1142 * of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each.
1143 * If @c table_alloc is 0 it defaults to @c ACE_Allocator::instance().
1144 * If @c entry_alloc is 0 then it defaults to the same allocator as
1145 * @c table_alloc.
1147 ACE_Hash_Map_Manager (size_t size,
1148 ACE_Allocator *table_alloc = 0,
1149 ACE_Allocator *entry_alloc = 0);
1151 // = The following two are necessary for template specialization of
1152 // ACE_Hash_Map_Manager to work.
1153 int equal (const EXT_ID &id1, const EXT_ID &id2);
1154 u_long hash (const EXT_ID &ext_id);
1158 * @class ACE_Hash_Map_Iterator
1160 * @brief Wrapper for backward compatibility.
1162 template <class EXT_ID, class INT_ID, class ACE_LOCK>
1163 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>
1165 public:
1166 // = STL-style traits/typedefs
1167 typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::container_type
1168 container_type;
1170 typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::iterator_category
1171 iterator_category;
1173 typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::value_type
1174 value_type;
1176 typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::reference
1177 reference;
1179 typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::pointer
1180 pointer;
1182 typedef typename ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::difference_type
1183 difference_type;
1185 /// Construct from map
1186 ACE_Hash_Map_Iterator (ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &mm,
1187 int tail = 0);
1189 /// Construct from base
1190 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);
1192 /// Assignment from base
1193 ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> &
1194 operator= (const ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base);
1198 * @class ACE_Hash_Map_Const_Iterator
1200 * @brief Wrapper for backward compatibility.
1202 template <class EXT_ID, class INT_ID, class ACE_LOCK>
1203 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>
1205 public:
1206 // = STL-style traits/typedefs
1207 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
1208 container_type;
1210 // = std::iterator_traits typedefs
1211 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
1212 iterator_category;
1214 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
1215 value_type;
1217 typedef typename ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::reference
1218 reference;
1220 typedef typename ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::pointer
1221 pointer;
1223 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
1224 difference_type;
1226 /// Construct from map
1227 ACE_Hash_Map_Const_Iterator (const ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &mm,
1228 int tail = 0);
1230 /// Construct from base
1231 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);
1233 /// Assignment from base
1234 ACE_Hash_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> &
1235 operator= (const ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base);
1239 * @class ACE_Hash_Map_Reverse_Iterator
1241 * @brief Wrapper for backward compatibility.
1243 template <class EXT_ID, class INT_ID, class ACE_LOCK>
1244 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>
1246 public:
1247 // = STL-style traits/typedefs
1248 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
1249 container_type;
1251 // = std::iterator_traits typedefs
1252 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
1253 iterator_category;
1255 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
1256 value_type;
1258 typedef typename ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::reference
1259 reference;
1261 typedef typename ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>::pointer
1262 pointer;
1264 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
1265 difference_type;
1267 ACE_Hash_Map_Reverse_Iterator (ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &mm,
1268 bool head = false);
1270 /// Construct from base
1271 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);
1273 /// Assignment from base
1274 ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> &
1275 operator= (const ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base);
1278 ACE_END_VERSIONED_NAMESPACE_DECL
1280 #if defined (__ACE_INLINE__)
1281 # include "ace/Hash_Map_Manager_T.inl"
1282 #endif /* __ACE_INLINE__ */
1284 #include "ace/Hash_Map_Manager_T.cpp"
1286 #include /**/ "ace/post.h"
1287 #endif /* ACE_HASH_MAP_MANAGER_T_H */