SDLGameEngine

SgeArray

A dynamic array. More...

Data Structures

struct  SGEARRAY

Functions

SGEARRAYsgeArrayNew (void)
 create a new array
SGEARRAYsgeAutoArrayNew (void(*function)(Uint32, void *))
 create a new auto array
void sgeArrayDestroy (SGEARRAY *a)
 free resources
void sgeArrayAdd (SGEARRAY *a, void *e)
 add a element to the array
void sgeArrayInsert (SGEARRAY *a, Uint32 offset, void *e)
 insert a element in a certain position
void sgeArrayReplace (SGEARRAY *a, Uint32 offset, void *e)
 replace a element in the array
void * sgeArrayGet (SGEARRAY *a, Uint32 offset)
 get a element from the array
void sgeArrayRemove (SGEARRAY *a, Uint32 offset)
 remove a element from the array
void sgeArrayForEach (SGEARRAY *a, void function(Uint32, void *))
 iterate through all elements of a element
Uint32 sgeArraySize (SGEARRAY *a)
 the number of elements in a array

Detailed Description

A dynamic array.

Provides functions for handling dynamic arrays.


Function Documentation

void sgeArrayAdd ( SGEARRAY a,
void *  e 
)

add a element to the array

Parameters:
athe array to add the element
ethe pointer to the element

Definition at line 36 of file sgearray.c.

void sgeArrayDestroy ( SGEARRAY a)

free resources

On standard array you have to free all elements resources by yourself, on auto arrays the free function is called for every element.

Parameters:
athe array to free

Definition at line 26 of file sgearray.c.

void sgeArrayForEach ( SGEARRAY a,
void   functionUint32, void * 
)

iterate through all elements of a element

Call a function on every element in the array. The function is passed a Uint32, which is the offset of the element, and a void pointer, which is the element data itself.

Parameters:
athe array to iterate over
functionthe function pointer to call for every element

Definition at line 78 of file sgearray.c.

void* sgeArrayGet ( SGEARRAY a,
Uint32  offset 
)

get a element from the array

Parameters:
athe array to get the element from
offsetthe position of the element

Definition at line 61 of file sgearray.c.

void sgeArrayInsert ( SGEARRAY a,
Uint32  offset,
void *  e 
)

insert a element in a certain position

Parameters:
athe array to insert the element into
offsetthe position where to insert
ethe element to insert

Definition at line 42 of file sgearray.c.

SGEARRAY* sgeArrayNew ( void  )

create a new array

With the standard array you have to free the elements resources by yourself when removing elements

Definition at line 11 of file sgearray.c.

void sgeArrayRemove ( SGEARRAY a,
Uint32  offset 
)

remove a element from the array

On standard arrays the elements resources are not freed, on auto arrays the free function is called.

Parameters:
athe array to remove the element from
offsetthe position of the element to remove

Definition at line 68 of file sgearray.c.

void sgeArrayReplace ( SGEARRAY a,
Uint32  offset,
void *  e 
)

replace a element in the array

Parameters:
athe array where to replace the element
offsetthe position to replace
ethe new element

Definition at line 53 of file sgearray.c.

Uint32 sgeArraySize ( SGEARRAY a) [inline]

the number of elements in a array

Parameters:
athe array to check

Definition at line 85 of file sgearray.c.

SGEARRAY* sgeAutoArrayNew ( void(*)(Uint32, void *)  function)

create a new auto array

With auto array, you can provide a 'remove' function which is called when elements are removed, where you can free the resources.

Parameters:
functiona function that frees the element

Definition at line 20 of file sgearray.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines