reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
vector.h
Go to the documentation of this file.
1/*
2 * This file defines a minimal vector (resizing array) data type.
3 * It is intended to be the simplest way of storing a collection of
4 * pointers that is frequently filled and then completely emptied.
5 *
6 * @author Peter Donovan (peterdonovan@berkeley.edu)
7 * @author Soroush Bateni (soroush@utdallas.edu)
8 */
9
10#ifndef VECTOR_H
11#define VECTOR_H
12
13#include <stddef.h>
14#include <stdlib.h>
15
16typedef struct vector_t {
17 void** start; /* The start of the underlying array. */
18 void** next; /* The element after the last element in the underlying array.
19 start <= next <= end. */
20 void** end; /* The end of the underlying array. */
21 int votes_required; /* The number of votes required to shrink this vector. */
22 int votes; /* The number of votes to shrink this vector. */
24
31
37
44void vector_push(vector_t* v, void* element);
45
53void vector_pushall(vector_t* v, void** array, size_t size);
54
60void* vector_pop(vector_t* v);
61
75void** vector_at(vector_t* v, size_t idx);
76
83size_t vector_size(vector_t* v);
84
94
95#endif /* VECTOR_H */
return address
Definition hashmap.h:74
Definition vector.h:16
int votes
Definition vector.h:22
int votes_required
Definition vector.h:21
void ** next
Definition vector.h:18
void ** start
Definition vector.h:17
void ** end
Definition vector.h:20
void ** vector_at(vector_t *v, size_t idx)
Definition vector.c:103
void vector_vote(vector_t *v)
Definition vector.c:138
vector_t vector_new(size_t initial_capacity)
Definition vector.c:21
void vector_push(vector_t *v, void *element)
Definition vector.c:45
void * vector_pop(vector_t *v)
Definition vector.c:77
size_t vector_size(vector_t *v)
Return the size of the vector.
Definition vector.c:128
void vector_pushall(vector_t *v, void **array, size_t size)
Definition vector.c:60
void vector_free(vector_t *v)
Definition vector.c:35
struct vector_t vector_t