SDLGameEngine

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

Data Structures | Functions

# SgeArray

A dynamic array. More...

## Data Structures
struct | SGEARRAY
## Functions
SGEARRAY * | sgeArrayNew (void)
| create a new array
SGEARRAY * | sgeAutoArrayNew (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:

  a | the array to add the element
  e | the 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:

  a | the 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:

  a | the array to iterate over
  function | the 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:

  a | the array to get the element from
  offset | the 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:

  a | the array to insert the element into
  offset | the position where to insert
  e | the 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:

  a | the array to remove the element from
  offset | the 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:

  a | the array where to replace the element
  offset | the position to replace
  e | the new element

Definition at line 53 of file sgearray.c.

Uint32 sgeArraySize | ( | SGEARRAY * | a | ) | `[inline]`

the number of elements in a array

Parameters:

  a | the 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:

  function | a function that frees the element

Definition at line 20 of file sgearray.c.

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines