Main Page | Modules | Class Hierarchy | Data Structures | File List | Data Fields | Globals | Related Pages

Indirect array
[Containers]


Detailed Description

resizable array of indirect elements of any size.

Date:
2002/10/22
Author:
benjamin gerard


Files

file  iarray.h
 Resizable array of indirect elements of any size.


Data Structures

struct  iarray_elt_t
 Array element. More...

struct  iarray_t
 Array definition. More...


Typedefs

typedef void *(* iarray_alloc_f )(unsigned int size, void *cookie)
 User provided allocation function.

typedef void(* iarray_free_f )(void *addr, void *cookie)
 User provided free function.

typedef int(* iarray_cmp_f )(const void *a, const void *b, void *cookie)
 User provided compare function.


Functions

int iarray_create (iarray_t *a, iarray_alloc_f alloc, iarray_free_f free, void *cookie)
 Create and initialized.

void iarray_destroy (iarray_t *a)
 Destroy.

int iarray_clear (iarray_t *a)
 Remove all elements.

void * iarray_addrof (iarray_t *a, int idx)
iarray_elt_tiarray_eltof (iarray_t *a, int idx)
int iarray_get (iarray_t *a, int idx, void *elt, int eltsize)
int iarray_find (iarray_t *a, const void *what, iarray_cmp_f cmp, void *cookie)
iarray_elt_tiarray_dup (iarray_t *a, int idx)
int iarray_set (iarray_t *a, int idx, void *elt, unsigned int eltsize)
int iarray_insert (iarray_t *a, int idx, void *elt, unsigned int eltsize)
int iarray_remove (iarray_t *a, int idx)
void iarray_lock (iarray_t *a)
 Lock the array for thread safe modification.

void iarray_unlock (iarray_t *a)
 Unlock the array for thread safe modification.

int iarray_trylock (iarray_t *a)
 Test if the array is lockable.

int iarray_lockcount (const iarray_t *a)
 Get current lock count.

void iarray_shuffle (iarray_t *a, int idx, int n)
 Shuffle a partition of the array.

void iarray_sort (iarray_t *a, iarray_cmp_f cmp, void *cookie)
 Sort the whole array.

void iarray_sort_part (iarray_t *a, int idx, int n, iarray_cmp_f cmp, void *cookie)
 Sort a partition of an array.


Function Documentation

int iarray_create iarray_t a,
iarray_alloc_f  alloc,
iarray_free_f  free,
void *  cookie
 

Create and initialized.

Parameters:
a pointer to an iarray_t.
alloc alloc function (0 default).
free free function (0 default).
cookie user value to be giveb to alloc() and free()
Returns:
error-code retval 0 success

void iarray_destroy iarray_t a  ) 
 

Destroy.

Parameters:
a pointer to previously created iarray_t.

int iarray_clear iarray_t a  ) 
 

Remove all elements.

Parameters:
a iarray to clear
Returns:
error-code
Return values:
success 

void iarray_lock iarray_t a  ) 
 

Lock the array for thread safe modification.

Parameters:
a iarray to lock
See also:
mutex_lock();

void iarray_unlock iarray_t a  ) 
 

Unlock the array for thread safe modification.

Parameters:
a iarray to unlock
See also:
mutex_unlock();

int iarray_trylock iarray_t a  ) 
 

Test if the array is lockable.

Parameters:
a iarray to (virtually) lock
See also:
mutex_trylock();

int iarray_lockcount const iarray_t a  ) 
 

Get current lock count.

Parameters:
a iarray
See also:
mutex_lockcount();

void iarray_shuffle iarray_t a,
int  idx,
int  n
 

Shuffle a partition of the array.

Parameters:
a iarray to shuffle
idx Index of first element to shuffle (must be valid).
n Number of element (clipped to max).

void iarray_sort iarray_t a,
iarray_cmp_f  cmp,
void *  cookie
 

Sort the whole array.

Parameters:
a iarray to sort
cmp compare function
cookie cookie for cmp function

void iarray_sort_part iarray_t a,
int  idx,
int  n,
iarray_cmp_f  cmp,
void *  cookie
 

Sort a partition of an array.

Parameters:
a iarray to sort
idx Index of first (clipped)
n Number of element (clipped to max).
cmp compare function.
cookie cookie for cmp function


dcplaya documentation version 1.2 Generated on January 2004 by doxygen 1.3.5