#include <Array_Base.h>
Inheritance diagram for ACE_Array_Base< T >:


Public Types | |
| typedef T | TYPE |
| typedef ACE_Array_Iterator< T > | ITERATOR |
| typedef T | 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 ACE_Allocator::size_type | size_type |
Public Member Functions | |
| ACE_DECLARE_STL_REVERSE_ITERATORS | ACE_Array_Base (size_type size=0, ACE_Allocator *the_allocator=0) |
| Dynamically create an uninitialized array. | |
| ACE_Array_Base (size_type size, T const &default_value, ACE_Allocator *the_allocator=0) | |
| Dynamically initialize the entire array to the . | |
| ACE_Array_Base (ACE_Array_Base< T > const &s) | |
| void | operator= (ACE_Array_Base< T > const &s) |
| ~ACE_Array_Base (void) | |
| Clean up the array (e.g., delete dynamically allocated memory). | |
| T & | operator[] (size_type slot) |
| T const & | operator[] (size_type slot) const |
| int | set (T const &new_item, size_type slot) |
| int | get (T &item, size_type slot) const |
| size_type | size (void) const |
| Returns the of the array. | |
| int | size (size_type new_size) |
| size_type | max_size (void) const |
| Returns the of the array. | |
| int | max_size (size_type new_size) |
| void | swap (ACE_Array_Base< T > &array) |
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 |
Protected Member Functions | |
| bool | in_range (size_type slot) const |
Protected Attributes | |
| size_type | max_size_ |
| size_type | cur_size_ |
| value_type * | array_ |
| Pointer to the array's storage buffer. | |
| ACE_Allocator * | allocator_ |
| Allocation strategy of the ACE_Array_Base. | |
Friends | |
| class | ACE_Array_Iterator< T > |
This parametric class implements a simple dynamic array; resizing must be controlled by the user. No comparison or find operations are implemented.
Definition at line 43 of file Array_Base.h.
|
|||||
|
Definition at line 54 of file Array_Base.h. |
|
|||||
|
Definition at line 58 of file Array_Base.h. |
|
|||||
|
Definition at line 56 of file Array_Base.h. |
|
|||||
|
Definition at line 59 of file Array_Base.h. |
|
|||||
|
Definition at line 53 of file Array_Base.h. |
|
|||||
|
Reimplemented in ACE_Array< T >, ACE_Array< ACE_Get_Opt_Long_Option * >, and ACE_Array< ACE_INET_Addr >. Definition at line 49 of file Array_Base.h. |
|
|||||
|
Definition at line 57 of file Array_Base.h. |
|
|||||
|
Definition at line 55 of file Array_Base.h. |
|
|||||
|
|||||
|
Reimplemented in ACE_Array< T >, ACE_Array< ACE_Get_Opt_Long_Option * >, and ACE_Array< ACE_INET_Addr >. Definition at line 48 of file Array_Base.h. |
|
|||||
|
Definition at line 52 of file Array_Base.h. |
|
||||||||||||||||
|
Dynamically create an uninitialized array.
Definition at line 25 of file Array_Base.cpp. References ACE_ALLOCATOR, ACE_Array_Base< T >::array_, ACE_Allocator::instance(), and ACE_Array_Base< T >::size_type.
00027 : max_size_ (size), 00028 cur_size_ (size), 00029 allocator_ (alloc) 00030 { 00031 if (this->allocator_ == 0) 00032 this->allocator_ = ACE_Allocator::instance (); 00033 00034 if (size != 0) 00035 { 00036 ACE_ALLOCATOR (this->array_, 00037 (T *) this->allocator_->malloc (size * sizeof (T))); 00038 for (size_type i = 0; i < size; ++i) 00039 new (&array_[i]) T; 00040 } 00041 else 00042 this->array_ = 0; 00043 } |
|
||||||||||||||||||||
|
Dynamically initialize the entire array to the .
Definition at line 46 of file Array_Base.cpp. References ACE_ALLOCATOR, ACE_Array_Base< T >::array_, ACE_Allocator::instance(), and ACE_Array_Base< T >::size_type.
00049 : max_size_ (size), 00050 cur_size_ (size), 00051 allocator_ (alloc) 00052 { 00053 if (this->allocator_ == 0) 00054 this->allocator_ = ACE_Allocator::instance (); 00055 00056 if (size != 0) 00057 { 00058 ACE_ALLOCATOR (this->array_, 00059 (T *) this->allocator_->malloc (size * sizeof (T))); 00060 for (size_type i = 0; i < size; ++i) 00061 new (&array_[i]) T (default_value); 00062 } 00063 else 00064 this->array_ = 0; 00065 } |
|
||||||||||
|
The copy constructor performs initialization by making an exact copy of the contents of parameter , i.e., *this == s will return true. Definition at line 70 of file Array_Base.cpp. References ACE_ALLOCATOR, ACE_Array_Base< T >::array_, ACE_Allocator::instance(), ACE_Array_Base< T >::size(), and ACE_Array_Base< T >::size_type.
00071 : max_size_ (s.size ()), 00072 cur_size_ (s.size ()), 00073 allocator_ (s.allocator_) 00074 { 00075 if (this->allocator_ == 0) 00076 this->allocator_ = ACE_Allocator::instance (); 00077 00078 ACE_ALLOCATOR (this->array_, 00079 (T *) this->allocator_->malloc (s.size () * sizeof (T))); 00080 for (size_type i = 0; i < this->size (); ++i) 00081 new (&this->array_[i]) T (s.array_[i]); 00082 } |
|
||||||||||
|
Clean up the array (e.g., delete dynamically allocated memory).
Definition at line 9 of file Array_Base.inl. References ACE_DES_ARRAY_FREE.
00010 {
00011 ACE_DES_ARRAY_FREE (this->array_,
00012 this->max_size_,
00013 this->allocator_->free,
00014 T);
00015 }
|
|
||||||||||
|
Definition at line 33 of file Array_Base.inl. References ACE_Array_Base< T >::array_.
00034 {
00035 return this->array_;
00036 }
|
|
||||||||||
|
Definition at line 19 of file Array_Base.inl. References ACE_Array_Base< T >::array_.
00020 {
00021 return this->array_;
00022 }
|
|
||||||||||
|
Definition at line 40 of file Array_Base.inl. References ACE_Array_Base< T >::array_, and ACE_Array_Base< T >::cur_size_.
|
|
||||||||||
|
Definition at line 26 of file Array_Base.inl. References ACE_Array_Base< T >::array_, and ACE_Array_Base< T >::cur_size_.
|
|
||||||||||||||||
|
Get an item in the array at location slot. Returns -1 if slot is not in range, else returns 0. Note that this function copies the item. If you want to avoid the copy, you can use the const operator [], but then you'll be responsible for range checking. Definition at line 149 of file Array_Base.cpp. References ACE_Array_Base< T >::array_, ACE_Array_Base< T >::in_range(), and ACE_Array_Base< T >::size_type.
|
|
||||||||||
|
Returns 1 if slot is within range, i.e., 0 >= slot < , else returns 0. Definition at line 86 of file Array_Base.inl. References ACE_Array_Base< T >::cur_size_, and ACE_Array_Base< T >::size_type. Referenced by ACE_Array_Base< T >::get(), and ACE_Array_Base< T >::set().
00087 {
00088 return index < this->cur_size_;
00089 }
|
|
||||||||||
|
Changes the size of the array to match . It copies the old contents into the new array. Return -1 on failure. It does not affect new_size Definition at line 164 of file Array_Base.cpp. References ACE_ALLOCATOR_RETURN, ACE_DES_ARRAY_FREE, ACE_Array_Base< T >::array_, ACE_Array_Base< T >::cur_size_, ACE_Array_Base< T >::max_size_, and ACE_Array_Base< T >::size_type.
00165 {
00166 if (new_size > this->max_size_)
00167 {
00168 T *tmp = 0;
00169
00170 ACE_ALLOCATOR_RETURN (tmp,
00171 (T *) this->allocator_->malloc (new_size * sizeof (T)),
00172 -1);
00173 for (size_type i = 0; i < this->cur_size_; ++i)
00174 new (&tmp[i]) T (this->array_[i]);
00175
00176 // Initialize the new portion of the array that exceeds the
00177 // previously allocated section.
00178 for (size_type j = this->cur_size_; j < new_size; ++j)
00179 new (&tmp[j]) T;
00180
00181 ACE_DES_ARRAY_FREE (this->array_,
00182 this->max_size_,
00183 this->allocator_->free,
00184 T);
00185 this->array_ = tmp;
00186 this->max_size_ = new_size;
00187 this->cur_size_ = new_size;
00188 }
00189
00190 return 0;
00191 }
|
|
||||||||||
|
Returns the of the array.
Definition at line 80 of file Array_Base.inl. References ACE_Array_Base< T >::max_size_. Referenced by ACE_Vector< T, DEFAULT_SIZE >::ACE_Vector(), ACE_DLL_Handle::get_dll_names(), ACE_DLL_Handle::open(), ACE_Vector< T, DEFAULT_SIZE >::push_back(), ACE_Vector< T, DEFAULT_SIZE >::resize(), and ACE_Array_Base< T >::size().
00081 {
00082 return this->max_size_;
00083 }
|
|
||||||||||
|
Assignment operator performs an assignment by making an exact copy of the contents of parameter , i.e., *this == s will return true. Note that if the of is >= than <s.max_size_> we can copy it without reallocating. However, if is < <s.max_size_> we must delete the , reallocate a new , and then copy the contents of . Definition at line 87 of file Array_Base.cpp. References ACE_DES_ARRAY_NOFREE, ACE_Array_Base< T >::array_, ACE_Array_Base< T >::cur_size_, ACE_Array_Base< T >::max_size_, ACE_Array_Base< T >::size(), ACE_Array_Base< T >::size_type, and ACE_Array_Base< T >::swap(). Referenced by ACE_Array< T >::operator=().
00088 {
00089 // Check for "self-assignment".
00090
00091 if (this != &s)
00092 {
00093 if (this->max_size_ < s.size ())
00094 {
00095 // Need to reallocate memory.
00096
00097 // Strongly exception-safe assignment.
00098 //
00099 // Note that we're swapping the allocators here, too.
00100 // Should we? Probably. "*this" should be a duplicate of
00101 // the "right hand side".
00102 ACE_Array_Base<T> tmp (s);
00103 this->swap (tmp);
00104 }
00105 else
00106 {
00107 // Underlying array is large enough. No need to reallocate
00108 // memory.
00109 //
00110 // "*this" still owns the memory for the underlying array.
00111 // Do not swap out the allocator.
00112 //
00113 // @@ Why don't we just drop the explicit destructor and
00114 // placement operator new() calls with a straight
00115 // element-by-element assignment? Is the existing
00116 // approach more efficient?
00117 // -Ossama
00118
00119 ACE_DES_ARRAY_NOFREE (this->array_,
00120 s.size (),
00121 T);
00122
00123 this->cur_size_ = s.size ();
00124
00125 for (size_type i = 0; i < this->size (); ++i)
00126 new (&this->array_[i]) T (s.array_[i]);
00127 }
00128 }
00129 }
|
|
||||||||||
|
Get item in the array at location slot. Doesn't perform range checking. Definition at line 98 of file Array_Base.inl. References ACE_Array_Base< T >::array_, and ACE_Array_Base< T >::size_type.
00099 {
00100 return this->array_[index];
00101 }
|
|
||||||||||
|
Set item in the array at location slot. Doesn't perform range checking. Definition at line 92 of file Array_Base.inl. References ACE_Array_Base< T >::array_, and ACE_Array_Base< T >::size_type.
00093 {
00094 return this->array_[index];
00095 }
|
|
||||||||||
|
Definition at line 61 of file Array_Base.inl.
00062 {
00063 return const_reverse_iterator (this->end ());
00064 }
|
|
||||||||||
|
Definition at line 47 of file Array_Base.inl.
00048 {
00049 return reverse_iterator (this->end ());
00050 }
|
|
||||||||||
|
Definition at line 68 of file Array_Base.inl.
00069 {
00070 return const_reverse_iterator (this->begin ());
00071 }
|
|
||||||||||
|
Definition at line 54 of file Array_Base.inl.
00055 {
00056 return reverse_iterator (this->begin ());
00057 }
|
|
||||||||||||||||
|
Set an item in the array at location slot. Returns -1 if slot is not in range, else returns 0. Definition at line 134 of file Array_Base.cpp. References ACE_Array_Base< T >::array_, ACE_Array_Base< T >::in_range(), and ACE_Array_Base< T >::size_type. Referenced by ACE_DLL_Handle::get_dll_names(), and ACE_DLL_Handle::open().
|
|
||||||||||
|
Changes the size of the array to match . It copies the old contents into the new array. Return -1 on failure. Definition at line 194 of file Array_Base.cpp. References ACE_Array_Base< T >::cur_size_, ACE_Array_Base< T >::max_size(), and ACE_Array_Base< T >::size_type.
|
|
||||||||||
|
Returns the of the array.
Reimplemented in ACE_Vector< T, DEFAULT_SIZE >. Definition at line 74 of file Array_Base.inl. References ACE_Array_Base< T >::cur_size_. Referenced by ACE_Array_Base< T >::ACE_Array_Base(), ACE_DLL_Handle::get_dll_names(), ACE_DLL_Handle::open(), ACE_Array_Base< T >::operator=(), ACE_Array< T >::operator==(), ACE_Vector< T, DEFAULT_SIZE >::push_back(), and ACE_Vector< T, DEFAULT_SIZE >::resize().
00075 {
00076 return this->cur_size_;
00077 }
|
|
||||||||||
|
Swap the contents of this array with the given array in an exception-safe manner. Definition at line 206 of file Array_Base.cpp. References ACE_Array_Base< T >::allocator_, ACE_Array_Base< T >::array_, ACE_Array_Base< T >::cur_size_, and ACE_Array_Base< T >::max_size_. Referenced by ACE_Array_Base< T >::operator=(), and ACE_Vector< T, DEFAULT_SIZE >::swap().
00207 {
00208 std::swap (this->max_size_ , rhs.max_size_);
00209 std::swap (this->cur_size_ , rhs.cur_size_);
00210 std::swap (this->array_ , rhs.array_);
00211 std::swap (this->allocator_, rhs.allocator_);
00212 }
|
|
|||||
|
Definition at line 191 of file Array_Base.h. |
|
|||||
|
Allocation strategy of the ACE_Array_Base.
Definition at line 189 of file Array_Base.h. Referenced by ACE_Array_Base< T >::swap(). |
|
|||||
|
Pointer to the array's storage buffer.
Definition at line 186 of file Array_Base.h. Referenced by ACE_Array_Base< T >::ACE_Array_Base(), ACE_Array_Base< T >::begin(), ACE_Array_Base< T >::end(), ACE_Array_Base< T >::get(), ACE_Array_Base< T >::max_size(), ACE_Array_Base< T >::operator=(), ACE_Array_Base< T >::operator[](), ACE_Array_Base< T >::set(), and ACE_Array_Base< T >::swap(). |
|
|||||
|
Current size of the array. This starts out being == to . However, if we are assigned a smaller array, then will become less than . The purpose of keeping track of both sizes is to avoid reallocating memory if we don't have to. Definition at line 183 of file Array_Base.h. Referenced by ACE_Array_Base< T >::end(), ACE_Array_Base< T >::in_range(), ACE_Array_Base< T >::max_size(), ACE_Array_Base< T >::operator=(), ACE_Array_Base< T >::size(), and ACE_Array_Base< T >::swap(). |
|
|||||
|
Maximum size of the array, i.e., the total number of elements in . Definition at line 174 of file Array_Base.h. Referenced by ACE_Array_Base< T >::max_size(), ACE_Array_Base< T >::operator=(), and ACE_Array_Base< T >::swap(). |
1.3.6