List Array


Detailed Description

Copyright (C) 2007-2008 Ola Lundqvist <ola@inguza.com>

All rights reserved.

List Array is a library to handle generic type elements in a list or array.

There are function to initialize, add, delete, search and free the list.


Data Structures

struct  listArray_t

Typedefs

typedef int(*) matchFunction (void *m1, void *m2)

Functions

void initListArray (struct listArray_t *l, int inc, int size)
int addListArrayElement (struct listArray_t *l, void *element)
int delListArrayElement (struct listArray_t *l, int i)
void * getListArrayElementPointer (struct listArray_t *l, int i)
void freeListArray (struct listArray_t *l)
int getListArrayNumberOfElements (struct listArray_t *l)
int findListArrayElement (struct listArray_t *l, matchFunction match, void *matchData)


Typedef Documentation

typedef int(*) matchFunction(void *m1, void *m2)

Function prototype for the function to use when matching elements

Parameters:
m1 Pointer to element 1
m2 Pointer to element 2
Returns:
1 if match

0 if no match


Function Documentation

int addListArrayElement ( struct listArray_t l,
void *  element 
)

Add an element to the list.

Parameters:
l The list data structure.
element The element to add. It will be copied into the list.
Returns:
Index in the array where it is stored.

int delListArrayElement ( struct listArray_t l,
int  i 
)

Remove an element from the list.

Parameters:
l The list data structure.
i Index to remove.
Returns:
Index in the array where it was removed.

int findListArrayElement ( struct listArray_t l,
matchFunction  match,
void *  matchData 
)

Find a specific element in the lits.

See also:
matchFunction
Parameters:
l The list data structure.
match Function pointer to a match function of type matchFunction.
matchData The element data to compare with using the matchFunction.
Returns:
The index for the found element.

-1 on if no matching element found.

void freeListArray ( struct listArray_t l  ) 

Free the list data strctures.

See also:
initListArray
Parameters:
l The list data structure.

void* getListArrayElementPointer ( struct listArray_t l,
int  i 
)

Get the pointer to an element.

Parameters:
l The list data structure.
i Index to get pointer for.
Returns:
Pointer to the element to the list.

int getListArrayNumberOfElements ( struct listArray_t l  )  [inline]

Get number of elements in the list.

Parameters:
l The list data structure.
Returns:
the number of elements stored in the list.

void initListArray ( struct listArray_t l,
int  inc,
int  size 
)

Initialize the list data structures.

See also:
freeListArray
Parameters:
l The list data structure.
inc How many extra elements to allocate when the list is full.
size Size of the data elements to be stored in the list.


Generated on Mon Apr 7 22:13:48 2008 for SocketDispatcher by  doxygen 1.5.1