ACE 7.1.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
ACE_Array_Base< T > Class Template Reference

Implement a simple dynamic array. More...

#include <Array_Base.h>

Inheritance diagram for ACE_Array_Base< T >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Array_Base< T >:
Collaboration graph
[legend]

Public Types

typedefTYPE
 
typedef ACE_Array_Iterator< T > ITERATOR
 
typedefvalue_type
 
typedef value_typeiterator
 
typedef value_type const * const_iterator
 
typedef value_typereference
 
typedef value_type const & const_reference
 
typedef value_typepointer
 
typedef value_type const * const_pointer
 
typedef ptrdiff_t difference_type
 
typedef ACE_Allocator::size_type size_type
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 

Public Member Functions

 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 default_value.
 
 ACE_Array_Base (ACE_Array_Base< T > const &s)
 
void operator= (ACE_Array_Base< T > const &s)
 
 ~ACE_Array_Base ()
 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 () const
 Returns the <cur_size_> of the array.
 
int size (size_type new_size)
 
size_type max_size () const
 Returns the <max_size_> of the array.
 
int max_size (size_type new_size)
 
Forward Iterator Accessors

Forward iterator accessors.

iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 

Reverse Iterator Accessors

Reverse iterator accessors.

size_type max_size_
 
size_type cur_size_
 
value_typearray_
 Pointer to the array's storage buffer.
 
ACE_Allocatorallocator_
 Allocation strategy of the ACE_Array_Base.
 
class ACE_Array_Iterator< T >
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
void swap (ACE_Array_Base< T > &array)
 
bool in_range (size_type slot) const
 

Detailed Description

template<class T>
class ACE_Array_Base< T >

Implement a simple dynamic array.

This parametric class implements a simple dynamic array; resizing must be controlled by the user. No comparison or find operations are implemented.

Member Typedef Documentation

◆ const_iterator

template<class T >
typedef value_type const* ACE_Array_Base< T >::const_iterator

◆ const_pointer

template<class T >
typedef value_type const* ACE_Array_Base< T >::const_pointer

◆ const_reference

template<class T >
typedef value_type const& ACE_Array_Base< T >::const_reference

◆ const_reverse_iterator

template<class T >
typedef std::reverse_iterator<const_iterator> ACE_Array_Base< T >::const_reverse_iterator

◆ difference_type

template<class T >
typedef ptrdiff_t ACE_Array_Base< T >::difference_type

◆ ITERATOR

template<class T >
typedef ACE_Array_Iterator<T> ACE_Array_Base< T >::ITERATOR

◆ iterator

template<class T >
typedef value_type* ACE_Array_Base< T >::iterator

◆ pointer

template<class T >
typedef value_type* ACE_Array_Base< T >::pointer

◆ reference

template<class T >
typedef value_type& ACE_Array_Base< T >::reference

◆ reverse_iterator

template<class T >
typedef std::reverse_iterator<iterator> ACE_Array_Base< T >::reverse_iterator

◆ size_type

template<class T >
typedef ACE_Allocator::size_type ACE_Array_Base< T >::size_type

◆ TYPE

template<class T >
typedef T ACE_Array_Base< T >::TYPE

◆ value_type

template<class T >
typedef T ACE_Array_Base< T >::value_type

Constructor & Destructor Documentation

◆ ACE_Array_Base() [1/3]

template<class T >
ACE_Array_Base< T >::ACE_Array_Base ( size_type size = 0,
ACE_Allocator * the_allocator = 0 )

Dynamically create an uninitialized array.

◆ ACE_Array_Base() [2/3]

template<class T >
ACE_Array_Base< T >::ACE_Array_Base ( size_type size,
T const & default_value,
ACE_Allocator * the_allocator = 0 )

Dynamically initialize the entire array to the default_value.

◆ ACE_Array_Base() [3/3]

template<class T >
ACE_Array_Base< T >::ACE_Array_Base ( ACE_Array_Base< T > const & s)

The copy constructor performs initialization by making an exact copy of the contents of parameter s, i.e., *this == s will return true.

◆ ~ACE_Array_Base()

template<class T >
ACE_Array_Base< T >::~ACE_Array_Base ( )
inline

Clean up the array (e.g., delete dynamically allocated memory).

Member Function Documentation

◆ begin() [1/2]

template<class T >
ACE_Array_Base< T >::iterator ACE_Array_Base< T >::begin ( )
inline

◆ begin() [2/2]

template<class T >
ACE_Array_Base< T >::const_iterator ACE_Array_Base< T >::begin ( ) const
inline

