Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CThingArray Class Reference

The CThingArray class is a dynamically sized array that stores CThing pointers. More...

Collaboration diagram for CThingArray:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CThingArray ()
 The constructor for CThingArray simply calls the Construct function.
 ~CThingArray ()
 The destructor for CThingArray simply calls the Destruct function.
void Construct ()
 The Construct function readies the internal structure of the CThingArray for use.
void Destruct ()
 The Destruct function cleans up the internal structure of the CThingArray.
void AddCThing (CThing *t)
 The AddCThing function adds a new CThing to the CThingArray.
CThingReturnAt (unsigned long i) const
 The ReturnAt function is used to get a CThing stored in a specific position within the array.
void AddAt (unsigned long i, CThing *t)
 The AddAt function replaces an element of the array with a new CThing.
void RemoveAt (unsigned long i)
 The RemoveAt function removes the CThing at a given position from the Array.
unsigned long NumberOfThings () const
 The NumberOfThings function returns the number of elements currently in the array.

Public Attributes

CThing ** ar
 The internal array data.
unsigned long size
 The number of available elements in the internal array.
unsigned long used
 The number of elements in the internal array that are currently used.

Detailed Description

The CThingArray class is a dynamically sized array that stores CThing pointers.

The CThingArray class is used almost universally whenever a list of CThings needs to be stored. The CThingArray class does not handle reference counting or garbage collection. The array itself stores pointers to CThings, not copies of them. Whenever array operations are mentioned remember that you are dealing with pointers to these CThings. This class' implementation is nearly identical to LongArray, Int8Array, and PointerArray.

See also:
LongArray

Int8Array

PointerArray

AddCThingReference()

ReleaseCThing()


Constructor & Destructor Documentation

CENTUMSHAREDCODE_API CThingArray::CThingArray  ) 
 

The constructor for CThingArray simply calls the Construct function.

See also:
CThingArray::Construct()

CENTUMSHAREDCODE_API CThingArray::~CThingArray  ) 
 

The destructor for CThingArray simply calls the Destruct function.

See also:
CThingArray::Destruct()


Member Function Documentation

CENTUMSHAREDCODE_API void CThingArray::AddAt unsigned long  i,
CThing t
 

The AddAt function replaces an element of the array with a new CThing.

If you try to replace an element at a position greater than the number of elements in the array nothing will happen. This was the source of more than one error, so prehaps it is best to think of the function as being called ReplaceAt.

Parameters:
i the index of the element to be replaced.
t the new CThing that will replace the old one.

CENTUMSHAREDCODE_API void CThingArray::AddCThing CThing t  ) 
 

The AddCThing function adds a new CThing to the CThingArray.

If there is not enough storage in the internal array it will be expanded. The new CThing is always added to the end of the array. The size of the array is expanded by 8 (8 pointer not 8 bytes) everytime it needs to be resized.

Parameters:
t a CThing that is to be stored in this CThingArray

CENTUMSHAREDCODE_API void CThingArray::Construct  ) 
 

The Construct function readies the internal structure of the CThingArray for use.

To reset a CThingArray you can call Destruct on it followed by a call to Construct.

See also:
CThingArray::Destruct()

CENTUMSHAREDCODE_API void CThingArray::Destruct  ) 
 

The Destruct function cleans up the internal structure of the CThingArray.

Destruct does not affect the CThings that were stored in it at the time in any way.

See also:
CThingArray::Construct()

CENTUMSHAREDCODE_API void CThingArray::RemoveAt unsigned long  i  ) 
 

The RemoveAt function removes the CThing at a given position from the Array.

The old CThing is replaced by what was previously the last CThing in the array and then the active part of the array is reduced by one. The RemoveAt function does not preserve the order of elements. Attempting to remove a position greater than the number of elements in the array has no effect.

Parameters:
i the index of the CThing to be removed.

CENTUMSHAREDCODE_API CThing * CThingArray::ReturnAt unsigned long  i  )  const
 

The ReturnAt function is used to get a CThing stored in a specific position within the array.

If you attempt to return a CThing at a position greater than the number of elements stored in the array NULL will be the result.

Parameters:
i the index of the CThing to be returned.
Returns:
the CThing pointer that was requested.


The documentation for this class was generated from the following files:
Generated on Sat Apr 16 16:31:09 2005 for Centum API by  doxygen 1.4.2