Legofit
infers population history from nucleotide site patterns.
|
Map strings to pointers. More...
#include "strptrmap.h"
#include "misc.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
Data Structures | |
struct | El |
A single key-value pair, with a pointer to the next one. More... | |
struct | StrPtrMap |
The hash table. More... | |
Macros | |
#define | KEYSIZE 20 |
#define | PNT_DIM 32u |
PNT_DIM: dimention of hash table must be a power of 2. | |
Functions | |
El * | El_new (const char *key, void *ptr) |
Construct a new element with given key and pointer. | |
void | El_free (El *e) |
Destroy a linked list of El objects. | |
El * | El_insert (El *self, const char *key, void *ptr, int *status) |
Insert a new key/ptr pair into the linked list. More... | |
StrPtrMap * | StrPtrMap_new (void) |
StrPtrMap constructor. | |
void | StrPtrMap_free (StrPtrMap *self) |
StrPtrMap destructor. | |
void * | StrPtrMap_get (StrPtrMap *self, const char *key) |
Get the pointer associated with key. More... | |
int | StrPtrMap_insert (StrPtrMap *self, const char *key, void *ptr) |
Insert a pointer into the table. More... | |
unsigned long | StrPtrMap_size (StrPtrMap *self) |
Return the number of elements in the StrPtrMap. | |
void | StrPtrMap_print (StrPtrMap *self) |
Print a StrPtrMap. | |
void | StrPtrMap_ptrArray (StrPtrMap *self, long unsigned n, void *v[n]) |
Fill array v with pointers. Abort if v is of wrong size. | |
Map strings to pointers.
Insert a new key/ptr pair into the linked list.
Usage:
El *list=NULL; int status; list = El_insert(list, key, ptr, &status); if(status != 0) printf("Error: key is already in list\n");
self | current element of list | |
[in] | key,a | character string |
[in] | ptr | pointer |
[out] | status | pointer to int, which will be set to 0 on success or 1 if ptr is already in list. |
References El_insert(), El_new(), and El::next.
Referenced by El_insert(), and StrPtrMap_insert().
void * StrPtrMap_get | ( | StrPtrMap * | self, |
const char * | key | ||
) |
Get the pointer associated with key.
If no such object exists, return NULL.
References El::next, PNT_DIM, and strhash().
Referenced by parseDerive(), and parseMix().
int StrPtrMap_insert | ( | StrPtrMap * | self, |
const char * | key, | ||
void * | ptr | ||
) |
Insert a pointer into the table.
References El_insert(), PNT_DIM, and strhash().
Referenced by parseSegment().