SDLGameEngine

SgeList

Hash list. More...

Data Structures

struct  SGELISTENTRY
struct  SGELIST

Typedefs

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

Functions

SGELISTsgeListNew (void)
 create a new hash list
SGELISTENTRYsgeListAdd (SGELIST *l, const char *id, void *data)
 add a element on the hash index id
SGELISTENTRYsgeListInsert (SGELIST *l, SGELISTENTRY *le, const char *id, void *data)
 insert a element before a certain element
SGELISTENTRYsgeListSearch (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:
idthe element key
datathe 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:
lhash list to add the element to
idthe hash key as string
datathe 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:
lthe hash list to iterate over
functiona 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:
lthe hash list to change
lethe element where to insert before
idthe hash key as string
datathe 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:
lthe hash list to remove the element from
idthe 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:
lthe hash list to search in
idthe 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