TeoCCl library  0.1.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
array_list.h File Reference

Go to the source code of this file.

Data Structures

struct  ccl_array_list
 Array-List structure. More...
 

Macros

#define ARRAY_LIST_DEFAULT_SIZE   32
 

Typedefs

typedef void( array_list_free_fn )(void *data)
 
typedef struct ccl_array_list ccl_array_list_t
 Array-List structure. More...
 

Functions

ccl_array_list_tcclArrayListNew (array_list_free_fn *free_fn)
 Create new Array-List. More...
 
int cclArrayListFree (ccl_array_list_t *tal)
 Free memory allocated for Array-List. More...
 
void * cclArrayListGetIdx (ccl_array_list_t *tal, size_t i)
 Get element of Array-List by index. More...
 
int cclArrayListDelIdx (ccl_array_list_t *tal, size_t i, size_t count)
 Delete range of elements of Array-List since index. More...
 
int cclArrayListAdd (ccl_array_list_t *tal, void *data)
 Add element to Array-List. More...
 
size_t cclArrayListLength (ccl_array_list_t *tal)
 Get count of elements in Array-List. More...
 
void cclArrayListSort (ccl_array_list_t *tal, int(*compar)(const void *, const void *))
 Run Qsort for array-list. More...
 
void * cclArrayListBSearch (ccl_array_list_t *tal, const void **key, int(*compar)(const void *, const void *))
 Binary search for array-list. More...
 

Macro Definition Documentation

#define ARRAY_LIST_DEFAULT_SIZE   32

Referenced by cclArrayListNew().

Typedef Documentation

typedef void( array_list_free_fn)(void *data)

Array-List structure.

Function Documentation

int cclArrayListAdd ( ccl_array_list_t tal,
void *  data 
)

Add element to Array-List.

Parameters
[in]tal- Pointer to ccl_array_list_t
[in]data- Pointer to the data to be added
Returns
-1 - error, 0 - adding was successful

References ccl_array_list::length.

void* cclArrayListBSearch ( ccl_array_list_t tal,
const void **  key,
int(*)(const void *, const void *)  compar 
)

Binary search for array-list.

Parameters
tal- array list
key- what we want to find
compar- pointer to comparator
Returns
A pointer to an entry in the array-list that matches the search key

References ccl_array_list::array, and ccl_array_list::length.

int cclArrayListDelIdx ( ccl_array_list_t tal,
size_t  i,
size_t  count 
)

Delete range of elements of Array-List since index.

Parameters
[in]tal- Pointer to ccl_array_list_t
[in]i- Delete from this index
[in]count- Count of deleting elements
Returns
zero
Todo:
Create correct return

References ccl_array_list::array, ccl_array_list::free_fn, and ccl_array_list::length.

int cclArrayListFree ( ccl_array_list_t tal)

Free memory allocated for Array-List.

Parameters
[in]tal- Pointer to ccl_array_list_t
Returns
zero
Todo:
Create correct return

References ccl_array_list::array, ccl_array_list::free_fn, and ccl_array_list::length.

void* cclArrayListGetIdx ( ccl_array_list_t tal,
size_t  i 
)

Get element of Array-List by index.

Parameters
[out]tal- Pointer to ccl_array_list_t
[in]i- index in ccl_array_list_t
Returns
Pointer to element of ccl_array_list_t

References ccl_array_list::array, and ccl_array_list::length.

size_t cclArrayListLength ( ccl_array_list_t tal)

Get count of elements in Array-List.

Parameters
[in]tal- Pointer to ccl_array_list_t
Returns
count of elements in ccl_array_list_t

References ccl_array_list::length.

ccl_array_list_t* cclArrayListNew ( array_list_free_fn free_fn)

Create new Array-List.

Parameters
[in]free_fn- Pointer to free-callback function
Returns
Pointer to ccl_array_list_t

References ccl_array_list::array, ARRAY_LIST_DEFAULT_SIZE, ccl_calloc(), ccl_malloc(), ccl_array_list::free_fn, ccl_array_list::length, and ccl_array_list::size.

void cclArrayListSort ( ccl_array_list_t tal,
int(*)(const void *, const void *)  compar 
)

Run Qsort for array-list.

Parameters
tal- array list
compar- pointer to comparator

References ccl_array_list::array, and ccl_array_list::length.