Legofit
infers population history from nucleotide site patterns.
sampndx.h
1#ifndef ARR_SAMPNDX_H
2# define ARR_SAMPNDX_H
3
4# include "typedefs.h"
5# include <stdio.h>
6# include <stdlib.h>
7
8struct SampNdx {
9 // Array "ptr" contains an entry for each sample. That entry is a
10 // pointer to "home", the node or segment that contains the
11 // sample. For sample i, the label equals 2^i (i.e. 1<<i).
12 unsigned n; // number of samples
13 void *ptr[MAXSAMP]; // array of pointers
14};
15
16void SampNdx_init(SampNdx * self);
17void SampNdx_addSamples(SampNdx * self, unsigned nsamples, void * ptr);
18void *SampNdx_get(SampNdx * self, unsigned i);
19unsigned SampNdx_size(SampNdx * self);
20int SampNdx_equals(const SampNdx *lhs, const SampNdx *rhs);
21void SampNdx_sanityCheck(SampNdx *self, const char *file, int line);
22int SampNdx_ptrsLegal(SampNdx * self, void * start, void * end);
23void SampNdx_remapPtrs(SampNdx *self, PtrPtrMap *ppm);
24
25#endif
void SampNdx_init(SampNdx *self)
Set everything to zero.
Definition: sampndx.c:17
void SampNdx_addSamples(SampNdx *self, unsigned nsamples, void *ptr)
Add samples for a single population.
Definition: sampndx.c:24
void SampNdx_sanityCheck(SampNdx *self, const char *file, int line)
Check sanity of a SampNdx.
Definition: sampndx.c:58
void SampNdx_remapPtrs(SampNdx *self, PtrPtrMap *ppm)
Remap pointers.
Definition: sampndx.c:79
int SampNdx_ptrsLegal(SampNdx *self, void *start, void *end)
Return 1 if all pointers in SampNdx are in [start,end); return 0 otherwise.
Definition: sampndx.c:69
void * SampNdx_get(SampNdx *self, unsigned i)
Return pointer to home of i'th sample.
Definition: sampndx.c:35
int SampNdx_equals(const SampNdx *lhs, const SampNdx *rhs)
This equality check doesn't do much, because the pointers in different SampNdx objects don't have to ...
Definition: sampndx.c:47
Definition: sampndx.h:8