- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Utils::Containers::DynamicArrayTemplate< Data > Class Template Reference

`#include <DynamicArrayTemplate.h>`

Inheritance diagram for Mers::Utils::Containers::DynamicArrayTemplate< Data >:

[legend]
Collaboration diagram for Mers::Utils::Containers::DynamicArrayTemplate< Data >:

[legend]
List of all members.

## Public Types
typedef Data * | pointer
typedef const Data * | const_pointer
typedef DynamicArrayTemplate< Data > | ContainerType
typedef IteratorTemplate< const_pointer, ContainerType > | const_iterator
typedef IteratorTemplate< pointer, ContainerType > | iterator
typedef const_iterator | ConstantIterator
typedef iterator | Iterator
## Public Member Functions
| DynamicArrayTemplate (bool myOwnershipStatus)
| DynamicArrayTemplate (DynamicArrayTemplate< Data > const &other)
virtual | ~DynamicArrayTemplate ()
Iterator | begin ()
ConstantIterator | begin () const
Iterator | end ()
ConstantIterator | end () const
int | pushBack (Data *data)
int | push_back (Data *data)
Data * | popBack ()
Data * | pop_back ()
void | insert (unsigned int elementIndex, Data *data)
Data *& | operator[] (int elementIndex)
Data *& | operator[] (unsigned int elementIndex)
Data const *& | operator[] (int elementIndex) const
Data const *& | operator[] (unsigned int elementIndex) const
DynamicArrayTemplate< Data > const & | operator= (DynamicArrayTemplate< Data > const &other)
DynamicArrayTemplate< Data > const & | operator+= (DynamicArrayTemplate< Data > const &other)
DynamicArrayTemplate< Data > const & | operator+= (Data const &data)
bool | operator== (DynamicArrayTemplate< Data > const &other) const
bool | operator!= (DynamicArrayTemplate< Data > const &other) const
## Protected Member Functions
void | printElement (std::ostream &out, void const *element) const
void | deleteElement (void *element) const
void * | newElement (void const *element) const
bool | isEqual (void const *element1, void const *element2) const

## Detailed Description

### template<class Data>
class Mers::Utils::Containers::DynamicArrayTemplate< Data >

Implements the generic template class for dynamic array. To use this class, the Data class must define: prints the data element to the specified stream void print(ostream &) const creates a copy of the element, or returns NULL to indicate the element couldn't be copied Data * duplicate() const compares the two elements and returns true if they are equal operator ==(Data const &) const

Definition at line 36 of file DynamicArrayTemplate.h.

## Constructor & Destructor Documentation

template<class Data>

Mers::Utils::Containers::DynamicArrayTemplate< Data >::DynamicArrayTemplate | ( | bool | myOwnershipStatus | ) | `[inline]`

Creates a new, empty array

Definition at line 46 of file DynamicArrayTemplate.h.

template<class Data>

Mers::Utils::Containers::DynamicArrayTemplate< Data >::DynamicArrayTemplate | ( | DynamicArrayTemplate< Data > const & | other | ) | `[inline]`

Creates a new array with a copy of the contents from the other array. This can be an expensive operation.

Parameters:

  | other | the array whos contents are copied

Definition at line 61 of file DynamicArrayTemplate.h.

template<class Data>

virtual Mers::Utils::Containers::DynamicArrayTemplate< Data >::~DynamicArrayTemplate | ( |  | ) | `[inline, virtual]`

Destroys the array

Definition at line 80 of file DynamicArrayTemplate.h.

## Member Function Documentation

template<class Data>

Iterator Mers::Utils::Containers::DynamicArrayTemplate< Data >::begin | ( |  | ) | `[inline]`

Returns a iterator that points to the first element of this array.

Returns:
  a iterator that starts this object

Definition at line 106 of file DynamicArrayTemplate.h.

template<class Data>

ConstantIterator Mers::Utils::Containers::DynamicArrayTemplate< Data >::begin | ( |  | ) | const`[inline]`

Returns a constant iterator that points to the first element of this array.

Returns:
  a constant iterator that starts this object

Definition at line 116 of file DynamicArrayTemplate.h.

template<class Data>

Iterator Mers::Utils::Containers::DynamicArrayTemplate< Data >::end | ( |  | ) | `[inline]`

