reactor-c
1.0
C Runtime for Lingua Franca
Toggle main menu visibility
Loading...
Searching...
No Matches
vector.h
Go to the documentation of this file.
1
/*
2
* @file vector.h
3
* @brief A minimal vector (resizing array) data type.
4
* @ingroup Utilities
5
*
6
* This is intended to be the simplest way of storing a collection of
7
* pointers that is frequently filled and then completely emptied.
8
*
9
* The corresponding `.c` files are in reactor-c/core/utils/vector
10
*
11
* @author Peter Donovan
12
* @author Soroush Bateni
13
*/
14
15
#ifndef VECTOR_H
16
#define VECTOR_H
17
18
#include <stddef.h>
19
#include <stdlib.h>
20
29
typedef
struct
vector_t
{
37
void
**
start
;
38
46
void
**
next
;
47
55
void
**
end
;
56
65
int
votes_required
;
66
74
int
votes
;
75
}
vector_t
;
76
84
vector_t
vector_new
(
size_t
initial_capacity);
85
91
void
vector_free
(
vector_t
* v);
92
100
void
vector_push
(
vector_t
* v,
void
* element);
101
110
void
vector_pushall
(
vector_t
* v,
void
** array,
size_t
size);
111
118
void
*
vector_pop
(
vector_t
* v);
119
134
void
**
vector_at
(
vector_t
* v,
size_t
idx);
135
142
size_t
vector_size
(
vector_t
* v);
143
152
void
vector_vote
(
vector_t
* v);
153
154
#endif
/* VECTOR_H */
vector_at
void ** vector_at(vector_t *v, size_t idx)
Return a pointer to where the vector element at 'idx' is stored.
vector_vote
void vector_vote(vector_t *v)
Vote on whether this vector should be given less memory.
vector_new
vector_t vector_new(size_t initial_capacity)
Allocate and initialize a new vector.
vector_push
void vector_push(vector_t *v, void *element)
Add the given element to the vector.
vector_pop
void * vector_pop(vector_t *v)
Remove and return some pointer that is contained in the given vector, or return NULL if the given vec...
vector_size
size_t vector_size(vector_t *v)
Return the size of the vector.
vector_pushall
void vector_pushall(vector_t *v, void **array, size_t size)
Add all elements of the given array to the vector.
vector_free
void vector_free(vector_t *v)
Free the memory held by the given vector, invalidating it.
vector_t
A vector (resizing array) data type.
Definition
vector.h:29
vector_t::votes
int votes
The number of votes to shrink this vector.
Definition
vector.h:74
vector_t::votes_required
int votes_required
The number of votes required to shrink this vector.
Definition
vector.h:65
vector_t::next
void ** next
The element after the last element in the underlying array.
Definition
vector.h:46
vector_t::start
void ** start
The start of the underlying array.
Definition
vector.h:37
vector_t::end
void ** end
The end of the underlying array.
Definition
vector.h:55
Users
runner
work
reactor-c
reactor-c
include
core
utils
vector.h
Generated on
for reactor-c by
1.17.0