Main Page   Class Hierarchy   Compound List   File List   Compound Members  

GlDynArray Class Template Reference

A dynamic array class. More...

#include <gldynarray.h>

List of all members.

Public Methods

unsigned NotFound () const
 Returned by failed search.

bool Empty () const
 Returns true if this contains nothing.

void Clear ()
 delete the contents of this array.

T & operator[] (unsigned i) const
 Array access.

T * Memory ()
 Access to the base of array memory.

Item (unsigned i) const
 Fetch an item, by reference, at the index given.

T * ItemPointer (unsigned i) const
 Fetch an item, by pointer, at the index given.

void SetItem (unsigned i, const T &t)
 Set the item at the given index.

unsigned Count () const
 The number of items in the array. More...

unsigned AllocatedSize () const
 The allocated memory, in total number of items.

void SetCount (unsigned _count)
 Set the number of items in the array. More...

unsigned PushBack (const T &t)
 Push T to the last element of the array. More...

Back ()
 Get the last element.

PopBack ()
 Pop the last element of the array. More...

void Insert (T t, unsigned n)
 Insert an element into this array at index 'n'. More...

void Remove (unsigned n)
 Remove the element at index 'n'. More...

unsigned Find (const T &t) const
 Trys to find the selected item (criteria being t == data[i]) returns an index if successful, NOTFOUND if not.

bool FindAndDelete (const T &t)
 Trys to find the selected item (criteria being t == data[i]) and delete it.

void Resize (unsigned _size)
 Resize the array. More...

void ResizePower2 (unsigned _size)
 A more useful and efficient resize. More...

void Append (const GlDynArray< T > &rhs)
 Appends another DynArray (of the same type) on to this one. More...

void Sort ()
 Perform a shellsort on the array. More...


Detailed Description

template<class T>
class GlDynArray< T >

A dynamic array class.

Has a notion of both Size (the allocated memory) and Count (the number of items.) Generally, as a user of the array you want to be sure you are using Count.

Left to its own devices, GlDynArray will use power of 2 memory allocation when it expands.


Member Function Documentation

template<class T>
void GlDynArray< T >::Append const GlDynArray< T > &    rhs [inline]
 

Appends another DynArray (of the same type) on to this one.

The appended array is unchanged. Uses PowerOf2 allocation in hopes of optimizing multiple appends.

template<class T>
unsigned GlDynArray< T >::Count   const [inline]
 

The number of items in the array.

(Managed by the user.)

template<class T>
void GlDynArray< T >::Insert   t,
unsigned    n
[inline]
 

Insert an element into this array at index 'n'.

Will resource and adjust count as necessary.

template<class T>
T GlDynArray< T >::PopBack   [inline]
 

Pop the last element of the array.

Will never change the size of allocated memory, but will update the count.

template<class T>
unsigned GlDynArray< T >::PushBack const T &    t [inline]
 

Push T to the last element of the array.

Will never reduce the size, only increase it. (Useful for setting the size to something reasonable, and then pushing items to the array.

Will increment count.

template<class T>
void GlDynArray< T >::Remove unsigned    n [inline]
 

Remove the element at index 'n'.

Adjusts count as necessary. Won't reduce memory.

template<class T>
void GlDynArray< T >::Resize unsigned    _size [inline]
 

Resize the array.

Will take no action of the array size does not change. Will not increase count.

template<class T>
void GlDynArray< T >::ResizePower2 unsigned    _size [inline]
 

A more useful and efficient resize.

Note resize normally does not need to be called, since it will be called by other functions.

template<class T>
void GlDynArray< T >::SetCount unsigned    _count [inline]
 

Set the number of items in the array.

This will also re-allocate memory.

template<class T>
void GlDynArray< T >::Sort   [inline]
 

Perform a shellsort on the array.

Note that "Find" is not cordinated with the sort, so Find will still be in linear time.


The documentation for this class was generated from the following file:
Generated on Mon Sep 15 12:01:11 2003 for Kyra by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001