TIndexedSet< T, size, step > Class Template Reference

This template serves as indexed set. More...

#include <IndexedSet.h>

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TIndexedSet (void)
 Constructor.
 ~TIndexedSet (void)
 Destructor.
 TIndexedSet (const TIndexedSet< T, size, step > &orig)
 fake copy constructor
void operator= (const TIndexedSet< T, size, step > &orig)
 fake assignment operator
DWORD GetItemSize (void) const
 Return size of one item in this set.
void Set (const TIndexedSet< T, size, step > &orig)
 Sets array with values from another array.
void Clear (void)
 Releases this list.
void ReserveSize (const DWORD &newSize)
 Resize array.
DWORD GetSize (void) const
 Returns number of items in list.
DWORD GetAllocatedSpace (void) const
 Returns number of allocated items.
DWORD AddItem (const T &item)
 Add item at end of list if item doesnt exists inside and returns its index.
BOOL IsInside (const T &item) const
 Determines whether specified item exists in set.
DWORD GetItemIndex (const T &item) const
 Returns index of specified item.
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.
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!!!

Detailed Description

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

This template serves as indexed set.

It is set where each item is unique.

Class should be used only for simle data types, pointers and structures (and classes) with default assignment operator and no alignment. Each used item must have default copy constructor. Also type of used item must have implemented OPERATOR == !!!

Inside class items are copied as memory block - NO operator=() .

While releasing list no destructor are called (inner array is destroy via free()) - all items must be destroyed manualy. Thus if item is pointer then parent object must go through entire list and call delete for any pointer if this pointer points on object type.

Assign this class is PROHIBITED via non-implemented copy constructor.

If item type is pointer then before deleting list all pointers must be released manually!!! For non-pointers type same method for destroying must be called for all items if it's required (e.g. type contains pointer to allocated memory).

Definition at line 43 of file IndexedSet.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 96 of file IndexedSet.h.

References TMemManager::new_mem().

Here is the call graph for this function:

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

Destructor.

Release indexed set. Do not release items in list, it must be released manually (only for pointer types).

Definition at line 112 of file IndexedSet.h.

References TMemManager::free_mem().

Here is the call graph for this function:

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

fake copy constructor


Member Function Documentation

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

Add item at end of list if item doesnt exists inside and returns its index.

If items already exists inside then no action is performed and index of item is returned. New item is created with copy of memory block.

Parameters:
item new item to add

Definition at line 208 of file IndexedSet.h.

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

Releases this list.

Only sets number of items to 0 - memory is still allocated only for one object! No destructors are called for object type!

Definition at line 146 of file IndexedSet.h.

References TMemManager::free_mem(), and TMemManager::new_mem().

Here is the call graph for this function:

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

Returns number of allocated items.

Returns:
number of allocated items

Definition at line 196 of file IndexedSet.h.

template<class T, unsigned int size, unsigned int step>
const T * TIndexedSet< 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 363 of file IndexedSet.h.

template<class T, unsigned int size, unsigned int step>
T * TIndexedSet< 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 353 of file IndexedSet.h.

template<class T, unsigned int size, unsigned int step>
T TIndexedSet< 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 to list
Returns:
item on desired index

Definition at line 286 of file IndexedSet.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
int TIndexedSet< T, size, step >::GetItemIndex const T &  item  )  const [inline]
 

Returns index of specified item.

If item doesnt exists then -1 is returned.

Parameters:
item [in] item to search

Definition at line 260 of file IndexedSet.h.

template<class T, unsigned int size, unsigned int step>
const T & TIndexedSet< 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 to list
Returns:
reference to item on desired index

Definition at line 314 of file IndexedSet.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
T & TIndexedSet< 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 to list
Returns:
reference to item on desired index

Definition at line 300 of file IndexedSet.h.

References DBGASSERT.

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

Return size of one item in this set.

Definition at line 87 of file IndexedSet.h.

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

Returns number of items in list.

Returns:
number of items in list

Definition at line 186 of file IndexedSet.h.

template<class T, unsigned int size, unsigned int step>
BOOL TIndexedSet< T, size, step >::IsInside const T &  item  )  const [inline]
 

Determines whether specified item exists in set.

Parameters:
item [in] item to search

Definition at line 241 of file IndexedSet.h.

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

fake assignment operator

template<class T, unsigned int size, unsigned int step>
const T & TIndexedSet< 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 to list
Returns:
reference to item on desired index

Definition at line 342 of file IndexedSet.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
T & TIndexedSet< 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 to list
Returns:
reference to item on desired index

Definition at line 328 of file IndexedSet.h.

References DBGASSERT.

template<class T, unsigned int size, unsigned int step>
void TIndexedSet< 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 memory - no copy constructor or operator= is used.

Parameters:
newSize new size of array in number of items

Definition at line 166 of file IndexedSet.h.

References TMemManager::free_mem(), and TMemManager::new_mem().

Here is the call graph for this function:

template<class T, unsigned int size, unsigned int step>
void TIndexedSet< T, size, step >::Set const TIndexedSet< T, size, step > &  orig  )  [inline]
 

Sets array with values from another array.

(Creates identical copy)

Parameters:
orig [in] original array

Definition at line 127 of file IndexedSet.h.

References TIndexedSet< T, size, step >::alloc, TIndexedSet< T, size, step >::array, TIndexedSet< T, size, step >::count, TMemManager::free_mem(), TMemManager::new_mem(), and TIndexedSet< T, size, step >::onestep.

Here is the call graph for this function:


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