TABLE OF CONTENTS


trish2/patricia_map [ Modules ]

[ Top ] [ 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 ]

[ Top ] [ 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

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 ]

[ Top ] [ 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

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

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

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 ]

[ Top ] [ 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

RETURN VALUE

A freshly allocated multimap.

SEE ALSO

patricia_map, pmap_multi_t, pmap_multi_free


trish2/pmap_multi_free [ Functions ]

[ Top ] [ 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

SEE ALSO

patricia_map, pmap_multi_t, pmap_multi_new


trish2/pmap_multi_add [ Functions ]

[ Top ] [ 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

SEE ALSO

patricia_map, pmap_multi_t, pmap_multi_get


trish2/pmap_multi_get [ Functions ]

[ Top ] [ 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

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 ]

[ Top ] [ 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

SEE ALSO

patricia_map, pmap_multi_t, pmap_multi_load, patricia_save, bunch_save


trish2/pmap_multi_load [ Functions ]

[ Top ] [ 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

RETURN VALUE

A multimap pointer.

SEE ALSO

patricia_map, pmap_multi_t, pmap_multi_save, patricia_load, bunch_load