TABLE OF CONTENTS
- trish2/patricia_map
- trish2/pmap_add
- trish2/pmap_get
- trish2/pmap_multival_t
- trish2/pmap_multi_t
- trish2/pmap_multi_new
- trish2/pmap_multi_free
- trish2/pmap_multi_add
- trish2/pmap_multi_get
- trish2/pmap_multi_save
- trish2/pmap_multi_load
trish2/patricia_map [ Modules ]
NAME
patricia_map
SYNOPSIS
#include <patricia_map.h>
DESCRIPTION
This module contains functions to use PATRICIA trees as hashes (or maps). A simple map associates a key, a wide character string, to single void* value. A map is implemented as a PATRICIA tree where the value is stored as the data of the PNODE_SPECIAL_END node at the end of the entry. To create, destroy, save, or load a simple map, you must use patricia_new, patricia_free, patricia_save and patricia_load functions. This module only provides routines for adding key/value pairs and obtaining the value associated to a key. It is therefore practical to claim values from the PATRICIA tree data bunch.
A multimap can associate a key to several values, the implementation is a simple map where the value is a single chained list. Also in a multimap the values must be claimed from a single bunch. Thus the module provides functions to create, destroy, save, and load a multimap.
EXAMPLE
SEE ALSO
patricia, bunch, pmap_add, pmap_get, pmap_multival_t, pmap_multi_t, pmap_multi_new, pmap_multi_free, pmap_multi_add, pmap_multi_get, pmap_multi_save, pmap_multi_load
trish2/pmap_add [ Functions ]
NAME
pmap_add
SYNOPSIS
#include <patricia_map.h> void *pmap_add(patricia_t *pat, wchar_t *key, void *value, int replace);
FUNCTION
pmap_add associates key to value in pat. If the key was already associated to a value, then pmap_add behaviour is determined by replace. If it is non zero then value replaces the old value. If it is zero then pmap_add keeps the old value and does not effect the map.
INPUTS
- pat : PATRICIA tree holding the map.
- key : Key of the pair.
- value : Value associated to the key.
- replace : Behaviour in the case key has an associated value.
RETURN VALUE
The value associated to key before the call, this value is returned even if replace is zero. NULL if they key was new to pat.
SEE ALSO
patricia_map, pmap_get, patricia
trish2/pmap_get [ Functions ]
NAME
pmap_get
SYNOPSIS
#include <patricia_map.h> void *pmap_get(patricia_t *pat, wchar_t *key);
FUNCTION
pmap_get gives the value associated with key in the simple map pat.
INPUTS
- pat : PATRICIA tree holding the map.
- key : Key to search.
RETURN VALUE
The value associated to key, NULL if they key was not found.
SEE ALSO
patricia_map, pmap_add, patricia
trish2/pmap_multival_t [ Structures ]
[ Top ] [ Structures ]
NAME
pmap_multival_t
SYNOPSIS
#include <patricia_map.h> typedef struct { void *value; pmap_multival_t *next; } pmap_multival_t;
DESCRIPTION
pmap_multival_t is the structure used to hold several values associated to a same key in a multimap.
ATTRIBUTES
- value : A single value.
- next : The other values.
SEE ALSO
patricia_map, pmap_multi_t, pmap_multi_get
trish2/pmap_multi_t [ Structures ]
[ Top ] [ Structures ]
NAME
pmap_mult_t
SYNOPSIS
#include <patricia_map.h> typedef struct { patricia_t *pat; bunch_t *values; } pmap_multi_t;
DESCRIPTION
pmap_multi_t is the structure containing a multimap, a multimap is really a simple map whose values are pmap_multival_t pointers.
ATTRIBUTES
- pat : Map.
- values : Bunch of values (not a pmap_multival_t bunch).
SEE ALSO
patricia_map, pmap_multival_t, pmap_multi_new, pmap_multi_free, pmap_multi_add, pmap_multi_get, pmap_multi_save, pmap_multi_load
trish2/pmap_multi_new [ Functions ]
NAME
pmap_multi_new
SYNOPSIS
#include <patricia_map.h> pmap_multi_t *pmap_multi_new(unsigned int node_block, unsigned int string_block, bunch_t *values);
FUNCTION
pmap_multi_new creates a new multimap. node_block and string_block are the block sizes of the keys PATRICIA tree bunches. values is a bunch you create from which the multiple values should be claimed.
INPUTS
- node_block : PATRICIA tree nodes bunch block size.
- string_block : Tail strings block size.
- values : Bunch of map values.
RETURN VALUE
A freshly allocated multimap.
SEE ALSO
patricia_map, pmap_multi_t, pmap_multi_free
trish2/pmap_multi_free [ Functions ]
NAME
pmap_multi_free
SYNOPSIS
#include <patricia_map.h> void pmap_multi_free(pmap_multi_t *pmm);
FUNCTION
pmap_multi_free destroys a multimap. The values bunch passed to pmap_multi_new will not be freed.
INPUTS
- pmm : Multimap to destroy.
SEE ALSO
patricia_map, pmap_multi_t, pmap_multi_new
trish2/pmap_multi_add [ Functions ]
NAME
pmap_multi_add
SYNOPSIS
#include <patricia_map.h> void pmap_multi_add(pmap_multi_t *pmm, wchar_t *key, void *value);
FUNCTION
pmap_multi_add associates value to key in the multimap pmm. If key was already associated to one or several values, the value will be prepended at the beginning of the list. If value was not claimed from pmm->values, then pmap_multi_save will not work properly.
INPUTS
- pmm : Multimap to add the pair in.
- key : Key.
- value : New value to associate.
SEE ALSO
patricia_map, pmap_multi_t, pmap_multi_get
trish2/pmap_multi_get [ Functions ]
NAME
pmap_multi_get
SYNOPSIS
#include <patricia_map.h> pmap_multival_t *pmap_multi_get(pmap_multi_t *pmm, wchar_t *key);
FUNCTION
pmap_multi_get retrieves the values associated to key in pmm. The result is a pmap_multival_t pointer containing the first value, you must loop through the linked list in order to get all values.
INPUTS
- pmm : Multimap to search in.
- key : Key to search for.
RETURN VALUE
The linked list of values. NULL if the key is not associated to anything. These are not copies.
SEE ALSO
patricia_map, pmap_multival_t, pmap_multi_t, pmap_multi_add
trish2/pmap_multi_save [ Functions ]
NAME
pmap_multi_save
SYNOPSIS
#include <patricia_map.h> void pmap_multi_save(pmap_multi_t *pmm, int options, FILE *f);
FUNCTION
pmap_multi_save writes pmm into f. This function will call patricia_save and bunch_save (for the values), options will be passed through.
INPUTS
- pmm : Multimap to save.
- options : bunch_save options.
- f : File handle to write in (opened with fopen, mode "w" or "a").
SEE ALSO
patricia_map, pmap_multi_t, pmap_multi_load, patricia_save, bunch_save
trish2/pmap_multi_load [ Functions ]
NAME
pmap_multi_load
SYNOPSIS
#include <patricia_map.h> pmap_multi_t *pmap_multi_load(FILE *f);
FUNCTION
pmap_multi_load reads a multimap from f. You must be sure that f is at the same offset than when pmap_multi_save was called. Also if the values contain claimed pointers, you are responsible for correcting them.
INPUTS
- f : File to read from (opened with fopen, mode "r").
RETURN VALUE
A multimap pointer.
SEE ALSO
patricia_map, pmap_multi_t, pmap_multi_save, patricia_load, bunch_load