Data Structures | Typedefs
gfsmWeightMap.h File Reference

Abstract map from gpointers to gfsmWeights using GTree. More...

#include <gfsmSet.h>
#include <gfsmSemiring.h>
#include <gfsmWeightMap.hi>
Include dependency graph for gfsmWeightMap.h:
This graph shows which files directly or indirectly include this file:

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...

Typedefs

typedef GTree gfsmWeightMap
 Type for maps from arbitrary data to gfsmWeights with a balanced binary tree. really just an ugly wrapper for GTree.
typedef GArray gfsmStateWeightPairArray
 Type for a GArray of gfsmStateWeightPair.

Functions

gfsmWeight <-> gpointer Conversions
static gfsmWeight gfsm_ptr2weight (const gpointer p)
static gpointer gfsm_weight2ptr (const gfsmWeight w)
gfsmWeightMap: Constructors etc.
static gfsmWeightMapgfsm_weightmap_new_full (GCompareDataFunc key_cmp_func, gpointer key_cmp_data, GDestroyNotify key_free_func)
static gfsmWeightMapgfsm_weightmap_new (GCompareFunc key_cmp_func)
static gfsmWeightMapgfsm_weightmap_copy (gfsmWeightMap *dst, gfsmWeightMap *src)
static void gfsm_weightmap_clear (gfsmWeightMap *wm)
static void gfsm_weightmap_free (gfsmWeightMap *wm)

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)
gfsmStateWeightPairArraygfsm_weightmap_to_array (gfsmWeightMap *weightmap, gfsmStateWeightPairArray *array)

gfsmWeightHash: Constructors etc.

#define gfsm_weighthash_new(key_hash_f, key_equal_f)   gfsm_weighthash_new_full(NULL,(key_hash_f),(key_equal_f),NULL)
static gfsmWeightHashgfsm_weighthash_new_full (gfsmDupFunc key_dup_func, GHashFunc key_hash_func, GEqualFunc key_equal_func, GDestroyNotify key_destroy_func)
static void gfsm_weighthash_clear (gfsmWeightHash *wh)
static void gfsm_weighthash_free (gfsmWeightHash *wh)

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)

Get size of 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)

#define gfsm_weighthash_new (   key_hash_f,
  key_equal_f 
)    gfsm_weighthash_new_full(NULL,(key_hash_f),(key_equal_f),NULL)

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

typedef GTree gfsmWeightMap
typedef GArray gfsmStateWeightPairArray

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

Create and return a new gfsmWeightMap

static gfsmWeightMap* gfsm_weightmap_new ( GCompareFunc  key_cmp_func)
inlinestatic

Create and return a new weightmap which does not copy stored keys.

static gfsmWeightMap* gfsm_weightmap_copy ( gfsmWeightMap dst,
gfsmWeightMap src 
)
inlinestatic

Copy weightmap src to dst.

Returns
dst
static void gfsm_weightmap_clear ( gfsmWeightMap wm)
inlinestatic

Clear a gfsmWeightMap

static void gfsm_weightmap_free ( gfsmWeightMap wm)
inlinestatic

Destroy a weightmap

static gboolean gfsm_weightmap_contains ( gfsmWeightMap weightmap,
gconstpointer  key 
)
inlinestatic

lookup: check weightmap membership

static gboolean gfsm_weightmap_lookup ( gfsmWeightMap weightmap,
gconstpointer  key,
gfsmWeight wp 
)
inlinestatic

extended lookup: get weight associated with key

static void gfsm_weightmap_insert ( gfsmWeightMap weightmap,
gconstpointer  key,
gfsmWeight  w 
)
inlinestatic

insert a new key->weight mapping into the weightmap insert a new key->weight mapping into the weightmap or overwrite old mapping

static gfsmWeight gfsm_weightmap_insert_sum ( gfsmWeightMap weightmap,
gconstpointer  key,
gfsmWeight  w,
gfsmSemiring sr 
)
inlinestatic

insert a new key->weight mapping into the weightmap, semiring-adding with old weight if present

Returns
new weight associated with key.
gfsmStateWeightPairArray* gfsm_weightmap_to_array ( gfsmWeightMap weightmap,
gfsmStateWeightPairArray array 
)

Copy contents of a gfsmWeightMap into a gfsmStateWeightPairArray

Parameters
weightmapweightmap to examine
arrayarray to be populated, or NULL to allocate a new array
Returns
array, or a newly allocated gfsmStateWeightPairArray
Note
Caller is responsible for freeing array when it is no longer needed.
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

static void gfsm_weighthash_clear ( gfsmWeightHash wh)
inlinestatic

clear a weight-hash

static void gfsm_weighthash_free ( gfsmWeightHash wh)
inlinestatic

destroy a weight-hash

static gboolean gfsm_weighthash_lookup ( gfsmWeightHash wh,
gconstpointer  key,
gfsmWeight wp 
)
inlinestatic

extended lookup: get weight associated with key

static void gfsm_weighthash_insert ( gfsmWeightHash wh,
gconstpointer  key,
gfsmWeight  w 
)
inlinestatic

insert a key->weight mapping into the weighthash

static gboolean gfsm_weighthash_insert_if_less ( gfsmWeightHash wh,
gconstpointer  key,
gfsmWeight  w,
gfsmSemiring sr 
)
inlinestatic

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.
static gboolean gfsm_weighthash_insert_sum_if_less ( gfsmWeightHash wh,
gconstpointer  key,
gfsmWeight  w,
gfsmSemiring sr 
)
inlinestatic

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.