DOUBLE_ARRAY< _CT > Class Template Reference

Double array template. More...

#include <mi32/doublear.h>

Inheritance diagram for DOUBLE_ARRAY< _CT >:

Inheritance graph
[legend]
List of all members.

Public Member Functions

ERRVALUE Append (const _CT &item)
ERRVALUE Assign (const _CT *items, int numitems)
void Attach (MIDOUBLEARRAY &items, int numitems)
void Clear ()
void ClearItems (int start=0, int end=-1)
ERRVALUE Copy (const DOUBLE_ARRAY< _CT > &rhs)
void DeleteItem (int index)
void Detach (MIDOUBLEARRAY &items)
 DOUBLE_ARRAY (const DOUBLE_ARRAY< _CT > &rhs)
 DOUBLE_ARRAY ()
void Free ()
void GetItems (_CT *items, int numitems, int firstitem=0) const
int GetMaxItems () const
int GetNumItems () const
int GetSizeInBytes () const
bool IsEmpty () const
 operator _CT * ()
 operator const _CT * () const
bool operator!= (const DOUBLE_ARRAY< _CT > &rhs) const
DOUBLE_ARRAY< _CT > & operator= (const DOUBLE_ARRAY< _CT > &rhs)
bool operator== (const DOUBLE_ARRAY< _CT > &rhs) const
_CT & operator[] (int index)
const _CT & operator[] (int index) const
void RemoveItem (INT32 item)
ERRVALUE Reserve (int newmaxitems, bool clear=false, bool addinc=false)
void ReserveExc (int newmaxitems, bool clear=false, bool addinc=false)
ERRVALUE Resize (int numitems, bool keepold=true, bool clear=false)
void ResizeExc (int numitems, bool keepold=true, bool clear=false)
void Reverse ()
ERRVALUE SetItems (int firstitem, const _CT *items, int numitems)
void Swap (DOUBLE_ARRAY< _CT > &rhs)
void SwapBytes ()
void TransferOwnerFrom (DOUBLE_ARRAY< _CT > &rhs)
template<class _T2> void TransferOwnerFromExt (DOUBLE_ARRAY< _T2 > &rhs)
 ~DOUBLE_ARRAY ()

Detailed Description

template<class _CT>
class DOUBLE_ARRAY< _CT >

Double array template.

This template is designed to contain an array of items which can be allocated using MmAlloc/MmRealloc. The primary purpose of this template is to replace allocated arrays where direct access to both array elements and the ability to access a pointer to the first element (as for a C array) is required.

For maximum efficiency, only minimal validation of access to array elements is performed. No initialization of array items is performed by the template.

This class is also designed to handle the 4 byte off alignment issue in regards to systems that have a 4 byte allocation granularity.

Best if used as DOUBLE_ARRAY<double>, DOUBLE_ARRAY<DPOINT2D>, DOUBLE_ARRAY<DPOINT3D>, DOUBLE_ARRAY<DRECT2D>, and DOUBLE_ARRAY<DRECT3D>

Definition at line 150 of file doublear.h.


Constructor & Destructor Documentation

template<class _CT>
DOUBLE_ARRAY< _CT >::DOUBLE_ARRAY  )  [inline]
 

Default constructor.

Definition at line 155 of file doublear.h.

template<class _CT>
DOUBLE_ARRAY< _CT >::DOUBLE_ARRAY const DOUBLE_ARRAY< _CT > &  rhs  )  [inline]
 

Copy constructor.

Definition at line 163 of file doublear.h.

template<class _CT>
DOUBLE_ARRAY< _CT >::~DOUBLE_ARRAY  )  [inline]
 

Definition at line 173 of file doublear.h.


Member Function Documentation

template<class _CT>
ERRVALUE DOUBLE_ARRAY< _CT >::Append const _CT &  item  )  [inline]
 

Append item to end of array, extending if necessary.

Definition at line 259 of file doublear.h.

template<class _CT>
ERRVALUE DOUBLE_ARRAY< _CT >::Assign const _CT *  items,
int  numitems
[inline]
 

Assign from C array, reserving space if needed.

Resizes the array to the specified number of items.

Parameters:
items  Items to copy to array
numitems  Number of items to copy

Definition at line 273 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::Attach MIDOUBLEARRAY items,
int  numitems
[inline]
 

Attach a buffer to the DOUBLE_ARRAY.

After passing a buffer to Attach(), the DOUBLE_ARRAY "<b>owns</b>" the buffer and will free it in its destructor.

Parameters:
items Reference to a pointer to the templated data type.
numitems The number of items being attached
The reason it's a reference is that after recording the pointer, Attach() will set your pointer to 0. This will prevent you from accidently freeing a pointer you no longer own. If you want it back, call the Detach() method

Definition at line 294 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::Clear  )  [inline]
 

Clear the array, does not free resources.

Definition at line 305 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::ClearItems int  start = 0,
int  end = -1
[inline]
 

Clear items in the array.

Parameters:
end  Default -1, use number of items

Definition at line 309 of file doublear.h.

template<class _CT>
ERRVALUE DOUBLE_ARRAY< _CT >::Copy const DOUBLE_ARRAY< _CT > &  rhs  )  [inline]
 

Copy the contents of another DOUBLE_ARRAY.

Same as assignment, but returns an error code instead of throwing an exception.

Definition at line 320 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::DeleteItem int  index  )  [inline]
 

Delete item in the array.

Use with care as this is not efficient for large arrays.

Definition at line 331 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::Detach MIDOUBLEARRAY items  )  [inline]
 

Detach the buffer from the DOUBLE_ARRAY.

This turns ownership of the buffer over to the caller, who is then responsibile for seeing that it gets disposed of. After calling Detach(), the DOUBLE_ARRAY will behave as if it had just been constructed. In other words, it will be a NULL pointer pointing to 0 items. This means that if you want to know how many items are in the array returned, you'd better find out before} you call Detach()!

Definition at line 352 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::Free  )  [inline]
 

Free the array.

Definition at line 364 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::GetItems _CT *  items,
int  numitems,
int  firstitem = 0
const [inline]
 

Get items from array.

Parameters:
items  Buffer to hold items
numitems  Number of items to copy
firstitem  First array item to retrieve

Definition at line 373 of file doublear.h.

template<class _CT>
int DOUBLE_ARRAY< _CT >::GetMaxItems  )  const [inline]
 

Get maximum number of items in array.

Definition at line 383 of file doublear.h.

template<class _CT>
int DOUBLE_ARRAY< _CT >::GetNumItems  )  const [inline]
 

Get number of items in array.

Definition at line 389 of file doublear.h.

template<class _CT>
int DOUBLE_ARRAY< _CT >::GetSizeInBytes  )  const [inline]
 

Get size of array required to hold current number of items in bytes.

Definition at line 393 of file doublear.h.

template<class _CT>
bool DOUBLE_ARRAY< _CT >::IsEmpty  )  const [inline]
 

Determine if array is empty.

Definition at line 397 of file doublear.h.

template<class _CT>
DOUBLE_ARRAY< _CT >::operator _CT *  )  [inline]
 

Cast to array of template type.

Definition at line 211 of file doublear.h.

template<class _CT>
DOUBLE_ARRAY< _CT >::operator const _CT *  )  const [inline]
 

Cast to const array of template type.

Definition at line 205 of file doublear.h.

template<class _CT>
bool DOUBLE_ARRAY< _CT >::operator!= const DOUBLE_ARRAY< _CT > &  rhs  )  const [inline]
 

Inequality operator.

Definition at line 198 of file doublear.h.

template<class _CT>
DOUBLE_ARRAY<_CT>& DOUBLE_ARRAY< _CT >::operator= const DOUBLE_ARRAY< _CT > &  rhs  )  [inline]
 

Assignment.

Definition at line 177 of file doublear.h.

template<class _CT>
bool DOUBLE_ARRAY< _CT >::operator== const DOUBLE_ARRAY< _CT > &  rhs  )  const [inline]
 

Equality operator.

Definition at line 189 of file doublear.h.

template<class _CT>
_CT& DOUBLE_ARRAY< _CT >::operator[] int  index  )  [inline]
 

GENERATING_DOXYGEN_OUTPUT.

Definition at line 228 of file doublear.h.

template<class _CT>
const _CT& DOUBLE_ARRAY< _CT >::operator[] int  index  )  const [inline]
 

Read (const) access to array element.

Note:
Does not verify that index is within valid range.

Definition at line 219 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::RemoveItem INT32  item  )  [inline]
 

Remove item at specified index, maintaining order.

Note that this is inefficient for large arrays.

Definition at line 402 of file doublear.h.

template<class _CT>
ERRVALUE DOUBLE_ARRAY< _CT >::Reserve int  newmaxitems,
bool  clear = false,
bool  addinc = false
[inline]
 

Reserve space in array for up to specified number of items.

Parameters:
newmaxitems  New maximum number of items
clear  Clear the array by resetting number of items to 0
addinc  Add alloation increment to requested size if actually need to resize

Definition at line 413 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::ReserveExc int  newmaxitems,
bool  clear = false,
bool  addinc = false
[inline]
 

Reserve space in array for up to specified number of items, throw exception on failure.

Parameters:
newmaxitems  New maximum number of items
clear  Clear the array by resetting number of items to 0
addinc  Add alloation increment to requested size if actually need to resize

Definition at line 428 of file doublear.h.

template<class _CT>
ERRVALUE DOUBLE_ARRAY< _CT >::Resize int  numitems,
bool  keepold = true,
bool  clear = false
[inline]
 

Resize array to specified number of items.

If the new size is larger than the previous size and the array is not cleared the new array entries will have indeterminant values.

Parameters:
numitems  New number of items desired
keepold  Keep old array entries
clear  Clear new entries to zeros, will clear all if keepold is false

Definition at line 444 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::ResizeExc int  numitems,
bool  keepold = true,
bool  clear = false
[inline]
 

Resize array to specified number of items, throw exception on failure.

If the new size is larger than the previous size and the array is not cleared the new array entries will have indeterminant values.

Parameters:
numitems  New number of items desired
keepold  Keep old array entries
clear  Clear new entries to zeros, will clear all if keepold is false

Definition at line 459 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::Reverse  )  [inline]
 

Reverse order of items in array.

Definition at line 471 of file doublear.h.

template<class _CT>
ERRVALUE DOUBLE_ARRAY< _CT >::SetItems int  firstitem,
const _CT *  items,
int  numitems
[inline]
 

Set array items from C array, expanding if needed.

Will not reduce the number of items in the array.

Parameters:
firstitem  First array item to replace
items  Items to copy to array
numitems  Number of items to copy

Definition at line 483 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::Swap DOUBLE_ARRAY< _CT > &  rhs  )  [inline]
 

Swap two DOUBLE_ARRAYs.

Definition at line 496 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::SwapBytes  )  [inline]
 

Swap bytes in a DOUBLE_ARRAY, assume that there is an overload to swap a _CT.

Definition at line 510 of file doublear.h.

template<class _CT>
void DOUBLE_ARRAY< _CT >::TransferOwnerFrom DOUBLE_ARRAY< _CT > &  rhs  )  [inline]
 

Transfer data ownership from 'rhs' to 'this'.

Definition at line 514 of file doublear.h.

template<class _CT>
template<class _T2>
void DOUBLE_ARRAY< _CT >::TransferOwnerFromExt DOUBLE_ARRAY< _T2 > &  rhs  )  [inline]
 

Transfer data ownership from 'rhs' to 'this'.

Definition at line 525 of file doublear.h.


The documentation for this class was generated from the following file:
Generated on Tue Dec 14 13:19:42 2004 for TNTsdk by  doxygen 1.3.8-20040913