Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
sol-vector.h File Reference

These are routines that Soletta provides for its vector implementation. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <errno.h>

Go to the source code of this file.

Data Structures

struct  sol_ptr_vector
 Soletta pointer vector is a wrapper around vector with an API more convenient to handle pointers. More...
 
struct  sol_vector
 Soletta vector is an array that grows dynamically. More...
 

Macros

#define SOL_PTR_VECTOR_FOREACH_IDX(vector, itrvar, idx)
 Macro to iterate over the pointer vector easily. More...
 
#define SOL_PTR_VECTOR_FOREACH_IDX_UNTIL(vector, itrvar, idx, until)
 Macro to iterate over the pointer vector until a index. More...
 
#define SOL_PTR_VECTOR_FOREACH_REVERSE_IDX(vector, itrvar, idx)
 Macro to iterate over the pointer vector easily in the reverse order. More...
 
#define SOL_PTR_VECTOR_INIT   { { NULL, 0, sizeof(void *) } }
 Helper macro to initialize a struct sol_ptr_vector. More...
 
#define SOL_VECTOR_FOREACH_IDX(vector, itrvar, idx)
 Macro to iterate over the vector easily. More...
 
#define SOL_VECTOR_FOREACH_IDX_UNTIL(vector, itrvar, idx, until)
 Macro to iterate over the vector until a index. More...
 
#define SOL_VECTOR_FOREACH_REVERSE_IDX(vector, itrvar, idx)
 Macro to iterate over the vector easily in the reverse order. More...
 
#define SOL_VECTOR_INIT(TYPE)   { NULL, 0, sizeof(TYPE) }
 Helper macro to initialize a sol_vector structure to hold elements of type TYPE. More...
 

Typedefs

typedef struct sol_ptr_vector sol_ptr_vector
 Soletta pointer vector is a wrapper around vector with an API more convenient to handle pointers. More...
 
typedef struct sol_vector sol_vector
 Soletta vector is an array that grows dynamically. More...
 

Functions

int sol_ptr_vector_append (struct sol_ptr_vector *pv, const void *ptr)
 Append a pointer to the end of the vector. More...
 
static void sol_ptr_vector_clear (struct sol_ptr_vector *pv)
 Delete all elements from the vector. More...
 
static int sol_ptr_vector_del (struct sol_ptr_vector *pv, uint16_t i)
 Remove the pointer of index i from the vector. More...
 
int sol_ptr_vector_del_element (struct sol_ptr_vector *pv, const void *elem)
 Remove all occurrences of elem from the vector pv. More...
 
static int sol_ptr_vector_del_last (struct sol_ptr_vector *pv)
 Remove the last element from the vector. More...
 
static int sol_ptr_vector_del_range (struct sol_ptr_vector *pv, uint16_t start, uint16_t len)
 Remove an range of pointers from the vector. More...
 
static int32_t sol_ptr_vector_find_first (const struct sol_ptr_vector *pv, const void *elem)
 Find the first occurrence of elem from the vector pv. More...
 
static int32_t sol_ptr_vector_find_first_sorted (const struct sol_ptr_vector *pv, const void *elem, int(*compare_cb)(const void *data1, const void *data2))
 Find the first occurrence of elem in the sorted vector pv. More...
 
static int32_t sol_ptr_vector_find_last (const struct sol_ptr_vector *pv, const void *elem)
 Find the last occurrence of elem from the vector pv. More...
 
static int32_t sol_ptr_vector_find_last_sorted (const struct sol_ptr_vector *pv, const void *elem, int(*compare_cb)(const void *data1, const void *data2))
 Find the last occurrence of elem in the sorted vector pv. More...
 
static int32_t sol_ptr_vector_find_sorted (const struct sol_ptr_vector *pv, const void *elem, int(*compare_cb)(const void *data1, const void *data2))
 Find the exact occurrence of elem in the sorted vector pv. More...
 
static void * sol_ptr_vector_get (const struct sol_ptr_vector *pv, uint16_t i)
 Return the element of the vector at the given index. More...
 
