TArrayObjects< T, size, step > Class Template Reference

This template defines advanced array with variable length. More...

#include <ArrayObjects.h>

Collaboration diagram for TArrayObjects< T, size, step >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

typedef int (__cdecl *cmp_fce)(const void *
 Sorting function sort two items func(a,b):.
 TArrayObjects (void)
 Constructor.
 ~TArrayObjects (void)
 Destructor.
 TArrayObjects (const TArrayObjects< T, size, step > &orig)
 Copy constructor.
void operator= (const TArrayObjects< T, size, step > &orig)
 fake assignment operator
void Set (const TArrayObjects< T, size, step > &orig)
 Copy objects from another array to this one.
DWORD GetItemSize (void) const
 Return size of one item in this array.
void Clear (void)
 Releases this list.
void ClearDeallocOff (void)
 Releases this list.
void ReserveSize (const DWORD &newSize)
 Resize array.
DWORD GetSize (void) const
 Returns number of items in list.
DWORD Size (void) const
 Returns number of items in list.
DWORD Count (void) const
 Returns number of items in list.
DWORD GetAllocatedSpace (void) const
 Returns number of allocated items.
void AddItem (const T &item)
 Add item at end of list.
void AddItemUninitialized (void)
 This method new "add" item into array.
void Insert (const T &item, const DWORD &index)
 Insert new item at specified position.
void RemoveItem (const DWORD &index)
 Remove item with given index from array.
void RemoveItemFast (const DWORD &index)
 Remove item with given index from array.
void RemoveLastItem (void)
 Remove last item in array.
GetItem (const DWORD &index) const
 Gets item on desired index.
T & GetItemRef (const DWORD &index)
 Gets reference to item on desired index.
const T & GetItemRef (const DWORD &index) const
 Gets reference to item on desired index.
T & operator[] (const DWORD &index)
 Gets reference to item on desired index.
const T & operator[] (const DWORD &index) const
 Gets reference to item on desired index.
GetLastItem (void) const
 Gets last item in array.
T & GetLastItemRef (void)
 Gets reference to last item in array.
const T & GetLastItemRef (void) const
 Gets reference to last item in array.
T * GetArray (void)
 Return pointer to array of items stored in this list!!!
const T * GetArray (void) const
 Return pointer to array of items stored in this list!!!
void Sort (cmp_fce func)
 Sort this list by given sorting function.
void Reverse (void)
 Reverse order of items in array.

Detailed Description

template<class T, unsigned int size = 5, unsigned int step = 5>
class TArrayObjects< T, size, step >

This template defines advanced array with variable length.

Unlike template TArray this template may be used for object types.

These types must have properly defined operator=, which is used in this class. Also default constructor and destructor should be properly defined. Also memory aligning is prefered in this template (operator new is used).

If item is destroyed then to this item is copy default value of given type with operator=.

If item type is pointer then before deleting list all pointers must be released manually!!! For non-pointers type destructors are called if exists.

For non-object type like scalar values or pointers is recommnded to use template TArray which provides better performance.

Definition at line 40 of file ArrayObjects.h.


Constructor & Destructor Documentation

template<class T, unsigned int size, unsigned int step>
TArrayObjects< T, size, step >::TArrayObjects void   ) 
 

Constructor.

Definition at line 122 of file ArrayObjects.h.

template<class T, unsigned int size, unsigned int step>
TArrayObjects< T, size, step >::~TArrayObjects void   ) 
 

Destructor.

Release list. Call destructor to each item in array.

Definition at line 159 of file ArrayObjects.h.

template<class T, unsigned int size, unsigned int step>
TArrayObjects< T, size, step >::TArrayObjects const TArrayObjects< T, size, step > &  orig  ) 
 

Copy constructor.

Parameters:
orig [in] original array

Definition at line 138 of file ArrayObjects.h.

References TArrayObjects< T, size, step >::alloc, TArrayObjects< T, size, step >::array, TArrayObjects< T, size, step >::count, and TArrayObjects< T, size, step >::onestep.


Member Function Documentation

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::AddItem const T &  item  ) 
 

Add item at end of list.

New item is created via operator=.

Parameters:
item [in] new item to add

Definition at line 261 of file ArrayObjects.h.

References TArrayObjects< T, size, step >::ReserveSize().

Referenced by NSMath::NSCurves::THermiteCubicSpline::AddPoint().

Here is the call graph for this function:

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::AddItemUninitialized void   ) 
 

This method new "add" item into array.

In fact method only increment number of items in array (which may result into reallocation array inside). After this increment "new" last item is uninitialized!!! This may be useful in situation when added item will be initialized via another method thus it needn't be initialized.