◆ end() [1/2]

template<class T >
ACE_Array_Base< T >::iterator ACE_Array_Base< T >::end ( )
inline

◆ end() [2/2]

template<class T >
ACE_Array_Base< T >::const_iterator ACE_Array_Base< T >::end ( ) const
inline

◆ get()

template<class T >
int ACE_Array_Base< T >::get ( T & item,
size_type slot ) const

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.

◆ in_range()

template<class T >
bool ACE_Array_Base< T >::in_range ( size_type slot) const
inlineprotected

Returns 1 if slot is within range, i.e., 0 >= slot < cur_size_, else returns 0.

◆ max_size() [1/2]

template<class T >
ACE_Array_Base< T >::size_type ACE_Array_Base< T >::max_size ( ) const
inline

Returns the <max_size_> of the array.

◆ max_size() [2/2]

template<class T >
int ACE_Array_Base< T >::max_size ( size_type new_size)

Changes the size of the array to match new_size. It copies the old contents into the new array. Return -1 on failure. It does not affect new_size

◆ operator=()

template<class T >
void ACE_Array_Base< T >::operator= ( ACE_Array_Base< T > const & s)

Assignment operator performs an assignment by making an exact copy of the contents of parameter s, i.e., *this == s will return true. Note that if the <max_size_> of <array_> is >= than <s.max_size_> we can copy it without reallocating. However, if <max_size_> is < <s.max_size_> we must delete the <array_>, reallocate a new <array_>, and then copy the contents of .

◆ operator[]() [1/2]

template<class T >
T & ACE_Array_Base< T >::operator[] ( size_type slot)

Set item in the array at location slot. Doesn't perform range checking.

◆ operator[]() [2/2]

template<class T >
T const & ACE_Array_Base< T >::operator[] ( size_type slot) const

Get item in the array at location slot. Doesn't perform range checking.

◆ rbegin() [1/2]

template<class T >
ACE_Array_Base< T >::reverse_iterator ACE_Array_Base< T >::rbegin ( )
inline

Maximum size of the array, i.e., the total number of T elements in array_.

◆ rbegin() [2/2]

template<class T >
ACE_Array_Base< T >::const_reverse_iterator ACE_Array_Base< T >::rbegin ( ) const
inline

Maximum size of the array, i.e., the total number of T elements in array_.

◆ rend() [1/2]

template<class T >
ACE_Array_Base< T >::reverse_iterator ACE_Array_Base< T >::rend ( )
inline

Maximum size of the array, i.e., the total number of T elements in array_.

◆ rend() [2/2]

template<class T >
ACE_Array_Base< T >::const_reverse_iterator ACE_Array_Base< T >::rend ( ) const
inline

Maximum size of the array, i.e., the total number of T elements in array_.

◆ set()

template<class T >
int ACE_Array_Base< T >::set ( T const & new_item,
size_type slot )

Set an item in the array at location slot. Returns -1 if slot is not in range, else returns 0.

◆ size() [1/2]

template<class T >
ACE_Array_Base< T >::size_type ACE_Array_Base< T >::size ( ) const
inline

Returns the <cur_size_> of the array.

◆ size() [2/2]

template<class T >
int ACE_Array_Base< T >::size ( size_type new_size)

Changes the size of the array to match new_size. It copies the old contents into the new array. Return -1 on failure.

◆ swap()

template<class T >
void ACE_Array_Base< T >::swap ( ACE_Array_Base< T > & array)

Swap the contents of this array with the given array in an exception-safe manner.

Friends And Related Symbol Documentation

◆ ACE_Array_Iterator< T >

template<class T >
friend class ACE_Array_Iterator< T >
friend

Maximum size of the array, i.e., the total number of T elements in array_.

Member Data Documentation

◆ allocator_

template<class T >
ACE_Allocator* ACE_Array_Base< T >::allocator_
protected

Allocation strategy of the ACE_Array_Base.

◆ array_

template<class T >
value_type* ACE_Array_Base< T >::array_
protected

Pointer to the array's storage buffer.

◆ cur_size_

template<class T >
size_type ACE_Array_Base< T >::cur_size_
protected

Current size of the array. This starts out being == to <max_size_>. However, if we are assigned a smaller array, then <cur_size_> will become less than <max_size_>. The purpose of keeping track of both sizes is to avoid reallocating memory if we don't have to.

◆ max_size_

template<class T >
size_type ACE_Array_Base< T >::max_size_
protected

Maximum size of the array, i.e., the total number of T elements in array_.


The documentation for this class was generated from the following files: