Legofit
infers population history from nucleotide site patterns.
ptrvec.h
1
#ifndef ARR_PTRVEC_H
2
#define ARR_PTRVEC_H
3
4
#include "typedefs.h"
5
#include <assert.h>
6
7
struct
PtrVec
{
8
unsigned
buffsize;
9
unsigned
used;
10
void
**buff;
// array of pointers
11
};
12
13
PtrVec
*
PtrVec_new
(
unsigned
n);
14
void
PtrVec_free(
PtrVec
*self);
15
int
PtrVec_push(
PtrVec
*self,
void
*val);
16
void
*PtrVec_pop(
PtrVec
*self);
17
int
PtrVec_resize
(
PtrVec
*self,
unsigned
size);
18
static
inline
void
PtrVec_empty(
PtrVec
*self);
19
static
inline
void
*PtrVec_get(
PtrVec
*self,
unsigned
i);
20
static
inline
unsigned
PtrVec_length(
PtrVec
*self);
21
22
static
inline
void
*PtrVec_get(
PtrVec
*self,
unsigned
i) {
23
assert(i < self->used);
24
return
self->buff[i];
25
}
26
27
static
inline
unsigned
PtrVec_length(
PtrVec
*self) {
28
return
self->used;
29
}
30
31
static
inline
void
PtrVec_empty(
PtrVec
*self) {
32
self->used = 0;
33
}
34
35
36
#endif
PtrVec_resize
int PtrVec_resize(PtrVec *self, unsigned size)
Enlarge size of allocated buffer if necessary.
Definition:
ptrvec.c:62
PtrVec_new
PtrVec * PtrVec_new(unsigned n)
Allocate an array with room for n pointers.
Definition:
ptrvec.c:17
PtrVec
Definition:
ptrvec.h:7
Generated on Fri Mar 17 2023 17:45:47 for Legofit by
1.9.4