Warning:
After calling this method you should initialize this item (e.g. via reference parameter of some function)

Definition at line 282 of file ArrayObjects.h.

References TArrayObjects< T, size, step >::ReserveSize().

Here is the call graph for this function:

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::Clear void   )  [inline]
 

Releases this list.

Only sets number of items to 0 - memory is still allocated for one object!

Definition at line 195 of file ArrayObjects.h.

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::ClearDeallocOff void   )  [inline]
 

Releases this list.

Only sets number of items to 0! No memory allocation is changed, thus method is very fast.

Definition at line 210 of file ArrayObjects.h.

template<class T, unsigned int size, unsigned int step>
DWORD TArrayObjects< T, size, step >::Count void   )  const [inline]
 

Returns number of items in list.

Returns:
number of items in list

Definition at line 240 of file ArrayObjects.h.

Referenced by NSMath::NSCurves::THermiteCubicSpline::GetFirstDerivateValue(), NSMath::NSCurves::THermiteCubicSpline::GetIndexByTime(), NSMath::NSCurves::THermiteCubicSpline::GetIndexByUniformTime(), NSMath::NSCurves::THermiteCubicSpline::GetPoint(), NSMath::NSCurves::THermiteCubicSpline::GetPointCount(), NSMath::NSCurves::THermiteCubicSpline::GetSecondDerivateValue(), NSMath::NSCurves::THermiteCubicSpline::GetTangent(), and NSMath::NSCurves::THermiteCubicSpline::GetValue().

template<class T, unsigned int size, unsigned int step>
DWORD TArrayObjects< T, size, step >::GetAllocatedSpace void   )  const [inline]
 

Returns number of allocated items.

Returns:
number of allocated items

Definition at line 250 of file ArrayObjects.h.

template<class T, unsigned int size, unsigned int step>
const T * TArrayObjects< T, size, step >::GetArray void   )  const [inline]
 

Return pointer to array of items stored in this list!!!

Returns:
pointer to array stored in this list.

Definition at line 510 of file ArrayObjects.h.

template<class T, unsigned int size, unsigned int step>
T * TArrayObjects< T, size, step >::GetArray void   )  [inline]
 

Return pointer to array of items stored in this list!!!

Returns:
pointer to array stored in this list.

Definition at line 500 of file ArrayObjects.h.

template<class T, unsigned int size, unsigned int step>
T TArrayObjects< T, size, step >::GetItem const DWORD index  )  const [inline]
 

Gets item on desired index.

Creates new item with copy constructor!!! Please use GetItemRef() or operator=() for reference getting. Index must be in range <0,count-1>!!!!

Parameters:
index [in] index to list
Returns:
item on desired index

Definition at line 392 of file ArrayObjects.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
const T & TArrayObjects< T, size, step >::GetItemRef const DWORD index  )  const [inline]
 

Gets reference to item on desired index.

Index must be in range <0,count-1>

Parameters:
index [in] index to list
Returns:
reference to item on desired index

Definition at line 422 of file ArrayObjects.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
T & TArrayObjects< T, size, step >::GetItemRef const DWORD index  )  [inline]
 

Gets reference to item on desired index.

Index must be in range <0,count-1>

Parameters:
index [in] index to list
Returns:
reference to item on desired index

Definition at line 407 of file ArrayObjects.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
DWORD TArrayObjects< T, size, step >::GetItemSize void   )  const [inline]
 

Return size of one item in this array.

Definition at line 113 of file ArrayObjects.h.

template<class T, unsigned int size, unsigned int step>
T TArrayObjects< T, size, step >::GetLastItem void   )  const [inline]
 

Gets last item in array.

Warning:
At least one item must be in array!

Definition at line 464 of file ArrayObjects.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
const T & TArrayObjects< T, size, step >::GetLastItemRef void   )  const [inline]
 

Gets reference to last item in array.

Warning:
At least one item must be in array!

Definition at line 488 of file ArrayObjects.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
T & TArrayObjects< T, size, step >::GetLastItemRef void   )  [inline]
 

Gets reference to last item in array.

Warning:
At least one item must be in array!

Definition at line 476 of file ArrayObjects.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
DWORD TArrayObjects< T, size, step >::GetSize void   )  const [inline]
 

Returns number of items in list.

Returns:
number of items in list

Definition at line 220 of file ArrayObjects.h.

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::Insert const T &  item,
const DWORD index
 

Insert new item at specified position.

New item is created via operator=.

Parameters:
item [in] new item to insert
index [in] index in range <0,count-1>

Definition at line 300 of file ArrayObjects.h.

References DBGASSERT, and TArrayObjects< T, size, step >::ReserveSize().

Here is the call graph for this function:

template<class T, unsigned int size = 5, unsigned int step = 5>
typedef TArrayObjects< T, size, step >::int __cdecl *  cmp_fce  )  const
 

Sorting function sort two items func(a,b):.

	*		< 0		....	a < b
	*		= 0		....	a = b
	*		> 0		....	a > b
	*	

template<class T, unsigned int size = 5, unsigned int step = 5>
void TArrayObjects< T, size, step >::operator= const TArrayObjects< T, size, step > &  orig  ) 
 

fake assignment operator

template<class T, unsigned int size, unsigned int step>
const T & TArrayObjects< T, size, step >::operator[] const DWORD index  )  const [inline]
 

Gets reference to item on desired index.

Index must be in range <0,count-1>

Parameters:
index [in] index to list
Returns:
reference to item on desired index

Definition at line 452 of file ArrayObjects.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
T & TArrayObjects< T, size, step >::operator[] const DWORD index  )  [inline]
 

Gets reference to item on desired index.

Index must be in range <0,count-1>

Parameters:
index [in] index to list
Returns:
reference to item on desired index

Definition at line 437 of file ArrayObjects.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::RemoveItem const DWORD index  ) 
 

Remove item with given index from array.

No destructor is called to item!!! Item is destroyed by assigning to default value via default constructor T item=T(); Thus class must have properly defined operator= and default constructor.

Parameters:
index [in] index of item - must be in range!!!

Definition at line 329 of file ArrayObjects.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::RemoveItemFast const DWORD index  ) 
 

Remove item with given index from array.

This methods change order of items in list!!! Last item is set to deleted item. No destructor is called to item!!! Item is destroyed by assigning to default value via default constructor T item=T(); Thus class must have properly defined operator= and default constructor.

Parameters:
index [in] index of item - must be in range

Definition at line 354 of file ArrayObjects.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::RemoveLastItem void   )  [inline]
 

Remove last item in array.

No destructor is called to item!!! Item is destroyed by assigning to default value via default constructor T item=T(); Thus class must have properly defined operator= and default constructor.

Definition at line 373 of file ArrayObjects.h.

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::ReserveSize const DWORD newSize  ) 
 

Resize array.

Original array items are copy to new array. If size in parameter is less than actual size than new size is set to actual size thus methods do nothing. Items are copy via operator=.

Parameters:
newSize [in] new size of array in number of items

Definition at line 541 of file ArrayObjects.h.

Referenced by TArrayObjects< T, size, step >::AddItem(), TArrayObjects< T, size, step >::AddItemUninitialized(), and TArrayObjects< T, size, step >::Insert().

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::Reverse void   ) 
 

Reverse order of items in array.

Definition at line 565 of file ArrayObjects.h.

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::Set const TArrayObjects< T, size, step > &  orig  ) 
 

Copy objects from another array to this one.

Use operator=.

Parameters:
orig [in] original array

Definition at line 173 of file ArrayObjects.h.

References TArrayObjects< T, size, step >::alloc, TArrayObjects< T, size, step >::array, TArrayObjects< T, size, step >::count, and TArrayObjects< T, size, step >::onestep.

Referenced by NSMath::NSCurves::THermiteCubicSpline::Set().

template<class T, unsigned int size, unsigned int step>
DWORD TArrayObjects< T, size, step >::Size void   )  const [inline]
 

Returns number of items in list.

Returns:
number of items in list

Definition at line 230 of file ArrayObjects.h.

Referenced by NSMath::NSCurves::THermiteCubicSpline::Add(), NSMath::NSCurves::THermiteCubicSpline::ChangeTangent(), NSMath::NSCurves::THermiteCubicSpline::GetFirstDerivateValue(), NSMath::NSCurves::THermiteCubicSpline::GetLength(), NSMath::NSCurves::THermiteCubicSpline::GetSecondDerivateValue(), NSMath::NSCurves::THermiteCubicSpline::GetValue(), NSMath::NSCurves::THermiteCubicSpline::Move(), NSMath::NSCurves::THermiteCubicSpline::MovePoint(), and NSMath::NSCurves::THermiteCubicSpline::Sub().

template<class T, unsigned int size, unsigned int step>
void TArrayObjects< T, size, step >::Sort cmp_fce  func  )  [inline]
 

Sort this list by given sorting function.

Sorting function sort two items func(a,b):

*		< 0		....	a < b
*		= 0		....	a = b
*		> 0		....	a > b
*	

Parameters:
func sorting function

Definition at line 528 of file ArrayObjects.h.


The documentation for this class was generated from the following file:
Generated on Wed Nov 28 22:41:39 2007 for Joy4D by  doxygen 1.4.6-NO