static uint16_t sol_ptr_vector_get_len (const struct sol_ptr_vector *pv)
 Returns the number of pointers stored in the vector. More...
 
static void * sol_ptr_vector_get_no_check (const struct sol_ptr_vector *pv, uint16_t i)
 Return the element of the vector at the given index (no safety checks). More...
 
static void sol_ptr_vector_init (struct sol_ptr_vector *pv)
 Initializes a sol_ptr_vector structure. More...
 
int sol_ptr_vector_init_n (struct sol_ptr_vector *pv, uint16_t n)
 Initializes a sol_ptr_vector structure and preallocates n elements. More...
 
int sol_ptr_vector_insert_at (struct sol_ptr_vector *pv, uint16_t i, const void *ptr)
 Insert a pointer in the pointer vector at a given position. More...
 
int32_t sol_ptr_vector_insert_sorted (struct sol_ptr_vector *pv, const void *ptr, int(*compare_cb)(const void *data1, const void *data2))
 Insert a pointer in the pointer vector, using the given comparison function to determine its position. More...
 
static int32_t sol_ptr_vector_match_first (const struct sol_ptr_vector *pv, const void *tempt, int(*compare_cb)(const void *data1, const void *data2))
 Match for the first occurrence matching template tempt. More...
 
static int32_t sol_ptr_vector_match_last (const struct sol_ptr_vector *pv, const void *tempt, int(*compare_cb)(const void *data1, const void *data2))
 Match for the last occurrence matching template tempt. More...
 
int32_t sol_ptr_vector_match_sorted (const struct sol_ptr_vector *pv, const void *tempt, int(*compare_cb)(const void *data1, const void *data2))
 Match for occurrence matching template tempt in the sorted vector pv. More...
 
int sol_ptr_vector_remove (struct sol_ptr_vector *pv, const void *ptr)
 Remove an pointer from the vector. More...
 
int sol_ptr_vector_set (struct sol_ptr_vector *pv, uint16_t i, const void *ptr)
 Set the element at index i to be ptr. More...
 
static void * sol_ptr_vector_steal (struct sol_ptr_vector *pv, uint16_t i)
 Remove and return the element at index i from the vector. More...
 
static void * sol_ptr_vector_steal_data (struct sol_ptr_vector *pv)
 Steal the memory holding the elements of the vector. More...
 
static void * sol_ptr_vector_steal_last (struct sol_ptr_vector *pv)
 Remove and return the last element from the vector. More...
 
int32_t sol_ptr_vector_update_sorted (struct sol_ptr_vector *pv, uint16_t i, int(*compare_cb)(const void *data1, const void *data2))
 Update sorted pointer vector so the element is still in order. More...
 
void * sol_vector_append (struct sol_vector *v)
 Append an element to the end of the vector. More...
 
void * sol_vector_append_n (struct sol_vector *v, uint16_t n)
 Append n elements to the end of the vector. More...
 
void sol_vector_clear (struct sol_vector *v)
 Delete all elements from the vector. More...
 
int sol_vector_del (struct sol_vector *v, uint16_t i)
 Remove an element from the vector. More...
 
int sol_vector_del_element (struct sol_vector *v, const void *elem)
 Remove an element from the vector. More...
 
static int sol_vector_del_last (struct sol_vector *v)
 Remove the last element from the vector. More...
 
int sol_vector_del_range (struct sol_vector *v, uint16_t start, uint16_t len)
 Remove an range of element from the vector. More...
 
static void * sol_vector_get (const struct sol_vector *v, uint16_t i)
 Return the element of the vector at the given index. More...
 
static void * sol_vector_get_no_check (const struct sol_vector *v, uint16_t i)
 Return the element of the vector at the given index (no safety checks). More...
 
void sol_vector_init (struct sol_vector *v, uint16_t elem_size)
 Initializes a sol_vector structure. More...
 
static void * sol_vector_steal_data (struct sol_vector *v)
 Steal the memory holding the elements of the vector. More...
 

Detailed Description

These are routines that Soletta provides for its vector implementation.