cu
generic.h File Reference

Provides generic functions for the data structures. More...

Go to the source code of this file.

Macros

#define cu_push(x, y)
 
#define cu_new(x)
 
#define cu_clear(x, fn)
 
#define cu_del(x)
 
#define cu_clear_del(x, fn)
 
#define cu_len(x)
 
#define cu_foreach(x, fn)
 
#define cu_is_empty(x)
 
#define cu_find(x, key, pred)
 
#define cu_insert(x, index, data)
 
#define cu_contains(x, key, pred)
 

Detailed Description

Provides generic functions for the data structures.

Macro Definition Documentation

#define cu_clear (   x,
  fn 
)
Value:
_Generic((x), \
vector_t * : vector_clear((vector_t *)x, fn), \
list_t * : list_clear((list_t *)x, fn) \
)
Holds the reference to the head and tail of the list.
Definition: list.h:27
vector dynamically growing array
Definition: vector.h:14
void vector_clear(vector_t *v, void(*df)(void *))
Remove all elements from the vector, in case that df is NULL every entry is set to 0...
void list_clear(const list_t *li, void(*df)(void *))
Remove all elements from the list.
#define cu_clear_del (   x,
  fn 
)
Value:
_Generic((x), \
list_t * : list_clear_del((list_t *)x, fn) \
)
Holds the reference to the head and tail of the list.
Definition: list.h:27
vector dynamically growing array
Definition: vector.h:14
void vector_clear_del(vector_t *v, void(*df)(void *))
Remove all elements and free the vector_t.
void list_clear_del(list_t *li, void(*df)(void *))
Remove all elements from the list and free it.
#define cu_contains (   x,
  key,
  pred 
)
Value:
_Generic((x), \
vector_t * : vector_contains((vector_t *)x, key, pred), \
list_t * : list_contains((list_t *)x, key, pred) \
)
Holds the reference to the head and tail of the list.
Definition: list.h:27
vector dynamically growing array
Definition: vector.h:14
bool list_contains(list_t *li, const void *key, int(*pred)(const void *, const void *))
bool vector_contains(const vector_t *v, const void *key, int(*pred)(const void *, const void *))
Check whether a element is in the vector. for an int created on the stack: return memcmp(a...
#define cu_del (   x)
Value:
_Generic((x), \
list_t * : list_del((list_t *)x) \
)
Holds the reference to the head and tail of the list.
Definition: list.h:27
void vector_del(vector_t *v)
Delete the vector and free allocated memory. The elements of the vector will not be freed...
vector dynamically growing array
Definition: vector.h:14
void list_del(list_t *li)
Free the memory allocated.
#define cu_find (   x,
  key,
  pred 
)
Value:
_Generic((x), \
vector_t * : vector_find((vector_t *)x, key, pred), \
list_t * : list_find((list_t *)x, key, pred) \
)
Holds the reference to the head and tail of the list.
Definition: list.h:27
vector dynamically growing array
Definition: vector.h:14
void * vector_find(const vector_t *v, const void *key, bool(*pred)(const void *, const void *))
Find an element in given vector.
void * list_find(const list_t *li, const void *key, bool(*pred)(const void *, const void *))
Find a element in the list.
#define cu_foreach (   x,
  fn 
)
Value:
_Generic((x), \
vector_t * : vector_foreach((vector_t *)x, fn), \
list_t * : list_foreach((list_t *)x, fn) \
)
Holds the reference to the head and tail of the list.
Definition: list.h:27
vector dynamically growing array
Definition: vector.h:14
void list_foreach(const list_t *li, void(*f)(void *))
Apply a function to every element of the list.
void vector_foreach(const vector_t *v, void(*f)(void *))
Apply the funtion f to every element in the vector.
#define cu_insert (   x,
  index,
  data 
)
Value:
_Generic((x), \
vector_t * : vector_insert((vector_t *)x, index, data), \
list_t * : list_insert((list_t *) x, index, data) \
)
Holds the reference to the head and tail of the list.
Definition: list.h:27
vector dynamically growing array
Definition: vector.h:14
void list_insert(list_t *li, const size_t index, void *data)
void vector_insert(vector_t *v, size_t index, void *data)
Insert an element at given position, should the index be greater than the current vector size then th...
#define cu_is_empty (   x)
Value:
_Generic((x), \
)
Holds the reference to the head and tail of the list.
Definition: list.h:27
vector dynamically growing array
Definition: vector.h:14
bool list_is_empty(const list_t *li)
Check whether the list is empty.
bool vector_is_empty(const vector_t *v)
#define cu_len (   x)
Value:
_Generic((x), \
list_t * : list_len((list_t *)x) \
)
Holds the reference to the head and tail of the list.
Definition: list.h:27
vector dynamically growing array
Definition: vector.h:14
size_t vector_len(const vector_t *v)
size_t list_len(const list_t *li)
Retrieve the length of a list.
#define cu_new (   x)
Value:
_Generic((x), \
)
Holds the reference to the head and tail of the list.
Definition: list.h:27
vector dynamically growing array
Definition: vector.h:14
list_t * list_new()
Create a new list.
vector_t * vector_new()
Creates a new empty vector of the size 8.
#define cu_push (   x,
 
)
Value:
_Generic((x), \
vector_t * : vector_push((vector_t *)x, y), \
list_t * : list_push_back((list_t *)x, y) \
)
Holds the reference to the head and tail of the list.
Definition: list.h:27
void list_push_back(list_t *li, void *data)
Append an element to the list.
void vector_push(vector_t *v, void *data)
Appends a element to the vector.
vector dynamically growing array
Definition: vector.h:14