SDLGameEngine

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

Data Structures | Typedefs | Functions | Variables

# SgeList

Hash list. More...

## Data Structures
struct | SGELISTENTRY
struct | SGELIST
## Typedefs
typedef void( | SGELISTFUNCTION )(const char *id, void *data)
| iterator function
## Functions
SGELIST * | sgeListNew (void)
| create a new hash list
SGELISTENTRY * | sgeListAdd (SGELIST *l, const char *id, void *data)
| add a element on the hash index id
SGELISTENTRY * | sgeListInsert (SGELIST *l, SGELISTENTRY *le, const char *id, void *data)
| insert a element before a certain element
SGELISTENTRY * | sgeListSearch (SGELIST *l, char *id)
| search a element in the hash list
void | sgeListRemove (SGELIST *l, char *id)
| remove a element from a list
void | sgeListForEach (SGELIST *l, SGELISTFUNCTION function)
| iterate over a hash list
void | sgeListDestroy (SGELIST *l)
| destroy a hash list
## Variables
void * | SGELISTENTRY::data
| The data of the element as void pointer.

## Detailed Description

Hash list.

Functions for handling string based hash lists. Think of it as sgeArray with a character string as index instead of a integer.

## Typedef Documentation

typedef void( SGELISTFUNCTION)(const char *id, void *data)

iterator function

Parameters:

  id | the element key
  data | the element data

See also:
  sgeListForEach

Definition at line 66 of file sgelist.h.

## Function Documentation

SGELISTENTRY* sgeListAdd | ( | SGELIST * | l,
|  | const char * | id,
|  | void * | data
| ) |  |

add a element on the hash index id

Parameters:

  l | hash list to add the element to
  id | the hash key as string
  data | the actual element data

Returns:
  a pointer to the new element as SGELISTENTRY

Definition at line 21 of file sgelist.c.

void sgeListDestroy | ( | SGELIST * | l | ) |

destroy a hash list

Elements are not freed, you have to free them yourself before destroying

Definition at line 113 of file sgelist.c.

void sgeListForEach | ( | SGELIST * | l,
|  | SGELISTFUNCTION | function
| ) |  |

iterate over a hash list

Parameters:

  l | the hash list to iterate over
  function | a function

The function gets the id (char *) and the data (void *) of the element.

Definition at line 105 of file sgelist.c.

SGELISTENTRY* sgeListInsert | ( | SGELIST * | l,
|  | SGELISTENTRY * | le,
|  | const char * | id,
|  | void * | data
| ) |  |

insert a element before a certain element

Parameters:

  l | the hash list to change
  le | the element where to insert before
  id | the hash key as string
  data | the actual element data

Returns:
  a pointer to the new element as SGELISTENTRY

Definition at line 51 of file sgelist.c.

SGELIST* sgeListNew | ( | void |  | ) |

create a new hash list

Returns:
  the new list as SGELIST pointer

Elements have to be freed yourself, after/before removing from the list.

Definition at line 11 of file sgelist.c.

void sgeListRemove | ( | SGELIST * | l,
|  | char * | id
| ) |  |

remove a element from a list

Parameters:

  l | the hash list to remove the element from
  id | the key of the element to remove

element data is not freed, usually you want to first search for the element and free the data before calling this.

Definition at line 82 of file sgelist.c.

SGELISTENTRY* sgeListSearch | ( | SGELIST * | l,
|  | char * | id
| ) |  |

search a element in the hash list

Parameters:

  l | the hash list to search in
  id | the key to search for

Returns:
  the element as SGELISTENTRY pointer or NULL of not found

Definition at line 72 of file sgelist.c.

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines