ACE  6.0.6
Public Types | Public Member Functions | Protected Attributes | Friends
ACE_Vector Class Reference

Defines an STL-like vector container. More...

#include <Vector_T.h>

Inheritance diagram for ACE_Vector:
Inheritance graph
Collaboration diagram for ACE_Vector:
Collaboration graph

List of all members.

Public Types

typedef ACE_Vector_Iterator< T,

Public Member Functions

 ACE_Vector (const size_t init_size=DEFAULT_SIZE, ACE_Allocator *alloc=0)
 ~ACE_Vector ()
size_t capacity (void) const
size_t size (void) const
void clear (void)
void resize (const size_t new_size, const T &t)
void push_back (const T &elem)
void pop_back (void)
void dump (void) const
bool operator== (const ACE_Vector< T, DEFAULT_SIZE > &s) const
 Equality comparison operator.
bool operator!= (const ACE_Vector< T, DEFAULT_SIZE > &s) const
 Inequality comparison operator.
void swap (ACE_Vector &rhs)

Protected Attributes

size_t length_
size_t curr_max_size_


class ACE_Vector_Iterator< T, DEFAULT_SIZE >

Detailed Description

Defines an STL-like vector container.

This is an STL-like template vector container, a wrapper around ACE_Array. It provides at least the basic std::vector look and feel: push_back(), clear(), resize(), capacity(). This template class uses the copy semantic paradigm, though it is okay to use reference counted smart pointers (see ACE_Ptr<T>) with this template class.

Requirements and Performance Characteristics

Member Typedef Documentation

typedef ACE_Vector_Iterator<T, DEFAULT_SIZE> ACE_Vector::Iterator

A short name for iterator for ACE_Vector.

Constructor & Destructor Documentation

ACE_Vector::ACE_Vector ( const size_t  init_size = DEFAULT_SIZE,
ACE_Allocator alloc = 0 

General constructor.

init_sizeInitial size of the vector with the default value of DEFAULT_SIZE
allocPointer to an ACE allocator. If it is NULL then the default ACE allocator is used
ACE_Vector::~ACE_Vector ( )


Member Function Documentation

size_t ACE_Vector::capacity ( void  ) const

Returns the current vector capacity, that is, the currently allocated buffer size.

Current buffer size of the vector
void ACE_Vector::clear ( void  )

Clears out the vector. It does not reallocate the vector's buffer, it is just sets the vector's dynamic size to 0.

void ACE_Vector::dump ( void  ) const

This function dumps the content of the vector. TO BE MOVED out of this class. It needs to be implemented as a global template function that accepts a const ACE_Vector<T>, in order to make instances of this class compile on Linux, AIX. G++ and xlC have template instantiation algoriths, which are different from the one in Visual C++. The algorithms try to instantiate ALL methods declared in the template class, regardless of whether the functions are used or not. That is, all of the classes, that are used as elements in ACE_Vector's, have to have the dump() methods defined in them (seems to be overkill).

This function calls T::dump() for each element of the vector.

bool ACE_Vector::operator!= ( const ACE_Vector< T, DEFAULT_SIZE > &  s) const

Inequality comparison operator.

Compare this vector with

  • s for inequality such that *this !=
  • s is always the complement of the boolean return value of *this ==
  • s.
bool ACE_Vector::operator== ( const ACE_Vector< T, DEFAULT_SIZE > &  s) const

Equality comparison operator.

Compare this vector with

  • s for equality. Two vectors are equal if their sizes are equal and all the elements are equal.
void ACE_Vector::pop_back ( void  )

Deletes the last element from the vector ("pop back"). What this function really does is decrement the dynamic size of the vector. The vector's buffer does not get reallocated for performance.

void ACE_Vector::push_back ( const T &  elem)

Appends a new element to the vector ("push back"). If the dynamic size of the vector is equal to the capacity of the vector (vector is at capacity), the vector automatically doubles its capacity.

elemA reference to the new element to be appended. By default, this parameters gets initialized with the default value of the class T.
void ACE_Vector::resize ( const size_t  new_size,
const T &  t 

Resizes the vector to the new capacity. If the vector's current capacity is smaller than the size to be specified, then the buffer gets reallocated. If the new capacity is less than the current capacity of the vector, the buffer size stays the same.

new_sizeNew capacity of the vector
tA filler value (of the class T) for initializing the elements of the vector with. By default, if this parameter is not specified, the default value of the class T will be used (for more detail, see the initialization clause for this parameter).
size_t ACE_Vector::size ( void  ) const

Returns the vector's dynamic size / actual current size of the vector. Do not confuse it with ACE_Array::size(), which returns the array's capacity. Unfortunately, ACE is not very consistent with the function names.

Dynamic size / actual current size of the vector.
void ACE_Vector::swap ( ACE_Vector rhs)

Friends And Related Function Documentation

friend class ACE_Vector_Iterator< T, DEFAULT_SIZE > [friend]

Member Data Documentation

size_t ACE_Vector::curr_max_size_ [protected]

Current capacity (buffer size) of the vector.

size_t ACE_Vector::length_ [protected]

Dynamic size (length) of the vector.

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines