#include <Array_Map.h>
Public Types | |
typedef Key | key_type |
typedef Value | data_type |
typedef std::pair< key_type, data_type > | value_type |
typedef value_type * | iterator |
typedef value_type const * | const_iterator |
typedef value_type & | reference |
typedef value_type const & | const_reference |
typedef value_type * | pointer |
typedef value_type const * | const_pointer |
typedef ptrdiff_t | difference_type |
typedef size_t | size_type |
Public Member Functions | |
ACE_DECLARE_STL_REVERSE_ITERATORS | ACE_Array_Map (size_type s=0) |
Default Constructor. | |
template<typename InputIterator> | |
ACE_Array_Map (InputIterator f, InputIterator l) | |
ACE_Array_Map (ACE_Array_Map const &map) | |
ACE_Array_Map & | operator= (ACE_Array_Map const &map) |
~ACE_Array_Map (void) | |
Destructor. | |
size_type | size (void) const |
Return current size of map. | |
size_type | max_size (void) const |
Maximum number of elements the map can hold. | |
bool | is_empty (void) const |
Return true if the map is empty, else false . | |
bool | empty (void) const |
void | swap (ACE_Array_Map &map) |
std::pair< iterator, bool > | insert (value_type const &x) |
Insert the value x into the map. | |
template<typename InputIterator> | |
void | insert (InputIterator f, InputIterator l) |
Insert range of elements into map. | |
void | erase (iterator pos) |
Remove element at position pos from the map. | |
size_type | erase (key_type const &k) |
Remove element corresponding to key k from the map. | |
void | erase (iterator first, iterator last) |
Remove range of elements [first, last) from the map. | |
void | clear (void) |
Clear contents of map. | |
size_type | count (key_type const &k) |
Count the number of elements corresponding to key k. | |
data_type & | operator[] (key_type const &k) |
Convenience array index operator. | |
Forward Iterator Accessors | |
Forward iterator accessors. | |
iterator | begin (void) |
iterator | end (void) |
const_iterator | begin (void) const |
const_iterator | end (void) const |
Reverse Iterator Accessors | |
Reverse iterator accessors. | |
reverse_iterator | rbegin (void) |
reverse_iterator | rend (void) |
const_reverse_iterator | rbegin (void) const |
const_reverse_iterator | rend (void) const |
Search Operations | |
Search the map for data corresponding to key k. | |
iterator | find (key_type const &k) |
const_iterator | find (key_type const &k) const |
Private Member Functions | |
void | grow (size_type s) |
Increase size of underlying buffer by s. | |
Private Attributes | |
size_type | size_ |
Number of elements in the map. | |
size_type | capacity_ |
Current size of underlying array. | |
value_type * | nodes_ |
Underlying array containing keys and data. |
Map implementation that focuses on small footprint and fast iteration. Search times are, however, linear (O(n)) meaning that this map isn't suitable for large data sets that will be searched in performance critical areas of code. Iteration over large data sets, however, is faster than linked list-based maps, for example, since spatial locality is maximized through the use of contiguous arrays as the underlying storage.
ACE_Array_Map
is a unique associative container, meaning that duplicate values may not be added to the map. It is also pair associative (value_type is a std::pair<>). It is not a sorted container. std::map
-like interface is exposed by this class portability. Furthermore, this map's iterators are compatible with STL algorithms.
Definition at line 88 of file Array_Map.h.
typedef value_type const* ACE_Array_Map< Key, Value, EqualTo >::const_iterator |
Definition at line 97 of file Array_Map.h.
typedef value_type const* ACE_Array_Map< Key, Value, EqualTo >::const_pointer |
Definition at line 101 of file Array_Map.h.
typedef value_type const& ACE_Array_Map< Key, Value, EqualTo >::const_reference |
Definition at line 99 of file Array_Map.h.
typedef Value ACE_Array_Map< Key, Value, EqualTo >::data_type |
Definition at line 94 of file Array_Map.h.
typedef ptrdiff_t ACE_Array_Map< Key, Value, EqualTo >::difference_type |
Definition at line 102 of file Array_Map.h.
typedef value_type* ACE_Array_Map< Key, Value, EqualTo >::iterator |
Definition at line 96 of file Array_Map.h.
typedef Key ACE_Array_Map< Key, Value, EqualTo >::key_type |
Definition at line 93 of file Array_Map.h.
typedef value_type* ACE_Array_Map< Key, Value, EqualTo >::pointer |
Definition at line 100 of file Array_Map.h.
typedef value_type& ACE_Array_Map< Key, Value, EqualTo >::reference |
Definition at line 98 of file Array_Map.h.
typedef size_t ACE_Array_Map< Key, Value, EqualTo >::size_type |
Definition at line 103 of file Array_Map.h.
typedef std::pair<key_type, data_type> ACE_Array_Map< Key, Value, EqualTo >::value_type |
Definition at line 95 of file Array_Map.h.
ACE_DECLARE_STL_REVERSE_ITERATORS ACE_Array_Map< Key, Value, EqualTo >::ACE_Array_Map | ( | size_type | s = 0 |
) |
Default Constructor.
Create an empty map with a preallocated buffer of size s.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Array_Map< Key, Value, EqualTo >::ACE_Array_Map | ( | InputIterator | f, | |
InputIterator | l | |||
) |
Definition at line 21 of file Array_Map.cpp.
References ACE_make_checked_array_iterator(), and ACE_Array_Map< Key, Value, EqualTo >::size_.
00023 : size_ (l - f) 00024 , capacity_ (size_) 00025 , nodes_ (size_ == 0 ? 0 : new value_type[size_]) 00026 { 00027 (void) std::copy (f, 00028 l, 00029 ACE_make_checked_array_iterator (this->begin (), 00030 this->size_)); 00031 00032 // iterator n = this->begin (); 00033 00034 // for (InputIterator i = f; i != l; ++i, ++n) 00035 // *n = *i; 00036 }
ACE_Array_Map< Key, Value, EqualTo >::ACE_Array_Map | ( | ACE_Array_Map< Key, Value, EqualTo > const & | map | ) |
ACE_Array_Map< Key, Value, EqualTo >::~ACE_Array_Map | ( | void | ) |
Destructor.
Definition at line 79 of file Array_Map.cpp.
References ACE_Array_Map< Key, Value, EqualTo >::nodes_.
00080 { 00081 delete[] this->nodes_; 00082 }
ACE_INLINE ACE_Array_Map< Key, Value, EqualTo >::const_iterator ACE_Array_Map< Key, Value, EqualTo >::begin | ( | void | ) | const |
Definition at line 45 of file Array_Map.inl.
References ACE_Array_Map< Key, Value, EqualTo >::nodes_.
00046 { 00047 return this->nodes_; 00048 }
ACE_INLINE ACE_Array_Map< Key, Value, EqualTo >::iterator ACE_Array_Map< Key, Value, EqualTo >::begin | ( | void | ) |
Definition at line 31 of file Array_Map.inl.
References ACE_Array_Map< Key, Value, EqualTo >::nodes_.
Referenced by operator==().
00032 { 00033 return this->nodes_; 00034 }
void ACE_Array_Map< Key, Value, EqualTo >::clear | ( | void | ) |
Clear contents of map.
Definition at line 205 of file Array_Map.cpp.
References ACE_Array_Map< Key, Value, EqualTo >::size_.
00206 { 00207 this->size_ = 0; // No need to deallocate array nor destroy elements. 00208 }
size_type ACE_Array_Map< Key, Value, EqualTo >::count | ( | key_type const & | k | ) |
Count the number of elements corresponding to key k.
ACE_INLINE bool ACE_Array_Map< Key, Value, EqualTo >::empty | ( | void | ) | const |
Return true
if the map is empty, else false
. We recommend using is_empty()
instead since it's more consistent with the ACE container naming conventions.
Definition at line 110 of file Array_Map.inl.
References ACE_Array_Map< Key, Value, EqualTo >::is_empty().
00111 { 00112 return this->is_empty (); 00113 }
ACE_INLINE ACE_Array_Map< Key, Value, EqualTo >::const_iterator ACE_Array_Map< Key, Value, EqualTo >::end | ( | void | ) | const |
Definition at line 52 of file Array_Map.inl.
References ACE_Array_Map< Key, Value, EqualTo >::nodes_, and ACE_Array_Map< Key, Value, EqualTo >::size_.
ACE_INLINE ACE_Array_Map< Key, Value, EqualTo >::iterator ACE_Array_Map< Key, Value, EqualTo >::end | ( | void | ) |
Definition at line 38 of file Array_Map.inl.
References ACE_Array_Map< Key, Value, EqualTo >::nodes_, and ACE_Array_Map< Key, Value, EqualTo >::size_.
Referenced by operator==().
void ACE_Array_Map< Key, Value, EqualTo >::erase | ( | iterator | first, | |
iterator | last | |||
) |
Remove range of elements [first, last) from the map.
size_type ACE_Array_Map< Key, Value, EqualTo >::erase | ( | key_type const & | k | ) |
Remove element corresponding to key k from the map.
void ACE_Array_Map< Key, Value, EqualTo >::erase | ( | iterator | pos | ) |
Remove element at position pos from the map.
Referenced by ACE::Monitor_Control::Monitor_Base::remove_constraint().
const_iterator ACE_Array_Map< Key, Value, EqualTo >::find | ( | key_type const & | k | ) | const |
end()
if data corresponding to key k is not in the map. iterator ACE_Array_Map< Key, Value, EqualTo >::find | ( | key_type const & | k | ) |
end()
if data corresponding to key k is not in the map. Referenced by ACE::Monitor_Control::Monitor_Base::remove_constraint().
void ACE_Array_Map< Key, Value, EqualTo >::grow | ( | size_type | s | ) | [private] |
Increase size of underlying buffer by s.
Referenced by ACE_Array_Map< Key, Value, EqualTo >::insert().
void ACE_Array_Map< Key, Value, EqualTo >::insert | ( | InputIterator | f, | |
InputIterator | l | |||
) |
Insert range of elements into map.
Definition at line 126 of file Array_Map.cpp.
References ACE_Array_Map< Key, Value, EqualTo >::grow().
00127 { 00128 this->grow (l - f); // Preallocate storage. 00129 00130 for (InputIterator i = f; i != l; ++i) 00131 { 00132 (void) this->insert (*i); 00133 } 00134 }
std::pair<iterator, bool> ACE_Array_Map< Key, Value, EqualTo >::insert | ( | value_type const & | x | ) |
Insert the value x into the map.
STL-style map insertion method.
x | std::pair containing key and datum. |
std::pair::second
will be false
if the map already contains a value with the same key as x. ACE_INLINE bool ACE_Array_Map< Key, Value, EqualTo >::is_empty | ( | void | ) | const |
Return true
if the map is empty, else false
.
Definition at line 101 of file Array_Map.inl.
References ACE_Array_Map< Key, Value, EqualTo >::size_.
Referenced by ACE_Array_Map< Key, Value, EqualTo >::empty().
00102 { 00103 return this->size_ == 0; 00104 }
ACE_INLINE ACE_Array_Map< Key, Value, EqualTo >::size_type ACE_Array_Map< Key, Value, EqualTo >::max_size | ( | void | ) | const |
Maximum number of elements the map can hold.
Definition at line 94 of file Array_Map.inl.
00095 { 00096 return size_type (-1) / sizeof (value_type); 00097 }
ACE_Array_Map& ACE_Array_Map< Key, Value, EqualTo >::operator= | ( | ACE_Array_Map< Key, Value, EqualTo > const & | map | ) |
data_type& ACE_Array_Map< Key, Value, EqualTo >::operator[] | ( | key_type const & | k | ) |
Convenience array index operator.
Array index operator that allows insertion and retrieval of elements using an array index syntax, such as:
ACE_INLINE ACE_Array_Map< Key, Value, EqualTo >::const_reverse_iterator ACE_Array_Map< Key, Value, EqualTo >::rbegin | ( | void | ) | const |
ACE_INLINE ACE_Array_Map< Key, Value, EqualTo >::reverse_iterator ACE_Array_Map< Key, Value, EqualTo >::rbegin | ( | void | ) |
ACE_INLINE ACE_Array_Map< Key, Value, EqualTo >::const_reverse_iterator ACE_Array_Map< Key, Value, EqualTo >::rend | ( | void | ) | const |
ACE_INLINE ACE_Array_Map< Key, Value, EqualTo >::reverse_iterator ACE_Array_Map< Key, Value, EqualTo >::rend | ( | void | ) |
ACE_INLINE ACE_Array_Map< Key, Value, EqualTo >::size_type ACE_Array_Map< Key, Value, EqualTo >::size | ( | void | ) | const |
Return current size of map.
Definition at line 87 of file Array_Map.inl.
References ACE_Array_Map< Key, Value, EqualTo >::size_.
Referenced by operator==().
00088 { 00089 return this->size_; 00090 }
void ACE_Array_Map< Key, Value, EqualTo >::swap | ( | ACE_Array_Map< Key, Value, EqualTo > & | map | ) |
Swap the contents of this map with the given map in an exception-safe manner.
size_type ACE_Array_Map< Key, Value, EqualTo >::capacity_ [private] |
Current size of underlying array.
capacity_
is always greater than or equal to size_
; Definition at line 263 of file Array_Map.h.
value_type* ACE_Array_Map< Key, Value, EqualTo >::nodes_ [private] |
Underlying array containing keys and data.
Definition at line 266 of file Array_Map.h.
Referenced by ACE_Array_Map< Key, Value, EqualTo >::begin(), ACE_Array_Map< Key, Value, EqualTo >::end(), and ACE_Array_Map< Key, Value, EqualTo >::~ACE_Array_Map().
size_type ACE_Array_Map< Key, Value, EqualTo >::size_ [private] |
Number of elements in the map.
Definition at line 257 of file Array_Map.h.
Referenced by ACE_Array_Map< Key, Value, EqualTo >::ACE_Array_Map(), ACE_Array_Map< Key, Value, EqualTo >::clear(), ACE_Array_Map< Key, Value, EqualTo >::end(), ACE_Array_Map< Key, Value, EqualTo >::is_empty(), and ACE_Array_Map< Key, Value, EqualTo >::size().