reactor-c
C Runtime for Lingua Franca
|
Macros | |
#define | REQUIRED_VOTES_TO_SHRINK 15 |
#define | CAPACITY_TO_SIZE_RATIO_FOR_SHRINK_VOTE 4 |
#define | SCALE_FACTOR 2 |
Functions | |
vector_t | vector_new (size_t initial_capacity) |
void | vector_free (vector_t *v) |
void | vector_push (vector_t *v, void *element) |
void | vector_pushall (vector_t *v, void **array, size_t size) |
void * | vector_pop (vector_t *v) |
void ** | vector_at (vector_t *v, size_t idx) |
size_t | vector_size (vector_t *v) |
Return the size of the vector. | |
void | vector_vote (vector_t *v) |
#define CAPACITY_TO_SIZE_RATIO_FOR_SHRINK_VOTE 4 |
#define REQUIRED_VOTES_TO_SHRINK 15 |
#define SCALE_FACTOR 2 |
void ** vector_at | ( | vector_t * | v, |
size_t | idx ) |
Return a pointer to where the vector element at 'idx' is stored. This can be used to set the value of the element or to read it. If the index is past the end of the vector, then the vector is automatically expanded and filled with NULL pointers as needed. If no element at idx
has been previously set, then the value pointed to by the returned pointer will be NULL.
v | The vector. |
idx | The index into the vector. |
void vector_free | ( | vector_t * | v | ) |
Free the memory held by the given vector, invalidating it.
v | Any vector. |
vector_t vector_new | ( | size_t | initial_capacity | ) |
Allocate and initialize a new vector.
initial_capacity | The desired initial capacity to allocate. |
void * vector_pop | ( | vector_t * | v | ) |
Remove and return some pointer that is contained in the given vector, or return NULL if the given vector is empty.
v | Any vector. |
void vector_push | ( | vector_t * | v, |
void * | element ) |
Add the given element to the vector.
v | A vector that is to grow. |
element | An element that the vector should contain. |
void vector_pushall | ( | vector_t * | v, |
void ** | array, | ||
size_t | size ) |
Add all elements of the given array to the vector. Elements should be non-null.
v | A vector that is to grow. |
array | An array of items to be added to the vector. |
size | The size of the given array. |
size_t vector_size | ( | vector_t * | v | ) |
Return the size of the vector.
v | Any vector |
void vector_vote | ( | vector_t * | v | ) |
Vote on whether this vector should be given less memory. If v
contains few elements, it becomes more likely to shrink.
It is suggested that this function be called when the number of elements in v
reaches a local maximum.
v | Any vector. |