Legofit
infers population history from nucleotide site patterns.
|
A table of IdSet values. More...
#include "idsetset.h"
#include "idset.h"
#include "error.h"
#include "binary.h"
#include "misc.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/errno.h>
Data Structures | |
struct | El |
A single key-value pair, with a pointer to the next one. More... | |
struct | IdSetSet |
The hash table. More... | |
Macros | |
#define | SETS_PER_BUCKET 0.7 |
Functions | |
static int | resize (IdSetSet *self, int dim) |
Change the size of the hash map and rehash. | |
static El * | El_new (IdSet *idset) |
Construct a new element with given key and value. | |
static El * | El_free_shallow (El *e) |
Destroy a linked list of El objects, but do not free IdSet pointers. | |
static El * | El_free_deep (El *e) |
Destroy a linked list of El objects, including IdSet pointers. | |
static El * | El_add (El *self, IdSet *idset, int *status) |
Add an new IdSet into the linked list. More... | |
static void | El_sanityCheck (El *el, const char *file, int line) |
IdSetSet * | IdSetSet_new (int n) |
Constructor reserves space for n elements. | |
void | IdSetSet_free_shallow (IdSetSet *self) |
Shallow destructor does not free IdSet objects. | |
void | IdSetSet_free_deep (IdSetSet *self) |
Deep destructor frees IdSet objects. | |
void | IdSetSet_empty_shallow (IdSetSet *self) |
Empty IdSetSet. Does not free the IdSet pointers. | |
void | IdSetSet_empty_deep (IdSetSet *self) |
Empty IdSetSet, including IdSet pointers. | |
int | IdSetSet_add (IdSetSet *self, IdSet *idset) |
Add a value to the table, resizing if necessary. More... | |
int | IdSetSet_size (IdSetSet *self) |
Return the number of elements. | |
int | IdSetSet_toArray (IdSetSet *self, unsigned size, IdSet *v[size]) |
Put idset pointers into array "v". More... | |
int | IdSetSet_rewind (IdSetSet *self) |
Move curr to first filled bucket in hash table. More... | |
IdSet * | IdSetSet_next (IdSetSet *self) |
Return the next IdSet pointer, or NULL if there are no more. More... | |
int | IdSetSet_reserve (IdSetSet *self, int m) |
Make sure hash table is large enough to hold m additional elements. | |
void | IdSetSet_sanityCheck (IdSetSet *self, const char *file, int line) |
Variables | |
static const double | sets_per_bucket = SETS_PER_BUCKET |
static const double | buckets_per_set = 1.0/SETS_PER_BUCKET |
A table of IdSet values.
The IdSetSet_add function merges entries that have identical tipId_t values and also identical migration histories. In that case, the probabilities of duplicate IdSet values add. If the IdSet objects are not identical, the IdSetSet_add function as separate copies.
To iterate across an IdSetSet named x:
IdSet *idset; IdSetSet_rewind(x); while( (idset = IdSetSet_next(x)) != NULL ) { <operate on idset> }
Add an new IdSet into the linked list.
Usage:
El *list=NULL; int status; list = El_add(list, idset, &status); switch(status) { case 0: printf("Added to probability of existing IdSet.\n"); break; case 1: printf("Added new IdSet to list\n"); break; default: printf("This should not happen.\n"); }
self | current element of list | |
[in] | idset,a | pointer |
[out] | status | pointer to int, which will be set to 1 if the new IdSet did not previously exist in the list or to 0 if it was already there. |
References El_new().
Add a value to the table, resizing if necessary.
References resize().
int IdSetSet_rewind | ( | IdSetSet * | self | ) |
Move curr to first filled bucket in hash table.
Return 0 on success or 1 if the hash table is empty;