TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DynamicArray.h
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* DynamicArray.h Copyright (c) Ladislav Zezula 2015 */
3 /*---------------------------------------------------------------------------*/
4 /* Common array implementation */
5 /*---------------------------------------------------------------------------*/
6 /* Date Ver Who Comment */
7 /* -------- ---- --- ------- */
8 /* 30.10.15 1.00 Lad The first version of DynamicArray.h */
9 /*****************************************************************************/
10 
11 #ifndef __DYNAMIC_ARRAY_H__
12 #define __DYNAMIC_ARRAY_H__
13 
14 //-----------------------------------------------------------------------------
15 // Structures
16 
17 typedef struct _DYNAMIC_ARRAY
18 {
19  char * ItemArray; // Pointer to items
20  size_t ItemCountMax; // Current number of items
21  size_t ItemCount; // Total size of the buffer
22  size_t ItemSize; // Size of the single item
23 
25 
26 //-----------------------------------------------------------------------------
27 // Functions for managing the array
28 
29 int Array_Create_(PDYNAMIC_ARRAY pArray, size_t ItemSize, size_t ItemCountMax);
30 void * Array_Insert(PDYNAMIC_ARRAY pArray, const void * NewItems, size_t NewItemCount);
31 void * Array_ItemAt(PDYNAMIC_ARRAY pArray, size_t ItemIndex);
32 size_t Array_IndexOf(PDYNAMIC_ARRAY pArray, const void * ArrayPtr);
33 void Array_Free(PDYNAMIC_ARRAY pArray);
34 
35 #define Array_Create(pArray, type, ItemCountMax) Array_Create_(pArray, sizeof(type), ItemCountMax)
36 
37 #endif // __DYNAMIC_ARRAY__
int Array_Create_(PDYNAMIC_ARRAY pArray, size_t ItemSize, size_t ItemCountMax)
Definition: DynamicArray.cpp:51
size_t ItemSize
Definition: DynamicArray.h:22
size_t Array_IndexOf(PDYNAMIC_ARRAY pArray, const void *ArrayPtr)
Definition: DynamicArray.cpp:87
Definition: DynamicArray.h:17
struct _DYNAMIC_ARRAY * PDYNAMIC_ARRAY
void Array_Free(PDYNAMIC_ARRAY pArray)
Definition: DynamicArray.cpp:95
void * Array_Insert(PDYNAMIC_ARRAY pArray, const void *NewItems, size_t NewItemCount)
Definition: DynamicArray.cpp:63
char * ItemArray
Definition: DynamicArray.h:19
void * Array_ItemAt(PDYNAMIC_ARRAY pArray, size_t ItemIndex)
Definition: DynamicArray.cpp:81
struct _DYNAMIC_ARRAY DYNAMIC_ARRAY
size_t ItemCountMax
Definition: DynamicArray.h:20
size_t ItemCount
Definition: DynamicArray.h:21