Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

rdValueArray< T > Class Template Reference

Note- this class has been replaced by class rdArray<T>. More...

#include <rdValueArray.h>

Inheritance diagram for rdValueArray< T >:

rdObject List of all members.

Public Member Functions

 rdValueArray (int aCapacity=128, const char *aName="UNKNOWN")
 Default constructor.

virtual ~rdValueArray ()
 Destructor.

void setDescription (const char *aDescrip=NULL)
 Set the description of this storage.

const char * getDescription () const
 Get a description of this storage.

bool ensureCapacity (int aCapacity)
 Ensure that the capacity of this array is at least the specified amount.

int getCapacity () const
 Get the capacity of this storage instance.

void setCapacityIncrement (int aIncrement=-1)
 Set the amount by which the capacity is increased.

int getCapacityIncrement () const
 Get the amount by which the capacity is increased.

void setFirstEmpty (int aIndex=0)
 Set the first empty element of the array to a specified value.

int getFirstEmpty () const
 Get the index of the first empty array element.

int append (const T &aValue)
 Append a value onto the array.

int append (const rdValueArray< T > &aArray)
 Append an array of values.

void set (int aIndex, const T &aValue)
 Set the value at a specified index.

T & get (int aIndex) const
 Get the pointer at a specified array index.

T & getLast () const
 Get the last pointer in the array.

void insert (int aIndex, const T &aValue)
void remove (int aIndex)
 Remove an object by index.

void remove (const T &aValue)
int searchSequential (const T &aValue, int aStartIndex=0)
int searchBinary (const T &aValue)
virtual void updateObject (bool aDeep=true)
 Update this object based on its XML node.

virtual void updateNode (bool aDeep=true)
 Update the XML node that represents this object.


Static Public Attributes

const int CAPMIN = rdValueArray_CAPMIN
 Minimum capacity.


Protected Attributes

char * _descrip
 Description.

int _capacity
 Current capacity.

int _capacityIncrement
 Increment by which the current capacity is increased when the capacity of this storage instance is reached.

T * _array
 Array of values.


Private Member Functions

void setNull ()
 Set all member variables to their null or default values.


Private Attributes

int _firstEmpty
 Index of the first empty array element.


Detailed Description

template<class T>
class rdValueArray< T >

Note- this class has been replaced by class rdArray<T>.

A class for storing an array of values of type T. The capacity of the class grows as needed. To use this template for a class of type T, class T must implement the following methods: default constructor, copy constructor, assignment operator (=), equality operator (==), and less than operator (<).

Version:
1.0
Author:
Frank C. Anderson


Constructor & Destructor Documentation

template<class T>
rdValueArray< T >::rdValueArray int  aCapacity = 128,
const char *  aName = "UNKNOWN"
 

Default constructor.

Note- this class has been replaced by class rdArray<T>.

template<class T>
rdValueArray< T >::~rdValueArray  )  [virtual]
 

Destructor.

When the array is deleted, references to elements of this array become invalid.


Member Function Documentation

template<class T>
int rdValueArray< T >::append const T &  aValue  ) 
 

Append a value onto the array.

Parameters:
aValue Value to be appended.
Returns:
Index to the new first empty element (or end) of the array.

template<class T>
bool rdValueArray< T >::ensureCapacity int  aCapacity  ) 
 

Ensure that the capacity of this array is at least the specified amount.

Parameters:
aCapacity Desired capacity.
Returns:
true if the capacity was successfully obtained, false otherwise.

template<class T>
rdObject * rdValueArray< T >::get int  aIndex  )  const
 

Get the pointer at a specified array index.

If the index is greater than or equal to the capacity of the array, NULL is returned.

Parameters:
aIndex Index of the desired array element.
Returns:
Pointer at aIndex or NULL.

template<class T>
const char * rdValueArray< T >::getDescription  )  const
 

Get a description of this storage.

Returns:
Description.

template<class T>
int rdValueArray< T >::getFirstEmpty  )  const
 

Get the index of the first empty array element.

Returns:
Index of the first empty array element.

template<class T>
rdObject * rdValueArray< T >::getLast  )  const
 

Get the last pointer in the array.

Returns:
Last pointer in the array.

template<class T>
rdObject * rdValueArray< T >::remove int  aIndex  ) 
 

Remove an object by index.

When an object is removed, the array locations of all objects following the removed object are shifted down by 1.

The caller is responsible for deleting the removed object.

To remove an object without shifting the array locations of all objects following the removed object, use the method set().

Parameters:
aIndex Index of the object to remove.
Returns:
Pointer to the removed object; NULL if there was no object at aIndex.
See also:
set()

template<class T>
void rdValueArray< T >::set int  aIndex,
const T &  aValue
 

Set the value at a specified index.

Parameters:
aIndex Index of the array element to be set. It is permissible for aIndex to be past the current end of the array. Values in the array from _firstEmpty to aIndex will be intialized using the default constructor of class T.
aValue Value.

template<class T>
void rdValueArray< T >::setCapacityIncrement int  aIncrement = -1  ) 
 

Set the amount by which the capacity is increased.

If the specified increment is less than 0 or this method is called with no argument, the capacity is set to double whenever the capacity is exceeded.

Parameters:
aIncrement Desired capacity increment.

template<class T>
void rdValueArray< T >::setDescription const char *  aDescrip = NULL  ) 
 

Set the description of this storage.

If the last character of a description is a carriage return, it is stripped.

Parameters:
aDescrip Description.

template<class T>
void rdValueArray< T >::setFirstEmpty int  aIndex = 0  ) 
 

Set the first empty element of the array to a specified value.

This method essentially resets the array so that all elements stored at a specified index or after are no longer considered valid: append() will simply over-write these elements.

Parameters:
aIndex Index at which to start appending new values onto the array. The default value is 0. If aIndex is greater than or equal to the current value of _firstEmpty, no change is made. If aIndex is less than 0, the array is set to start storing at index 0.
See also:
getFirstEmpty()

template<class T>
virtual void rdValueArray< T >::updateNode bool  aDeep = true  )  [virtual]
 

Update the XML node that represents this object.

Parameters:
aDeep If true, update the XML node of this object AND the XML nodes of all class members that are rdObjects (child nodes); if false, update only the XML node of this object without updating the XML nodes of its children.

Reimplemented from rdObject.

template<class T>
virtual void rdValueArray< T >::updateObject bool  aDeep = true  )  [virtual]
 

Update this object based on its XML node.

Parameters:
aDeep If true, update this object and all its child objects (member variables that are rdObject's); if false, update only the member variables that are not rdObject's.

Reimplemented from rdObject.


The documentation for this class was generated from the following files:
Generated on Wed Aug 20 02:17:13 2003 for Simulation Software by doxygen1.3