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

ACE_Hash_Map_Manager_Ex Class Template Reference

Define a map abstraction that efficiently associates <EXT_ID>s with <INT_ID>s. More...

#include <Hash_Map_Manager_T.h>

Inheritance diagram for ACE_Hash_Map_Manager_Ex:

Inheritance graph
[legend]
Collaboration diagram for ACE_Hash_Map_Manager_Ex:

Collaboration graph
[legend]
List of all members.

Public Types

typedef EXT_ID KEY
typedef INT_ID VALUE
typedef ACE_Hash_Map_Entry<
EXT_ID, INT_ID > 
ENTRY
typedef ACE_Hash_Map_Iterator_Ex<
EXT_ID, INT_ID, HASH_KEY,
COMPARE_KEYS, ACE_LOCK > 
ITERATOR
typedef ACE_Hash_Map_Const_Iterator_Ex<
EXT_ID, INT_ID, HASH_KEY,
COMPARE_KEYS, ACE_LOCK > 
CONST_ITERATOR
typedef ACE_Hash_Map_Reverse_Iterator_Ex<
EXT_ID, INT_ID, HASH_KEY,
COMPARE_KEYS, ACE_LOCK > 
REVERSE_ITERATOR
typedef ACE_Hash_Map_Iterator_Ex<
EXT_ID, INT_ID, HASH_KEY,
COMPARE_KEYS, ACE_LOCK > 
iterator
typedef ACE_Hash_Map_Const_Iterator_Ex<
EXT_ID, INT_ID, HASH_KEY,
COMPARE_KEYS, ACE_LOCK > 
const_iterator
typedef ACE_Hash_Map_Reverse_Iterator_Ex<
EXT_ID, INT_ID, HASH_KEY,
COMPARE_KEYS, ACE_LOCK > 
reverse_iterator

Public Methods

 ACE_Hash_Map_Manager_Ex (ACE_Allocator *alloc=0)
 Initialize a <Hash_Map_Manager_Ex> with default size. More...

 ACE_Hash_Map_Manager_Ex (size_t size, ACE_Allocator *alloc=0)
 Initialize a <Hash_Map_Manager_Ex> with size <length>. More...

int open (size_t size=ACE_DEFAULT_MAP_SIZE, ACE_Allocator *alloc=0)
 Initialize a <Hash_Map_Manager_Ex> with <size> elements. More...

int close (void)
 Close down a <Hash_Map_Manager_Ex> and release dynamically allocated resources. More...

int unbind_all (void)
 Removes all the entries in <Map_Manager_Ex>. More...

 ~ACE_Hash_Map_Manager_Ex (void)
 Cleanup the <Hash_Map_Manager_Ex>. More...

int bind (const EXT_ID &item, const INT_ID &int_id)
int bind (const EXT_ID &ext_id, const INT_ID &int_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry)
int trybind (const EXT_ID &ext_id, INT_ID &int_id)
int trybind (const EXT_ID &ext_id, INT_ID &int_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry)
int rebind (const EXT_ID &ext_id, const INT_ID &int_id)
int rebind (const EXT_ID &ext_id, const INT_ID &int_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry)
int rebind (const EXT_ID &ext_id, const INT_ID &int_id, INT_ID &old_int_id)
int rebind (const EXT_ID &ext_id, const INT_ID &int_id, INT_ID &old_int_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry)
int rebind (const EXT_ID &ext_id, const INT_ID &int_id, EXT_ID &old_ext_id, INT_ID &old_int_id)
int rebind (const EXT_ID &ext_id, const INT_ID &int_id, EXT_ID &old_ext_id, INT_ID &old_int_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry)
int find (const EXT_ID &ext_id, INT_ID &int_id) const
 Locate <ext_id> and pass out parameter via <int_id>. Return 0 if found, returns -1 if not found. More...

int find (const EXT_ID &ext_id) const
 Returns 0 if the <ext_id> is in the mapping, otherwise -1. More...

int find (const EXT_ID &ext_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry) const
 Locate <ext_id> and pass out parameter via <entry>. If found, return 0, returns -1 if not found. More...

int unbind (const EXT_ID &ext_id)
int unbind (const EXT_ID &ext_id, INT_ID &int_id)
 Break any association of <ext_id>. Returns the value of <int_id> in case the caller needs to deallocate memory. Return 0 if the unbind was successfully, and returns -1 if failures occur. More...

int unbind (ACE_Hash_Map_Entry< EXT_ID, INT_ID > *entry)
 Remove entry from map. Return 0 if the unbind was successfully, and returns -1 if failures occur. More...

size_t current_size (void) const
 Return the current size of the map. More...

size_t total_size (void) const
 Return the total size of the map. More...

ACE_LOCK & mutex (void)
void dump (void) const
 Dump the state of an object. More...

ACE_Hash_Map_Iterator_Ex<
EXT_ID, INT_ID, HASH_KEY,
COMPARE_KEYS, ACE_LOCK > 
begin (void)
 Return forward iterator. More...

ACE_Hash_Map_Iterator_Ex<
EXT_ID, INT_ID, HASH_KEY,
COMPARE_KEYS, ACE_LOCK > 
end (void)
ACE_Hash_Map_Reverse_Iterator_Ex<
EXT_ID, INT_ID, HASH_KEY,
COMPARE_KEYS, ACE_LOCK > 
rbegin (void)
 Return reverse iterator. More...

