TeoCCl library  0.1.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
array_list.c File Reference
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include "teoccl/array_list.h"
#include "teoccl/memory.h"

Macros

#define SIZE_T_MAX   ((size_t)-1)
 

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 SIZE_T_MAX   ((size_t)-1)

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.