|
uLib
User mode C/C++ extended API library for Win32 programmers.
|
#include <uLib/DynArray.h>
Simple dynamic array (storing void*) to contain whatever..
The base method DeleteItem uses mem_Free() to dispose of the item data, so
if you use mem_Alloc() for your items, you don't need a descendant DynArray.
Definition at line 51 of file DynArray.h.
Public Data | |
| DWORD const & | Count |
| DWORD const & | Size |
| DynArray const & | Items |
Public Functions | |
| DynArray (DWORD Size=16, WORD Delta=16) | |
| virtual | ~DynArray () |
| void | Init (DWORD Size, WORD Delta) |
| void | Done () |
| PVOID | operator+= (PVOID Item) |
| PVOID | operator -= (PVOID Item) |
| PVOID | Insert (PVOID Item) |
| PVOID | InsertAt (DWORD Index, PVOID Item) |
| PVOID | Push (PVOID Item) |
| PVOID | Pull (void) |
| PVOID | Pop (void) |
| virtual void | DeleteItem (PVOID &Item) |
| virtual void | DeleteAll (void) |
| void | Delete (PVOID &Item) |
| < More... | |
| void | Delete (DWORD Index) |
| PVOID | Remove (PVOID Item) |
| PVOID | Remove (DWORD Index) |
| LONG | IndexOf (PVOID Item) const |
| PVOID | At (DWORD Index) const |
| PVOID | FirstThat (DYN_ITEMFUNC Match, PVOID userData) const |
| PVOID | LastThat (DYN_ITEMFUNC Match, PVOID userData) const |
| bool | ForEach (DYN_ITEMFUNC Action, PVOID userData) const |
| PVOID | operator[] (DWORD Index) const |
| Size | Initial size of array. |
| Delta | Nr of slots to add when array fills up. |
Definition at line 34 of file DynArray.cpp.
|
virtual |
The destructor calls DeleteAll, which invokes DeleteItem on each item.
Definition at line 46 of file DynArray.cpp.
Used by c'tor
Definition at line 51 of file DynArray.cpp.
| void uLib::DynArray::Done | ( | ) |
Used by d'tor
Definition at line 66 of file DynArray.cpp.
|
inline |
Add Item to the array.
Definition at line 68 of file DynArray.h.
|
inline |
Remove Item from the array.
Definition at line 69 of file DynArray.h.
| PVOID uLib::DynArray::Insert | ( | PVOID | Item | ) |
Appends Item to the collection. Override: if needed.
| Item | Item to add to array. |
Definition at line 72 of file DynArray.cpp.
| PVOID uLib::DynArray::InsertAt | ( | DWORD | Index, |
| PVOID | Item | ||
| ) |
Inserts Item at the specified index. Existing items are moved.
If Index is beyond the end of collection InsertAt() equals Insert().
| Index | Index where to insert item. Zero based. |
| Item | Pointer to item. |
Definition at line 105 of file DynArray.cpp.
| PVOID uLib::DynArray::Push | ( | PVOID | Item | ) |
| PVOID uLib::DynArray::Pull | ( | void | ) |
Remove an iten. Push/Pull = FIFO (queue) action.
Definition at line 126 of file DynArray.cpp.
| PVOID uLib::DynArray::Pop | ( | void | ) |
Remove an iten. Push/Pop = LIFO (stack) action.
Definition at line 131 of file DynArray.cpp.
|
virtual |
DeleteItem() should destroy Item, and set the ptr to NULL.
You must override this if your items are allocated any other way than mem_Alloc().
See also ~DynArray().
Definition at line 136 of file DynArray.cpp.
|
virtual |
Definition at line 155 of file DynArray.cpp.
| void uLib::DynArray::Delete | ( | PVOID & | Item | ) |
<
DeleteAll() deletes all items in the collection.
| Item | Pointer to item to delete. |
Definition at line 142 of file DynArray.cpp.
| void uLib::DynArray::Delete | ( | DWORD | Index | ) |
Delete() deletes the item and removes it from collection.
| Index | Index of item to delete. |
Definition at line 148 of file DynArray.cpp.
| PVOID uLib::DynArray::Remove | ( | PVOID | Item | ) |
| Item | Pointer to item to remove. |
Definition at line 160 of file DynArray.cpp.
| PVOID uLib::DynArray::Remove | ( | DWORD | Index | ) |
Remove() removes the item without deleting it.
| Index | Index of item to remove. |
Definition at line 166 of file DynArray.cpp.
| LONG uLib::DynArray::IndexOf | ( | PVOID | Item | ) | const |
IndexOf() returns the index of Item if it exists, else it returns -1.
Definition at line 177 of file DynArray.cpp.
| PVOID uLib::DynArray::At | ( | DWORD | Index | ) | const |
At() retrieves the item at Index.
Definition at line 185 of file DynArray.cpp.
| PVOID uLib::DynArray::FirstThat | ( | DYN_ITEMFUNC | Match, |
| PVOID | userData | ||
| ) | const |
Returns the first item in the collection that matches userData,
according to the supplied Match function.
| Match | Callback function to compare items. |
| userData | Arbitrary data to pass to the comparison funtion. |
Definition at line 191 of file DynArray.cpp.
| PVOID uLib::DynArray::LastThat | ( | DYN_ITEMFUNC | Match, |
| PVOID | userData | ||
| ) | const |
LastThat() works like FirstThat(), exept that it finds the last item.
Definition at line 199 of file DynArray.cpp.
| bool uLib::DynArray::ForEach | ( | DYN_ITEMFUNC | Action, |
| PVOID | userData | ||
| ) | const |
Calls the supplied Action function for each item in the collection,
or until the Action callback returns false.
| Action | Callback function to process items. |
| userData | Arbitrary data to pass to the action funtion. |
Definition at line 207 of file DynArray.cpp.
|
inline |
Provide subscript access to the array's items.
Definition at line 133 of file DynArray.h.
| DWORD const& uLib::DynArray::Count |
Nr of items in collection (ReadOnly)
Definition at line 53 of file DynArray.h.
| DWORD const& uLib::DynArray::Size |
Allocated pointer array length (ReadOnly)
Definition at line 54 of file DynArray.h.
| DynArray const& uLib::DynArray::Items |
Self-reference for subscript access through pointer.
Example: MyArrayPtr->Items[ index ];
Definition at line 55 of file DynArray.h.