ACE_Hash_Map_Reverse_Iterator_Ex<
EXT_ID, INT_ID, HASH_KEY,
COMPARE_KEYS, ACE_LOCK > 
rend (void)

Protected Methods

int equal (const EXT_ID &id1, const EXT_ID &id2)
 Returns 1 if <id1> == <id2>, else 0. This is defined as a separate method to facilitate template specialization. More...

u_long hash (const EXT_ID &ext_id)
 Compute the hash value of the <ext_id>. This is defined as a separate method to facilitate template specialization. More...

int bind_i (const EXT_ID &ext_id, const INT_ID &int_id)
 Performs bind. Must be called with locks held. More...

int bind_i (const EXT_ID &ext_id, const INT_ID &int_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry)
 Performs bind. Must be called with locks held. More...

int trybind_i (const EXT_ID &ext_id, INT_ID &int_id)
 Performs trybind. Must be called with locks held. More...

int trybind_i (const EXT_ID &ext_id, INT_ID &int_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry)
 Performs trybind. Must be called with locks held. More...

int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id)
 Performs rebind. Must be called with locks held. More...

int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry)
 Performs rebind. Must be called with locks held. More...

int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id, INT_ID &old_int_id)
 Performs rebind. Must be called with locks held. More...

int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id, INT_ID &old_int_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry)
 Performs rebind. Must be called with locks held. More...

int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id, EXT_ID &old_ext_id, INT_ID &old_int_id)
 Performs rebind. Must be called with locks held. More...

int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id, EXT_ID &old_ext_id, INT_ID &old_int_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry)
 Performs rebind. Must be called with locks held. More...

int find_i (const EXT_ID &ext_id, INT_ID &int_id)
 Performs a find of <int_id> using <ext_id> as the key. Must be called with locks held. More...

int find_i (const EXT_ID &ext_id)
 Performs a find using <ext_id> as the key. Must be called with locks held. More...

int find_i (const EXT_ID &ext_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry)
 Performs a find using <ext_id> as the key. Must be called with locks held. More...

int unbind_i (const EXT_ID &ext_id, INT_ID &int_id)
 Performs unbind. Must be called with locks held. More...

int unbind_i (const EXT_ID &ext_id)
 Performs unbind. Must be called with locks held. More...

int unbind_i (ACE_Hash_Map_Entry< EXT_ID, INT_ID > *entry)
 Performs unbind. Must be called with locks held. More...

int create_buckets (size_t size)
int close_i (void)
 Close down a <Map_Manager_Ex>. Must be called with locks held. More...

int unbind_all_i (void)
 Removes all the entries in <Map_Manager_Ex>. Must be called with locks held. More...

int shared_find (const EXT_ID &ext_id, ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&entry, size_t &loc)
 Returns the <ACE_Hash_Map_Entry> that corresponds to <ext_id>. More...


Protected Attributes

ACE_Allocatorallocator_
 Pointer to a memory allocator. More...

ACE_LOCK lock_
 Synchronization variable for the MT_SAFE <ACE_Hash_Map_Manager_Ex>. More...

HASH_KEY hash_key_
 Function object used for hashing keys. More...

COMPARE_KEYS compare_keys_
 Function object used for comparing keys. More...


Private Methods

void operator= (const ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > &)
 ACE_Hash_Map_Manager_Ex (const ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > &)

Private Attributes

ACE_Hash_Map_Entry< EXT_ID,
INT_ID > * 
table_
size_t total_size_
 Total size of the hash table. More...

size_t cur_size_
 Current number of entries in the table (note that this can be larger than <total_size_> due to the bucket chaining). More...


Friends

class ACE_Hash_Map_Iterator_Base_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >
class ACE_Hash_Map_Iterator_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >
class ACE_Hash_Map_Const_Iterator_Base_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >
class ACE_Hash_Map_Const_Iterator_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >
class ACE_Hash_Map_Reverse_Iterator_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >
class ACE_Hash_Map_Bucket_Iterator< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >

Detailed Description

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
class ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >

Define a map abstraction that efficiently associates <EXT_ID>s with <INT_ID>s.

This implementation of a map uses a hash table. Key hashing is achieved through the HASH_KEY object and key comparison is achieved through the COMPARE_KEYS object. This class uses an <ACE_Allocator> to allocate memory. The user can make this a persistent class by providing an <ACE_Allocator> with a persistable memory pool.

Definition at line 109 of file Hash_Map_Manager_T.h.


Member Typedef Documentation

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
typedef ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> ACE_Hash_Map_Manager_Ex::const_iterator
 

Definition at line 138 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
typedef ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> ACE_Hash_Map_Manager_Ex::CONST_ITERATOR
 

Definition at line 130 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
typedef ACE_Hash_Map_Entry<EXT_ID, INT_ID> ACE_Hash_Map_Manager_Ex::ENTRY
 

Definition at line 124 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
typedef ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> ACE_Hash_Map_Manager_Ex::iterator
 

Definition at line 136 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
typedef ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> ACE_Hash_Map_Manager_Ex::ITERATOR
 

Definition at line 128 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
typedef EXT_ID ACE_Hash_Map_Manager_Ex::KEY
 