Returns a iterator that points just past the last element of this array.

Returns:
  a iterator that ends this object

Definition at line 127 of file DynamicArrayTemplate.h.

template<class Data>

ConstantIterator Mers::Utils::Containers::DynamicArrayTemplate< Data >::end | ( |  | ) | const`[inline]`

Returns a constant iterator that points just past the last element of this array.

Returns:
  a constant iterator that ends this object

Definition at line 137 of file DynamicArrayTemplate.h.

template<class Data>

int Mers::Utils::Containers::DynamicArrayTemplate< Data >::pushBack | ( | Data * | data | ) | `[inline]`

Adds a data element to the end of the array, allocating space if necessary for it to fit. This object assumes ownership of data object and will delete it when this object is destroyed.

Parameters:

  | data | pointer to the data being added

Returns:
  0 on success or a positive number if the data could not be added

Definition at line 153 of file DynamicArrayTemplate.h.

Referenced by Mers::Utils::Containers::DynamicArrayTemplate< Mers::Executives::DeductiveController::Command::CommandDispatcherEntry::Parameter >::push_back().

template<class Data>

int Mers::Utils::Containers::DynamicArrayTemplate< Data >::push_back | ( | Data * | data | ) | `[inline]`

Adds a data element to the end of the array, allocating space if necessary for it to fit. This object assumes ownership of data object and will delete it when this object is destroyed, if appopriate.

Parameters:

  | data | pointer to the data being added

Returns:
  0 on success or a positive number if the data could not be added

Definition at line 169 of file DynamicArrayTemplate.h.

template<class Data>

Data* Mers::Utils::Containers::DynamicArrayTemplate< Data >::popBack | ( |  | ) | `[inline]`

Returns the last element of the array and removes it from the array, also reduces the size of the array should it fall below 1/4 full.

Returns:
  the data element at the end of the current array

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 181 of file DynamicArrayTemplate.h.

Referenced by Mers::Utils::Containers::DynamicArrayTemplate< Mers::Executives::DeductiveController::Command::CommandDispatcherEntry::Parameter >::pop_back().

template<class Data>

Data* Mers::Utils::Containers::DynamicArrayTemplate< Data >::pop_back | ( |  | ) | `[inline]`

returns the last element of the array and removes it from the array, also reduces the size of the array should it fall below 1/4 full.

Returns:
  the data element at the end of the current array

Definition at line 192 of file DynamicArrayTemplate.h.

template<class Data>

void Mers::Utils::Containers::DynamicArrayTemplate< Data >::insert | ( | unsigned int | elementIndex,
|  | Data * | data |
| ) |  |  | `[inline]`

Inserts a new element at the specified index.

Parameters:

  | elementIndex | the index that the item should be inserted at
  | data | the data being inserted

Definition at line 205 of file DynamicArrayTemplate.h.

template<class Data>

Data* & Mers::Utils::Containers::DynamicArrayTemplate< Data >::operator[] | ( | int | elementIndex | ) | `[inline]`

retrieves the element at the specified index and returns it

Parameters:

  | elementIndex | location of the element to be accessed

Returns:
  the element requested if index is in range, otherwise it returns NULL

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 223 of file DynamicArrayTemplate.h.

template<class Data>

Data* & Mers::Utils::Containers::DynamicArrayTemplate< Data >::operator[] | ( | unsigned int | elementIndex | ) | `[inline]`

retrieves the element at the specified index and returns it

Parameters:

  | elementIndex | location of the element to be accessed

Returns:
  the element requested if index is in range, otherwise it returns NULL

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 236 of file DynamicArrayTemplate.h.

template<class Data>

Data const* & Mers::Utils::Containers::DynamicArrayTemplate< Data >::operator[] | ( | int | elementIndex | ) | const`[inline]`

retrieves the element at the specified index and returns it

Parameters:

  | elementIndex | location of the element to be accessed

Returns:
  the element requested if index is in range, otherwise it returns NULL

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 249 of file DynamicArrayTemplate.h.

template<class Data>

Data const* & Mers::Utils::Containers::DynamicArrayTemplate< Data >::operator[] | ( | unsigned int | elementIndex | ) | const`[inline]`

retrieves the element at the specified index and returns it

Parameters:

  | elementIndex | location of the element to be accessed

