Define a map abstraction that associates system generated keys with user specified values. More...
#include <Active_Map_Manager_T.h>
Public Types | |
typedef ACE_Active_Map_Manager_Key | key_type |
typedef T | mapped_type |
typedef ACE_Map_Entry < ACE_Active_Map_Manager_Key, T > | ENTRY |
typedef ACE_Map_Iterator < ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > | ITERATOR |
typedef ACE_Map_Reverse_Iterator < ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > | REVERSE_ITERATOR |
typedef ENTRY | entry |
typedef ITERATOR | iterator |
typedef REVERSE_ITERATOR | reverse_iterator |
Public Member Functions | |
ACE_Active_Map_Manager (ACE_Allocator *alloc=0) | |
Initialize a Active_Map_Manager with the ACE_DEFAULT_MAP_SIZE. | |
ACE_Active_Map_Manager (size_t size, ACE_Allocator *alloc=0) | |
Initialize a Active_Map_Manager with size entries. | |
~ACE_Active_Map_Manager (void) | |
int | open (size_t length=ACE_DEFAULT_MAP_SIZE, ACE_Allocator *alloc=0) |
Initialize a Active_Map_Manager with size length. | |
int | close (void) |
int | bind (const T &value, ACE_Active_Map_Manager_Key &key) |
int | bind (const T &value) |
int | bind (ACE_Active_Map_Manager_Key &key, T *&internal_value) |
int | rebind (const ACE_Active_Map_Manager_Key &key, const T &value) |
int | rebind (const ACE_Active_Map_Manager_Key &key, const T &value, T &old_value) |
int | rebind (const ACE_Active_Map_Manager_Key &key, const T &value, ACE_Active_Map_Manager_Key &old_key, T &old_value) |
int | find (const ACE_Active_Map_Manager_Key &key, T &value) const |
Locate value associated with key. | |
int | find (const ACE_Active_Map_Manager_Key &key) const |
Is key in the map? | |
int | find (const ACE_Active_Map_Manager_Key &key, T *&internal_value) const |
int | unbind (const ACE_Active_Map_Manager_Key &key) |
Remove key from the map. | |
int | unbind (const ACE_Active_Map_Manager_Key &key, T &value) |
int | unbind (const ACE_Active_Map_Manager_Key &key, T *&internal_value) |
size_t | current_size (void) const |
Return the current size of the map. | |
size_t | total_size (void) const |
Return the total size of the map. | |
void | dump (void) const |
Dump the state of an object. | |
ACE_Map_Iterator < ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > | begin (void) |
Return forward iterator. | |
ACE_Map_Iterator < ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > | end (void) |
ACE_Map_Reverse_Iterator < ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > | rbegin (void) |
Return reverse iterator. | |
ACE_Map_Reverse_Iterator < ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > | rend (void) |
Static Public Member Functions | |
static const ACE_Active_Map_Manager_Key | npos (void) |
Returns a key that cannot be found in the map. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Protected Types | |
typedef ACE_Map_Manager < ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > | ACE_AMM_BASE |
Private base class. | |
Private Member Functions | |
void | operator= (const ACE_Active_Map_Manager< T > &) |
ACE_Active_Map_Manager (const ACE_Active_Map_Manager< T > &) |
Define a map abstraction that associates system generated keys with user specified values.
Since the key is system generated, searches are very fast and take a constant amount of time.
Definition at line 39 of file Active_Map_Manager_T.h.
typedef ACE_Map_Manager<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ACE_Active_Map_Manager< T >::ACE_AMM_BASE [protected] |
Private base class.
Definition at line 187 of file Active_Map_Manager_T.h.
typedef ACE_Map_Entry<ACE_Active_Map_Manager_Key, T> ACE_Active_Map_Manager< T >::ENTRY |
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 47 of file Active_Map_Manager_T.h.
typedef ENTRY ACE_Active_Map_Manager< T >::entry |
Definition at line 51 of file Active_Map_Manager_T.h.
typedef ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ACE_Active_Map_Manager< T >::ITERATOR |
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 48 of file Active_Map_Manager_T.h.
typedef ITERATOR ACE_Active_Map_Manager< T >::iterator |
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 52 of file Active_Map_Manager_T.h.
typedef ACE_Active_Map_Manager_Key ACE_Active_Map_Manager< T >::key_type |
Definition at line 44 of file Active_Map_Manager_T.h.
typedef T ACE_Active_Map_Manager< T >::mapped_type |
Definition at line 45 of file Active_Map_Manager_T.h.
typedef ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ACE_Active_Map_Manager< T >::REVERSE_ITERATOR |
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 49 of file Active_Map_Manager_T.h.
typedef REVERSE_ITERATOR ACE_Active_Map_Manager< T >::reverse_iterator |
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 53 of file Active_Map_Manager_T.h.
ACE_Active_Map_Manager< T >::ACE_Active_Map_Manager | ( | ACE_Allocator * | alloc = 0 |
) | [inline] |
Initialize a Active_Map_Manager with the ACE_DEFAULT_MAP_SIZE.
Definition at line 229 of file Active_Map_Manager_T.inl.
: ACE_AMM_BASE (alloc) { }
ACE_Active_Map_Manager< T >::ACE_Active_Map_Manager | ( | size_t | size, | |
ACE_Allocator * | alloc = 0 | |||
) | [inline] |
Initialize a Active_Map_Manager with size entries.
Definition at line 235 of file Active_Map_Manager_T.inl.
: ACE_AMM_BASE (size, alloc) { }
ACE_Active_Map_Manager< T >::~ACE_Active_Map_Manager | ( | void | ) | [inline] |
Close down a Active_Map_Manager and release dynamically allocated resources.
Definition at line 243 of file Active_Map_Manager_T.inl.
{ }
ACE_Active_Map_Manager< T >::ACE_Active_Map_Manager | ( | const ACE_Active_Map_Manager< T > & | ) | [private] |
ACE_Map_Iterator< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > ACE_Active_Map_Manager< T >::begin | ( | void | ) |
Return forward iterator.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 288 of file Active_Map_Manager_T.inl.
{ return ACE_AMM_BASE::begin (); }
int ACE_Active_Map_Manager< T >::bind | ( | const T & | value, | |
ACE_Active_Map_Manager_Key & | key | |||
) | [inline] |
Add value to the map, and the corresponding key produced by the Active_Map_Manager is returned through key.
Definition at line 37 of file Active_Map_Manager_T.inl.
{ T *internal_value = 0; int result = this->bind (key, internal_value); if (result == 0) { // Store new value. *internal_value = value; } return result; }
int ACE_Active_Map_Manager< T >::bind | ( | const T & | value | ) | [inline] |
Add value to the map. The user does not care about the corresponding key produced by the Active_Map_Manager.
Definition at line 54 of file Active_Map_Manager_T.inl.
{ ACE_Active_Map_Manager_Key key; return this->bind (value, key); }
int ACE_Active_Map_Manager< T >::bind | ( | ACE_Active_Map_Manager_Key & | key, | |
T *& | internal_value | |||
) | [inline] |
Reserves a slot in the internal structure and returns the key and a pointer to the value. User should place their value into internal_value. This method is useful in reducing the number of copies required in some cases. Note that internal_value is only a temporary pointer and will change when the map resizes. Therefore, the user should use the pointer immediately and not hold on to it.
Definition at line 8 of file Active_Map_Manager_T.inl.
{ ACE_UINT32 slot_index; int result = this->next_free (slot_index); if (result == 0) { // Move from free list to occupied list this->move_from_free_list_to_occupied_list (slot_index); // Reset the key. this->search_structure_[slot_index].ext_id_.increment_slot_generation_count (); this->search_structure_[slot_index].ext_id_.slot_index (slot_index); // Copy the key for the user. key = this->search_structure_[slot_index].ext_id_; // This is where the user should place the value. internal_value = &this->search_structure_[slot_index].int_id_; // Update the current size. ++this->cur_size_; } return result; }
int ACE_Active_Map_Manager< T >::close | ( | void | ) | [inline] |
Close down a Active_Map_Manager and release dynamically allocated resources.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 255 of file Active_Map_Manager_T.inl.
{ return ACE_AMM_BASE::close (); }
size_t ACE_Active_Map_Manager< T >::current_size | ( | void | ) | const [inline] |
Return the current size of the map.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 261 of file Active_Map_Manager_T.inl.
{ return ACE_AMM_BASE::current_size (); }
void ACE_Active_Map_Manager< T >::dump | ( | void | ) | const [inline] |
Dump the state of an object.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 280 of file Active_Map_Manager_T.inl.
{ #if defined (ACE_HAS_DUMP) ACE_AMM_BASE::dump (); #endif /* ACE_HAS_DUMP */ }
ACE_Map_Iterator< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > ACE_Active_Map_Manager< T >::end | ( | void | ) | [inline] |
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 294 of file Active_Map_Manager_T.inl.
{ return ACE_AMM_BASE::end (); }
int ACE_Active_Map_Manager< T >::find | ( | const ACE_Active_Map_Manager_Key & | key, | |
T & | value | |||
) | const [inline] |
Locate value associated with key.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 95 of file Active_Map_Manager_T.inl.
{ T *internal_value = 0; int result = this->find (key, internal_value); if (result == 0) value = *internal_value; return result; }
int ACE_Active_Map_Manager< T >::find | ( | const ACE_Active_Map_Manager_Key & | key | ) | const [inline] |
Is key in the map?
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 87 of file Active_Map_Manager_T.inl.
{ T *internal_value = 0; return this->find (key, internal_value); }
int ACE_Active_Map_Manager< T >::find | ( | const ACE_Active_Map_Manager_Key & | key, | |
T *& | internal_value | |||
) | const [inline] |
Locate value associated with key. The value is returned via internal_value and hence a copy is saved. Note that internal_value is only a temporary pointer and will change when the map resizes. Therefore, the user should use the pointer immediately and not hold on to it.
Definition at line 61 of file Active_Map_Manager_T.inl.
{ ACE_UINT32 slot_index = key.slot_index (); ACE_UINT32 slot_generation = key.slot_generation (); if (slot_index > this->total_size_ || #if defined (ACE_HAS_LAZY_MAP_MANAGER) this->search_structure_[slot_index].free_ || #endif /* ACE_HAS_LAZY_MAP_MANAGER */ this->search_structure_[slot_index].ext_id_.slot_generation () != slot_generation || this->search_structure_[slot_index].ext_id_.slot_index () == (ACE_UINT32)this->free_list_id ()) { return -1; } else { // This is where the user value is. internal_value = &this->search_structure_[slot_index].int_id_; } return 0; }
const ACE_Active_Map_Manager_Key ACE_Active_Map_Manager< T >::npos | ( | void | ) | [inline, static] |
Returns a key that cannot be found in the map.
Definition at line 274 of file Active_Map_Manager_T.inl.
{ return ACE_Active_Map_Manager_Key (~0, ~0); }
int ACE_Active_Map_Manager< T >::open | ( | size_t | length = ACE_DEFAULT_MAP_SIZE , |
|
ACE_Allocator * | alloc = 0 | |||
) | [inline] |
Initialize a Active_Map_Manager with size length.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 248 of file Active_Map_Manager_T.inl.
{ return ACE_AMM_BASE::open (length, alloc); }
void ACE_Active_Map_Manager< T >::operator= | ( | const ACE_Active_Map_Manager< T > & | ) | [private] |
ACE_Map_Reverse_Iterator< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > ACE_Active_Map_Manager< T >::rbegin | ( | void | ) | [inline] |
Return reverse iterator.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 300 of file Active_Map_Manager_T.inl.
{ return ACE_AMM_BASE::rbegin (); }
int ACE_Active_Map_Manager< T >::rebind | ( | const ACE_Active_Map_Manager_Key & | key, | |
const T & | value, | |||
ACE_Active_Map_Manager_Key & | old_key, | |||
T & | old_value | |||
) | [inline] |
Reassociate key with value, storing the old key and value into the "out" parameter old_key and old_value. The function fails if key is not in the map.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 143 of file Active_Map_Manager_T.inl.
{ int result = this->find (key); if (result == 0) { // Copy old key. old_key = this->search_structure_[key.slot_index ()].ext_id_; // Copy old value. old_value = this->search_structure_[key.slot_index ()].int_id_; // Store new value. this->search_structure_[key.slot_index ()].int_id_ = value; } return result; }
int ACE_Active_Map_Manager< T >::rebind | ( | const ACE_Active_Map_Manager_Key & | key, | |
const T & | value | |||
) | [inline] |
Reassociate key with value. The function fails if key is not in the map.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 109 of file Active_Map_Manager_T.inl.
{ int result = this->find (key); if (result == 0) { // Store new value. this->search_structure_[key.slot_index ()].int_id_ = value; } return result; }
int ACE_Active_Map_Manager< T >::rebind | ( | const ACE_Active_Map_Manager_Key & | key, | |
const T & | value, | |||
T & | old_value | |||
) | [inline] |
Reassociate key with value, storing the old value into the "out" parameter old_value. The function fails if key is not in the map.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 124 of file Active_Map_Manager_T.inl.
{ int result = this->find (key); if (result == 0) { // Copy old value. old_value = this->search_structure_[key.slot_index ()].int_id_; // Store new value. this->search_structure_[key.slot_index ()].int_id_ = value; } return result; }
ACE_Map_Reverse_Iterator< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > ACE_Active_Map_Manager< T >::rend | ( | void | ) | [inline] |
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 306 of file Active_Map_Manager_T.inl.
{ return ACE_AMM_BASE::rend (); }
size_t ACE_Active_Map_Manager< T >::total_size | ( | void | ) | const [inline] |
Return the total size of the map.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 267 of file Active_Map_Manager_T.inl.
{ return ACE_AMM_BASE::total_size (); }
int ACE_Active_Map_Manager< T >::unbind | ( | const ACE_Active_Map_Manager_Key & | key | ) | [inline] |
Remove key from the map.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 221 of file Active_Map_Manager_T.inl.
{ T *internal_value; return this->unbind (key, internal_value); }
int ACE_Active_Map_Manager< T >::unbind | ( | const ACE_Active_Map_Manager_Key & | key, | |
T *& | internal_value | |||
) | [inline] |
Locate value associated with key. The value is returned via internal_value and hence a copy is saved. Note that internal_value is only a temporary pointer and will change when the map resizes or when this slot is reused. Therefore, the user should use the pointer immediately and not hold on to it.
Definition at line 166 of file Active_Map_Manager_T.inl.
{ int result = this->find (key, internal_value); if (result == 0) { ACE_UINT32 slot_index = key.slot_index (); #if defined (ACE_HAS_LAZY_MAP_MANAGER) // // In the case of lazy map managers, the movement of free slots // from the occupied list to the free list is delayed until we // run out of free slots in the free list. // this->search_structure_[slot_index].free_ = 1; #else // Move from occupied list to free list. this->move_from_occupied_list_to_free_list (slot_index); #endif /* ACE_HAS_LAZY_MAP_MANAGER */ // Reset the slot_index. This will tell us that this entry is free. this->search_structure_[slot_index].ext_id_.slot_index (this->free_list_id ()); // Update the current size. --this->cur_size_; } return result; }
int ACE_Active_Map_Manager< T >::unbind | ( | const ACE_Active_Map_Manager_Key & | key, | |
T & | value | |||
) | [inline] |
Remove key from the map, and return the value associated with key.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 204 of file Active_Map_Manager_T.inl.
{ T *internal_value; int result = this->unbind (key, internal_value); if (result == 0) { // Copy old value. value = *internal_value; } return result; }
ACE_Active_Map_Manager< T >::ACE_ALLOC_HOOK_DECLARE |
Declare the dynamic allocation hooks.
Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.
Definition at line 182 of file Active_Map_Manager_T.h.