Abstract map from gpointers to gfsmWeights using GTree.
More...
#include <gfsmSet.h>
#include <gfsmSemiring.h>
#include <gfsmWeightMap.hi>
Go to the source code of this file.
Data Structures |
struct | gfsmWeightHash |
| Structure for mapping arbitrary data to gfsmWeights with a hash. really just an ugly wrapper for GHashTable. More...
|
union | gfsmWeightOrPointer |
| Union type for converting between gfsmWeight and gpointer. Requires that sizeof(gpointer)>=sizeof(gfsmWeight) in order to work properly. More...
|
gfsmWeightmap: Accessors |
#define | gfsm_weightmap_size(weightmap) g_tree_nnodes(weightmap) |
#define | gfsm_weightmap_remove(weightmap, key) g_tree_remove((weightmap),((gpointer)(key))) |
#define | gfsm_weightmap_foreach(weightmap, func, data) g_tree_foreach((weightmap),(func),(data)) |
static gboolean | gfsm_weightmap_contains (gfsmWeightMap *weightmap, gconstpointer key) |
static gboolean | gfsm_weightmap_lookup (gfsmWeightMap *weightmap, gconstpointer key, gfsmWeight *wp) |
static void | gfsm_weightmap_insert (gfsmWeightMap *weightmap, gconstpointer key, gfsmWeight w) |
static gfsmWeight | gfsm_weightmap_insert_sum (gfsmWeightMap *weightmap, gconstpointer key, gfsmWeight w, gfsmSemiring *sr) |
gfsmStateWeightPairArray * | gfsm_weightmap_to_array (gfsmWeightMap *weightmap, gfsmStateWeightPairArray *array) |
gfsmWeightHash: Accessors |
#define | gfsm_weighthash_foreach(wh, func, data) g_hash_table_foreach((wh)->table,(func),(data)) |
static gboolean | gfsm_weighthash_lookup (gfsmWeightHash *wh, gconstpointer key, gfsmWeight *wp) |
static void | gfsm_weighthash_insert (gfsmWeightHash *wh, gconstpointer key, gfsmWeight w) |
static gboolean | gfsm_weighthash_insert_if_less (gfsmWeightHash *wh, gconstpointer key, gfsmWeight w, gfsmSemiring *sr) |
static gboolean | gfsm_weighthash_insert_sum_if_less (gfsmWeightHash *wh, gconstpointer key, gfsmWeight w, gfsmSemiring *sr) |
Detailed Description
Macro Definition Documentation
#define gfsm_weightmap_size |
( |
|
weightmap | ) |
g_tree_nnodes(weightmap) |
#define gfsm_weightmap_remove |
( |
|
weightmap, |
|
|
|
key |
|
) |
| g_tree_remove((weightmap),((gpointer)(key))) |
Remove an element from a weightmap
#define gfsm_weightmap_foreach |
( |
|
weightmap, |
|
|
|
func, |
|
|
|
data |
|
) |
| g_tree_foreach((weightmap),(func),(data)) |
Traversal (see g_tree_foreach)
create & return a new hashing weightmap (returned map will not copy or free keys
#define gfsm_weighthash_foreach |
( |
|
wh, |
|
|
|
func, |
|
|
|
data |
|
) |
| g_hash_table_foreach((wh)->table,(func),(data)) |
Traversal (see g_hash_table_foreach)
Typedef Documentation
Function Documentation
static gfsmWeight gfsm_ptr2weight |
( |
const gpointer |
p | ) |
|
|
inlinestatic |
Convert a gpointer to a gfsmWeight
static gpointer gfsm_weight2ptr |
( |
const gfsmWeight |
w | ) |
|
|
inlinestatic |
Macro to convert gfsmWeight->gpointer
static gfsmWeightMap* gfsm_weightmap_new_full |
( |
GCompareDataFunc |
key_cmp_func, |
|
|
gpointer |
key_cmp_data, |
|
|
GDestroyNotify |
key_free_func |
|
) |
| |
|
inlinestatic |
static gfsmWeightMap* gfsm_weightmap_new |
( |
GCompareFunc |
key_cmp_func | ) |
|
|
inlinestatic |
Create and return a new weightmap which does not copy stored keys.
Copy weightmap src to dst.
- Returns
- dst
static gboolean gfsm_weightmap_contains |
( |
gfsmWeightMap * |
weightmap, |
|
|
gconstpointer |
key |
|
) |
| |
|
inlinestatic |
lookup: check weightmap membership
extended lookup: get weight associated with key
insert a new key->weight mapping into the weightmap insert a new key->weight mapping into the weightmap or overwrite old mapping
insert a new key->weight mapping into the weightmap, semiring-adding with old weight if present
- Returns
- new weight associated with key.
static gfsmWeightHash* gfsm_weighthash_new_full |
( |
gfsmDupFunc |
key_dup_func, |
|
|
GHashFunc |
key_hash_func, |
|
|
GEqualFunc |
key_equal_func, |
|
|
GDestroyNotify |
key_destroy_func |
|
) |
| |
|
inlinestatic |
Create and return a new hashing weight-map
extended lookup: get weight associated with key
insert a key->weight mapping into the weighthash
Possibly insert a key->weight mapping into the weighthash The mapping (key=>w) is inserted if either no mapping for key exists in wh, or if w is strictly less-than the stored weight for key according to sr.
- Returns
- TRUE if the mapping was updated, otherwise FALSE.
Possibly insert a key->weight mapping into the weighthash The mapping (key=>w) is inserted if no mapping for key exists in wh. Otherwise, the stored weight (stored_w) for key is set to (w+stored_w) just in case (w+stored_w) is strictly less than stored_w for key according to sr.
- Returns
- TRUE if the mapping was updated, otherwise FALSE.