Definition at line 120 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
typedef ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> ACE_Hash_Map_Manager_Ex::reverse_iterator
 

Definition at line 140 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
typedef ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> ACE_Hash_Map_Manager_Ex::REVERSE_ITERATOR
 

Definition at line 132 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
typedef INT_ID ACE_Hash_Map_Manager_Ex::VALUE
 

Definition at line 122 of file Hash_Map_Manager_T.h.


Constructor & Destructor Documentation

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::ACE_Hash_Map_Manager_Ex ACE_Allocator   alloc = 0
 

Initialize a <Hash_Map_Manager_Ex> with default size.

Definition at line 18 of file Hash_Map_Manager_T.i.

References ACE_DEFAULT_MAP_SIZE, ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, and open.

00019   : allocator_ (alloc),
00020     table_ (0),
00021     total_size_ (0),
00022     cur_size_ (0)
00023 {
00024   if (this->open (ACE_DEFAULT_MAP_SIZE, alloc) == -1)
00025     ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_Hash_Map_Manager_Ex\n")));
00026 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::ACE_Hash_Map_Manager_Ex size_t    size,
ACE_Allocator   alloc = 0
 

Initialize a <Hash_Map_Manager_Ex> with size <length>.

Definition at line 6 of file Hash_Map_Manager_T.i.

References ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, and open.

00008   : allocator_ (alloc),
00009     table_ (0),
00010     total_size_ (0),
00011     cur_size_ (0)
00012 {
00013   if (this->open (size, alloc) == -1)
00014     ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_Hash_Map_Manager_Ex\n")));
00015 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::~ACE_Hash_Map_Manager_Ex void   
 

Cleanup the <Hash_Map_Manager_Ex>.

Definition at line 45 of file Hash_Map_Manager_T.i.

References close.

00046 {
00047   this->close ();
00048 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::ACE_Hash_Map_Manager_Ex const ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > &    [private]
 


Member Function Documentation

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_Hash_Map_Iterator_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::begin void   
 

Return forward iterator.

Definition at line 348 of file Hash_Map_Manager_T.i.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind const EXT_ID &    ext_id,
const INT_ID &    int_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
 

Same as a normal bind, except the map entry is also passed back to the caller. The entry in this case will either be the newly created entry, or the existing one.

Definition at line 101 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and bind_i.

00104 {
00105   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00106 
00107   return this->bind_i (ext_id, int_id, entry);
00108 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind const EXT_ID &    item,
const INT_ID &    int_id
 

Associate <ext_id> with <int_id>. If <ext_id> is already in the map then the <ACE_Hash_Map_Entry> is not changed. Returns 0 if a new entry is bound successfully, returns 1 if an attempt is made to bind an existing entry, and returns -1 if failures occur.

Definition at line 92 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and bind_i.

00094 {
00095   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00096 
00097   return this->bind_i (ext_id, int_id);
00098 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind_i const EXT_ID &    ext_id,
const INT_ID &    int_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
[protected]
 

Performs bind. Must be called with locks held.

Definition at line 203 of file Hash_Map_Manager_T.cpp.

References ACE_ALLOCATOR_RETURN, cur_size_, ACE_Hash_Map_Entry::next_, shared_find, and table_.

00206 {
00207   size_t loc;
00208   int result = this->shared_find (ext_id, entry, loc);
00209 
00210   if (result == -1)
00211     {
00212       void *ptr;
00213       // Not found.
00214       ACE_ALLOCATOR_RETURN (ptr,
00215                             this->allocator_->malloc (sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>)),
00216                             -1);
00217 
00218       entry = new (ptr) ACE_Hash_Map_Entry<EXT_ID, INT_ID> (ext_id,
00219                                                             int_id,
00220                                                             this->table_[loc].next_,
00221                                                             &this->table_[loc]);
00222       this->table_[loc].next_ = entry;
00223       entry->next_->prev_ = entry;
00224       this->cur_size_++;
00225       return 0;
00226     }
00227   else
00228     return 1;
00229 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind_i const EXT_ID &    ext_id,
const INT_ID &    int_id
[protected]
 

Performs bind. Must be called with locks held.

Definition at line 83 of file Hash_Map_Manager_T.i.

Referenced by bind, and rebind_i.

00085 {
00086   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp;
00087 
00088   return this->bind_i (ext_id, int_id, temp);
00089 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::close void   
 

Close down a <Hash_Map_Manager_Ex> and release dynamically allocated resources.

Definition at line 29 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and close_i.

Referenced by ~ACE_Hash_Map_Manager_Ex.

00030 {
00031   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00032 
00033   return this->close_i ();
00034 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::close_i void    [protected]
 

Close down a <Map_Manager_Ex>. Must be called with locks held.

Definition at line 140 of file Hash_Map_Manager_T.cpp.

References ACE_DES_FREE_TEMPLATE2, ACE_NOOP, allocator_, ACE_Allocator::free, table_, total_size_, and unbind_all_i.

Referenced by close, and open.

00141 {
00142   // Protect against "double-deletion" in case the destructor also
00143   // gets called.
00144   if (this->table_ != 0)
00145     {
00146       // Remove all the entries.
00147       this->unbind_all_i ();
00148 
00149       // Iterate through the buckets cleaning up the sentinels.
00150       for (size_t i = 0; i < this->total_size_; i++)
00151         {
00152           // Destroy the dummy entry.
00153           ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry = &this->table_[i];
00154           // The "if" second argument results in a no-op instead of
00155           // deallocation.
00156           ACE_DES_FREE_TEMPLATE2 (entry, ACE_NOOP,
00157                                   ACE_Hash_Map_Entry, EXT_ID, INT_ID);
00158         }
00159 
00160       // Reset size.
00161       this->total_size_ = 0;
00162 
00163       // Free table memory.
00164       this->allocator_->free (this->table_);
00165 
00166       // Should be done last...
00167       this->table_ = 0;
00168     }
00169 
00170   return 0;
00171 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::create_buckets size_t    size [protected]
 

Resize the map. Must be called with locks held. Note, that this method should never be called more than once or else all the hashing will get screwed up as the size will change.

Definition at line 93 of file Hash_Map_Manager_T.cpp.

References ACE_ALLOCATOR_RETURN, table_, and total_size_.

Referenced by open.

00094 {
00095   size_t bytes = size * sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>);
00096   void *ptr;
00097 
00098   ACE_ALLOCATOR_RETURN (ptr,
00099                         this->allocator_->malloc (bytes),
00100                         -1);
00101 
00102   this->table_ = (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *) ptr;
00103 
00104   this->total_size_ = size;
00105 
00106   // Initialize each entry in the hash table to be a circular linked
00107   // list with the dummy node in the front serving as the anchor of
00108   // the list.
00109   for (size_t i = 0; i < size; i++)
00110     new (&this->table_[i]) ACE_Hash_Map_Entry<EXT_ID, INT_ID> (&this->table_[i],
00111                                                                &this->table_[i]);
00112   return 0;
00113 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE size_t ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::current_size void    const
 

Return the current size of the map.

Definition at line 51 of file Hash_Map_Manager_T.i.

References cur_size_.

00052 {
00053   return this->cur_size_;
00054 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
void ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::dump void    const
 

Dump the state of an object.

Definition at line 82 of file Hash_Map_Manager_T.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, allocator_, ACE_Allocator::dump, LM_DEBUG, and lock_.

00083 {
00084   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00085   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("total_size_ = %d"), this->total_size_));
00086   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("\ncur_size_ = %d"), this->cur_size_));
00087   this->allocator_->dump ();
00088   this->lock_.dump ();
00089   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00090 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_Hash_Map_Iterator_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::end void   
 

Definition at line 355 of file Hash_Map_Manager_T.i.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::equal const EXT_ID &    id1,
const EXT_ID &    id2
[protected]
 

Returns 1 if <id1> == <id2>, else 0. This is defined as a separate method to facilitate template specialization.

Reimplemented in ACE_Hash_Map_Manager.

Definition at line 76 of file Hash_Map_Manager_T.i.

References compare_keys_.

Referenced by shared_find.

00078 {
00079   return this->compare_keys_ (id1, id2);
00080 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find const EXT_ID &    ext_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
const
 

Locate <ext_id> and pass out parameter via <entry>. If found, return 0, returns -1 if not found.

Definition at line 232 of file Hash_Map_Manager_T.i.

References ACE_READ_GUARD_RETURN, find_i, and lock_.

00234 {
00235   ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *nc_this =
00236     (ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *)
00237     this;
00238 
00239   ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, nc_this->lock_, -1);
00240 
00241   return nc_this->find_i (ext_id, entry);
00242 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find const EXT_ID &    ext_id const
 

Returns 0 if the <ext_id> is in the mapping, otherwise -1.

Definition at line 213 of file Hash_Map_Manager_T.i.

References ACE_READ_GUARD_RETURN, find_i, and lock_.

00214 {
00215   ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *nc_this =
00216     (ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *)
00217     this;
00218   ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, nc_this->lock_, -1);
00219 
00220   return nc_this->find_i (ext_id);
00221 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find const EXT_ID &    ext_id,
INT_ID &    int_id
const
 

Locate <ext_id> and pass out parameter via <int_id>. Return 0 if found, returns -1 if not found.

Definition at line 200 of file Hash_Map_Manager_T.i.

References ACE_READ_GUARD_RETURN, find_i, and lock_.

00202 {
00203   ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *nc_this =
00204     (ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *)
00205     this;
00206 
00207   ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, nc_this->lock_, -1);
00208 
00209   return nc_this->find_i (ext_id, int_id);
00210 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find_i const EXT_ID &    ext_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
[protected]
 

Performs a find using <ext_id> as the key. Must be called with locks held.

Definition at line 224 of file Hash_Map_Manager_T.i.

References shared_find.

00226 {
00227   size_t dummy;
00228   return this->shared_find (ext_id, entry, dummy);
00229 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find_i const EXT_ID &    ext_id [protected]
 

Performs a find using <ext_id> as the key. Must be called with locks held.

Definition at line 191 of file Hash_Map_Manager_T.i.

References shared_find.

00192 {
00193   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry;
00194 
00195   size_t dummy;
00196   return this->shared_find (ext_id, entry, dummy);
00197 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find_i const EXT_ID &    ext_id,
INT_ID &    int_id
[protected]
 

Performs a find of <int_id> using <ext_id> as the key. Must be called with locks held.

Definition at line 175 of file Hash_Map_Manager_T.i.

References ACE_Hash_Map_Entry::int_id_, and shared_find.

Referenced by find.

00177 {
00178   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry;
00179 
00180   size_t dummy;
00181   if (this->shared_find (ext_id, entry, dummy) == -1)
00182     return -1;
00183   else
00184     {
00185       int_id = entry->int_id_;
00186       return 0;
00187     }
00188 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE u_long ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::hash const EXT_ID &    ext_id [protected]
 

Compute the hash value of the <ext_id>. This is defined as a separate method to facilitate template specialization.

Reimplemented in ACE_Hash_Map_Manager.

Definition at line 70 of file Hash_Map_Manager_T.i.

References hash_key_.

Referenced by shared_find.

00071 {
00072   return this->hash_key_ (ext_id);
00073 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_LOCK & ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::mutex void   
 

Returns a reference to the underlying <ACE_LOCK>. This makes it possible to acquire the lock explicitly, which can be useful in some cases if you instantiate the <ACE_Atomic_Op> with an <ACE_Recursive_Mutex> or <ACE_Process_Mutex>, or if you need to guard the state of an iterator. NOTE: the right name would be <lock>, but HP/C++ will choke on that!

Definition at line 63 of file Hash_Map_Manager_T.i.

References ACE_TRACE, and lock_.

00064 {
00065   ACE_TRACE ("ACE_Hash_Map_Manager_Ex::mutex");
00066   return this->lock_;
00067 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::open size_t    size = ACE_DEFAULT_MAP_SIZE,
ACE_Allocator   alloc = 0
 

Initialize a <Hash_Map_Manager_Ex> with <size> elements.

Definition at line 116 of file Hash_Map_Manager_T.cpp.

References ACE_ASSERT, ACE_WRITE_GUARD_RETURN, allocator_, close_i, create_buckets, and ACE_Allocator::instance.

Referenced by ACE_Hash_Map_Manager_Ex.

00118 {
00119   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00120 
00121   // Calling this->close_i () to ensure we release previous allocated
00122   // memory before allocating new one.
00123   this->close_i ();
00124 
00125   if (alloc == 0)
00126     alloc = ACE_Allocator::instance ();
00127 
00128   this->allocator_ = alloc;
00129 
00130   // This assertion is here to help track a situation that shouldn't
00131   // happen, but did with Sun C++ 4.1 (before a change to this class
00132   // was made: it used to have an enum that was supposed to be defined
00133   // to be ACE_DEFAULT_MAP_SIZE, but instead was defined to be 0).
00134   ACE_ASSERT (size != 0);
00135 
00136   return this->create_buckets (size);
00137 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
void ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::operator= const ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > &    [private]
 

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_Hash_Map_Reverse_Iterator_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rbegin void   
 

Return reverse iterator.

Definition at line 362 of file Hash_Map_Manager_T.i.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind const EXT_ID &    ext_id,
const INT_ID &    int_id,
EXT_ID &    old_ext_id,
INT_ID &    old_int_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
 

Same as a normal rebind, except the map entry is also passed back to the caller. The entry in this case will either be the newly created entry, or the existing one.

Definition at line 335 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and rebind_i.

00340 {
00341   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00342 
00343   return this->rebind_i (ext_id, int_id, old_ext_id, old_int_id, entry);
00344 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind const EXT_ID &    ext_id,
const INT_ID &    int_id,
EXT_ID &    old_ext_id,
INT_ID &    old_int_id
 

Associate <ext_id> with <int_id>. If <ext_id> is not in the map then behaves just like <bind>. Otherwise, store the old values of <ext_id> and <int_id> into the "out" parameters and rebind the new parameters. This is very useful if you need to have an atomic way of updating <ACE_Hash_Map_Entrys> and you also need full control over memory allocation. Returns 0 if a new entry is bound successfully, returns 1 if an existing entry was rebound, and returns -1 if failures occur.

Definition at line 324 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and rebind_i.

00328 {
00329   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00330 
00331   return this->rebind_i (ext_id, int_id, old_ext_id, old_int_id);
00332 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind const EXT_ID &    ext_id,
const INT_ID &    int_id,
INT_ID &    old_int_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
 

Same as a normal rebind, except the map entry is also passed back to the caller. The entry in this case will either be the newly created entry, or the existing one.

Definition at line 313 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and rebind_i.

00317 {
00318   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00319 
00320   return this->rebind_i (ext_id, int_id, old_int_id, entry);
00321 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind const EXT_ID &    ext_id,
const INT_ID &    int_id,
INT_ID &    old_int_id
 

Associate <ext_id> with <int_id>. If <ext_id> is not in the map then behaves just like <bind>. Otherwise, store the old value of <int_id> into the "out" parameter and rebind the new parameters. Returns 0 if a new entry is bound successfully, returns 1 if an existing entry was rebound, and returns -1 if failures occur.

Definition at line 303 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and rebind_i.

00306 {
00307   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00308 
00309   return this->rebind_i (ext_id, int_id, old_int_id);
00310 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind const EXT_ID &    ext_id,
const INT_ID &    int_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
 

Same as a normal rebind, except the map entry is also passed back to the caller. The entry in this case will either be the newly created entry, or the existing one.

Definition at line 293 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and rebind_i.

00296 {
00297   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00298 
00299   return this->rebind_i (ext_id, int_id, entry);
00300 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind const EXT_ID &    ext_id,
const INT_ID &    int_id
 

Reassociate <ext_id> with <int_id>. If <ext_id> is not in the map then behaves just like <bind>. Returns 0 if a new entry is bound successfully, returns 1 if an existing entry was rebound, and returns -1 if failures occur.

Definition at line 284 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and rebind_i.

00286 {
00287   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00288 
00289   return this->rebind_i (ext_id, int_id);
00290 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind_i const EXT_ID &    ext_id,
const INT_ID &    int_id,
EXT_ID &    old_ext_id,
INT_ID &    old_int_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
[protected]
 

Performs rebind. Must be called with locks held.

Definition at line 352 of file Hash_Map_Manager_T.cpp.

References bind_i, ACE_Hash_Map_Entry::ext_id_, ACE_Hash_Map_Entry::int_id_, and shared_find.

00357 {
00358   size_t dummy;
00359   if (this->shared_find (ext_id, entry, dummy) == -1)
00360     return this->bind_i (ext_id, int_id);
00361   else
00362     {
00363       old_ext_id = entry->ext_id_;
00364       old_int_id = entry->int_id_;
00365       entry->ext_id_ = ext_id;
00366       entry->int_id_ = int_id;
00367       return 1;
00368     }
00369 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind_i const EXT_ID &    ext_id,
const INT_ID &    int_id,
EXT_ID &    old_ext_id,
INT_ID &    old_int_id
[protected]
 

Performs rebind. Must be called with locks held.

Definition at line 269 of file Hash_Map_Manager_T.i.

References rebind_i.

00273 {
00274   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *node;
00275 
00276   return this->rebind_i (ext_id,
00277                          int_id,
00278                          old_ext_id,
00279                          old_int_id,
00280                          node);
00281 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind_i const EXT_ID &    ext_id,
const INT_ID &    int_id,
INT_ID &    old_int_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
[protected]
 

Performs rebind. Must be called with locks held.

Definition at line 334 of file Hash_Map_Manager_T.cpp.

References bind_i, ACE_Hash_Map_Entry::ext_id_, ACE_Hash_Map_Entry::int_id_, and shared_find.

00338 {
00339   size_t dummy;
00340   if (this->shared_find (ext_id, entry, dummy) == -1)
00341     return this->bind_i (ext_id, int_id);
00342   else
00343     {
00344       old_int_id = entry->int_id_;
00345       entry->ext_id_ = ext_id;
00346       entry->int_id_ = int_id;
00347       return 1;
00348     }
00349 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind_i const EXT_ID &    ext_id,
const INT_ID &    int_id,
INT_ID &    old_int_id
[protected]
 

Performs rebind. Must be called with locks held.

Definition at line 256 of file Hash_Map_Manager_T.i.

References rebind_i.

00259 {
00260   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *node;
00261 
00262   return this->rebind_i (ext_id,
00263                          int_id,
00264                          old_int_id,
00265                          node);
00266 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind_i const EXT_ID &    ext_id,
const INT_ID &    int_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
[protected]
 

Performs rebind. Must be called with locks held.

Definition at line 318 of file Hash_Map_Manager_T.cpp.

References bind_i, ACE_Hash_Map_Entry::ext_id_, ACE_Hash_Map_Entry::int_id_, and shared_find.

00321 {
00322   size_t dummy;
00323   if (this->shared_find (ext_id, entry, dummy) == -1)
00324     return this->bind_i (ext_id, int_id);
00325   else
00326     {
00327       entry->ext_id_ = ext_id;
00328       entry->int_id_ = int_id;
00329       return 1;
00330     }
00331 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind_i const EXT_ID &    ext_id,
const INT_ID &    int_id
[protected]
 

Performs rebind. Must be called with locks held.

Definition at line 245 of file Hash_Map_Manager_T.i.

Referenced by rebind, and rebind_i.

00247 {
00248   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *node;
00249 
00250   return this->rebind_i (ext_id,
00251                          int_id,
00252                          node);
00253 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_Hash_Map_Reverse_Iterator_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rend void   
 

Definition at line 369 of file Hash_Map_Manager_T.i.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::shared_find const EXT_ID &    ext_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry,
size_t &    loc
[protected]
 

Returns the <ACE_Hash_Map_Entry> that corresponds to <ext_id>.

Definition at line 294 of file Hash_Map_Manager_T.cpp.

References equal, ACE_Hash_Map_Entry::ext_id_, hash, ACE_Hash_Map_Entry::next_, table_, and total_size_.

Referenced by bind_i, find_i, rebind_i, trybind_i, and unbind_i.

00297 {
00298   loc = this->hash (ext_id) % this->total_size_;
00299 
00300   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp = this->table_[loc].next_;
00301 
00302   while (temp != &this->table_[loc] && this->equal (temp->ext_id_, ext_id) == 0)
00303     temp = temp->next_;
00304 
00305   if (temp == &this->table_[loc])
00306     {
00307       errno = ENOENT;
00308       return -1;
00309     }
00310   else
00311     {
00312       entry = temp;
00313       return 0;
00314     }
00315 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE size_t ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::total_size void    const
 

Return the total size of the map.

Definition at line 57 of file Hash_Map_Manager_T.i.

References total_size_.

00058 {
00059   return this->total_size_;
00060 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::trybind const EXT_ID &    ext_id,
INT_ID &    int_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
 

Same as a normal trybind, except the map entry is also passed back to the caller. The entry in this case will either be the newly created entry, or the existing one.

Definition at line 132 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and trybind_i.

00135 {
00136   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00137 
00138   return this->trybind_i (ext_id, int_id, entry);
00139 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::trybind const EXT_ID &    ext_id,
INT_ID &    int_id
 

Associate <ext_id> with <int_id> if and only if <ext_id> is not in the map. If <ext_id> is already in the map then the <int_id> parameter is assigned the existing value in the map. Returns 0 if a new entry is bound successfully, returns 1 if an attempt is made to bind an existing entry, and returns -1 if failures occur.

Definition at line 123 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and trybind_i.

00125 {
00126   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00127 
00128   return this->trybind_i (ext_id, int_id);
00129 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::trybind_i const EXT_ID &    ext_id,
INT_ID &    int_id,
ACE_Hash_Map_Entry< EXT_ID, INT_ID > *&    entry
[protected]
 

Performs trybind. Must be called with locks held.

Definition at line 232 of file Hash_Map_Manager_T.cpp.

References ACE_ALLOCATOR_RETURN, cur_size_, ACE_Hash_Map_Entry::next_, shared_find, and table_.

00235 {
00236   size_t loc;
00237   int result = this->shared_find (ext_id, entry, loc);
00238 
00239   if (result == -1)
00240     {
00241       // Not found.
00242       void *ptr;
00243       ACE_ALLOCATOR_RETURN (ptr,
00244                             this->allocator_->malloc (sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>)),
00245                             -1);
00246 
00247       entry = new (ptr) ACE_Hash_Map_Entry<EXT_ID, INT_ID> (ext_id,
00248                                                             int_id,
00249                                                             this->table_[loc].next_,
00250                                                             &this->table_[loc]);
00251       this->table_[loc].next_ = entry;
00252       entry->next_->prev_ = entry;
00253       this->cur_size_++;
00254       return 0;
00255     }
00256   else
00257     return 1;
00258 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::trybind_i const EXT_ID &    ext_id,
INT_ID &    int_id
[protected]
 

Performs trybind. Must be called with locks held.

Definition at line 111 of file Hash_Map_Manager_T.i.

References ACE_Hash_Map_Entry::int_id_.

Referenced by trybind.

00113 {
00114   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp;
00115 
00116   int result = this->trybind_i (ext_id, int_id, temp);
00117   if (result == 1)
00118     int_id = temp->int_id_;
00119   return result;
00120 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind ACE_Hash_Map_Entry< EXT_ID, INT_ID > *    entry
 

Remove entry from map. Return 0 if the unbind was successfully, and returns -1 if failures occur.

Definition at line 167 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and unbind_i.

00168 {
00169   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00170 
00171   return this->unbind_i (entry) == -1 ? -1 : 0;
00172 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind const EXT_ID &    ext_id,
INT_ID &    int_id
 

Break any association of <ext_id>. Returns the value of <int_id> in case the caller needs to deallocate memory. Return 0 if the unbind was successfully, and returns -1 if failures occur.

Definition at line 150 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and unbind_i.

00152 {
00153   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00154 
00155   return this->unbind_i (ext_id, int_id);
00156 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind const EXT_ID &    ext_id
 

Unbind (remove) the <ext_id> from the map. Don't return the <int_id> to the caller (this is useful for collections where the <int_id>s are *not* dynamically allocated...)

Definition at line 159 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and unbind_i.

00160 {
00161   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00162 
00163   return this->unbind_i (ext_id) == -1 ? -1 : 0;
00164 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind_all void   
 

Removes all the entries in <Map_Manager_Ex>.

Definition at line 37 of file Hash_Map_Manager_T.i.

References ACE_WRITE_GUARD_RETURN, and unbind_all_i.

00038 {
00039   ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00040 
00041   return this->unbind_all_i ();
00042 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind_all_i void    [protected]
 

Removes all the entries in <Map_Manager_Ex>. Must be called with locks held.

Definition at line 174 of file Hash_Map_Manager_T.cpp.

References ACE_DES_FREE_TEMPLATE2, cur_size_, ACE_Hash_Map_Entry::next_, ACE_Hash_Map_Entry::prev_, table_, and total_size_.

Referenced by close_i, and unbind_all.

00175 {
00176   // Iterate through the entire map calling the destuctor of each
00177   // <ACE_Hash_Map_Entry>.
00178   for (size_t i = 0; i < this->total_size_; i++)
00179     {
00180       for (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp_ptr = this->table_[i].next_;
00181            temp_ptr != &this->table_[i];
00182            )
00183         {
00184           ACE_Hash_Map_Entry<EXT_ID, INT_ID> *hold_ptr = temp_ptr;
00185           temp_ptr = temp_ptr->next_;
00186 
00187           // Explicitly call the destructor.
00188           ACE_DES_FREE_TEMPLATE2 (hold_ptr, this->allocator_->free,
00189                                   ACE_Hash_Map_Entry, EXT_ID, INT_ID);
00190         }
00191 
00192       // Restore the sentinel.
00193       this->table_[i].next_ = &this->table_[i];
00194       this->table_[i].prev_ = &this->table_[i];
00195     }
00196 
00197   this->cur_size_ = 0;
00198 
00199   return 0;
00200 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind_i ACE_Hash_Map_Entry< EXT_ID, INT_ID > *    entry [protected]
 

Performs unbind. Must be called with locks held.

Definition at line 281 of file Hash_Map_Manager_T.cpp.

References ACE_DES_FREE_TEMPLATE2, cur_size_, ACE_Hash_Map_Entry::next_, and ACE_Hash_Map_Entry::prev_.

00282 {
00283   entry->next_->prev_ = entry->prev_;
00284   entry->prev_->next_ = entry->next_;
00285 
00286   // Explicitly call the destructor.
00287   ACE_DES_FREE_TEMPLATE2 (entry, this->allocator_->free,
00288                           ACE_Hash_Map_Entry, EXT_ID, INT_ID);
00289   this->cur_size_--;
00290   return 0;
00291 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind_i const EXT_ID &    ext_id [protected]
 

Performs unbind. Must be called with locks held.

Definition at line 142 of file Hash_Map_Manager_T.i.

References unbind_i.

00143 {
00144   INT_ID int_id;
00145 
00146   return this->unbind_i (ext_id, int_id);
00147 }

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
int ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind_i const EXT_ID &    ext_id,
INT_ID &    int_id
[protected]
 

Performs unbind. Must be called with locks held.

Definition at line 261 of file Hash_Map_Manager_T.cpp.

References ACE_Hash_Map_Entry::int_id_, and shared_find.

Referenced by unbind, and unbind_i.

00263 {
00264   ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp;
00265 
00266   size_t loc;
00267   int result = this->shared_find (ext_id, temp, loc);
00268 
00269   if (result == -1)
00270     {
00271       errno = ENOENT;
00272       return -1;
00273     }
00274 
00275   int_id = temp->int_id_;
00276 
00277   return this->unbind_i (temp);
00278 }


Friends And Related Function Documentation

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
friend class ACE_Hash_Map_Bucket_Iterator< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > [friend]
 

Definition at line 117 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
friend class ACE_Hash_Map_Const_Iterator_Base_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > [friend]
 

Definition at line 114 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
friend class ACE_Hash_Map_Const_Iterator_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > [friend]
 

Definition at line 115 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
friend class ACE_Hash_Map_Iterator_Base_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > [friend]
 

Definition at line 112 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
friend class ACE_Hash_Map_Iterator_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > [friend]
 

Definition at line 113 of file Hash_Map_Manager_T.h.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
friend class ACE_Hash_Map_Reverse_Iterator_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK > [friend]
 

Definition at line 116 of file Hash_Map_Manager_T.h.


Member Data Documentation

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_Allocator* ACE_Hash_Map_Manager_Ex::allocator_ [protected]
 

Pointer to a memory allocator.

Definition at line 430 of file Hash_Map_Manager_T.h.

Referenced by close_i, dump, and open.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
COMPARE_KEYS ACE_Hash_Map_Manager_Ex::compare_keys_ [protected]
 

Function object used for comparing keys.

Definition at line 439 of file Hash_Map_Manager_T.h.

Referenced by equal.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
size_t ACE_Hash_Map_Manager_Ex::cur_size_ [private]
 

Current number of entries in the table (note that this can be larger than <total_size_> due to the bucket chaining).

Definition at line 460 of file Hash_Map_Manager_T.h.

Referenced by bind_i, current_size, trybind_i, unbind_all_i, and unbind_i.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
HASH_KEY ACE_Hash_Map_Manager_Ex::hash_key_ [protected]
 

Function object used for hashing keys.

Definition at line 436 of file Hash_Map_Manager_T.h.

Referenced by hash.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_LOCK ACE_Hash_Map_Manager_Ex::lock_ [protected]
 

Synchronization variable for the MT_SAFE <ACE_Hash_Map_Manager_Ex>.

Definition at line 433 of file Hash_Map_Manager_T.h.

Referenced by dump, find, and mutex.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
ACE_Hash_Map_Entry<EXT_ID, INT_ID>* ACE_Hash_Map_Manager_Ex::table_ [private]
 

Array of <ACE_Hash_Map_Entry> *s, each of which points to an <ACE_Hash_Map_Entry> that serves as the beginning of a linked list of <EXT_ID>s that hash to that bucket.

Definition at line 453 of file Hash_Map_Manager_T.h.

Referenced by ACE_Hash_Map_Const_Iterator_Base_Ex::ACE_Hash_Map_Const_Iterator_Base_Ex, ACE_Hash_Map_Iterator_Base_Ex::ACE_Hash_Map_Iterator_Base_Ex, bind_i, close_i, create_buckets, shared_find, trybind_i, and unbind_all_i.

template<class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
size_t ACE_Hash_Map_Manager_Ex::total_size_ [private]
 

Total size of the hash table.

Definition at line 456 of file Hash_Map_Manager_T.h.

Referenced by ACE_Hash_Map_Const_Iterator_Base_Ex::ACE_Hash_Map_Const_Iterator_Base_Ex, ACE_Hash_Map_Iterator_Base_Ex::ACE_Hash_Map_Iterator_Base_Ex, close_i, create_buckets, shared_find, total_size, and unbind_all_i.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:48:47 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002