Returns:
  the element requested if index is in range, otherwise it returns NULL

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 262 of file DynamicArrayTemplate.h.

template<class Data>

DynamicArrayTemplate<Data> const& Mers::Utils::Containers::DynamicArrayTemplate< Data >::operator= | ( | DynamicArrayTemplate< Data > const & | other | ) | `[inline]`

Copies the data from the other array to this array. This can be expensive for long arrays. The origional data in this array is destroyed.

Parameters:

  | other | the array supplying the data for this array

Returns:
  the other array

Definition at line 276 of file DynamicArrayTemplate.h.

template<class Data>

DynamicArrayTemplate<Data> const& Mers::Utils::Containers::DynamicArrayTemplate< Data >::operator+= | ( | DynamicArrayTemplate< Data > const & | other | ) | `[inline]`

Appends a copy of the data from the other array to this array. This can be expensive for long arrays.

Parameters:

  | other | the array supplying the data for this array

Returns:
  this array

Definition at line 289 of file DynamicArrayTemplate.h.

template<class Data>

DynamicArrayTemplate<Data> const& Mers::Utils::Containers::DynamicArrayTemplate< Data >::operator+= | ( | Data const & | data | ) | `[inline]`

appends a copy of the data to this array. This is the same as pushBack except the data here is copied first, so this object doesn't assume ownership of data

Parameters:

  | data | the element being copied and added to this array

Returns:
  this array

Definition at line 303 of file DynamicArrayTemplate.h.

template<class Data>

bool Mers::Utils::Containers::DynamicArrayTemplate< Data >::operator== | ( | DynamicArrayTemplate< Data > const & | other | ) | const`[inline]`

Returns true if the two arrays have all the same elements in the same order.

Parameters:

  | other | the array being compared to this array

Returns:
  true if the two arrays have the same elements in the same order

Definition at line 317 of file DynamicArrayTemplate.h.

template<class Data>

bool Mers::Utils::Containers::DynamicArrayTemplate< Data >::operator!= | ( | DynamicArrayTemplate< Data > const & | other | ) | const`[inline]`

Returns false if the two arrays have all the same elements in the same order.

Parameters:

  | other | the array being compared to this array

Returns:
  false if the two arrays have the same elements in the same order

Definition at line 331 of file DynamicArrayTemplate.h.

template<class Data>

void Mers::Utils::Containers::DynamicArrayTemplate< Data >::printElement | ( | std::ostream & | out,
|  | void const * | element |
| ) |  |  | const`[inline, protected, virtual]`

Prints the element of this array to the ostream out. This is called by the DynamicArray::operator<< for each element being printed.

Parameters:

  | out | the stream being printed to
  | element | the element being printed

Implements Mers::Utils::Containers::DynamicArray.

Definition at line 351 of file DynamicArrayTemplate.h.

template<class Data>

void Mers::Utils::Containers::DynamicArrayTemplate< Data >::deleteElement | ( | void * | element | ) | const`[inline, protected, virtual]`

Called when an element should be deleted because it's storage space is being deleted. This function deletes the element (Data).

Parameters:

  | element | the BaesModelAssignment to delete

Implements Mers::Utils::Containers::DynamicArray.

Definition at line 365 of file DynamicArrayTemplate.h.

template<class Data>

void* Mers::Utils::Containers::DynamicArrayTemplate< Data >::newElement | ( | void const * | element | ) | const`[inline, protected, virtual]`

Creates and returns a new Data that is a copy of the Data element.

Parameters:

  | element | the element being copied

Returns:
  the new Data object that is a copy of element

Implements Mers::Utils::Containers::DynamicArray.

Definition at line 378 of file DynamicArrayTemplate.h.

template<class Data>

bool Mers::Utils::Containers::DynamicArrayTemplate< Data >::isEqual | ( | void const * | element1,
|  | void const * | element2 |
| ) |  |  | const`[inline, protected, virtual]`

Returns true if the two elements are equal. This default function returns true if the pointers are the same.

Parameters:

  | element1 | the first element in the comparison
  | element2 | the second element in the comparison

Returns:
  true if they are the equal and false if they are not equal

Reimplemented from Mers::Utils::Containers::DynamicArray.

Definition at line 394 of file DynamicArrayTemplate.h.

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

- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Containers/DynamicArrayTemplate.h