Tuple

Tuple — Tuple.

Synopsis


#include <libhrel/tuple.h>


typedef     HTuple;
            HTupleElem;
HTuple*     h_tuple_new                     (void);
HTuple*     h_tuple_newv                    (gboolean typed,
                                             ...);
HTuple*     h_tuple_new_v                   (gboolean typed,
                                             va_list args);
HTuple*     h_tuple_n_new_v                 (gboolean typed,
                                             guint size,
                                             va_list args);
void        h_tuple_free                    (HTuple *tuple);
HTuple*     h_tuple_clone                   (HTuple *tuple);
HTuple*     h_tuple_clone_elems_l           (HTuple *tuple,
                                             GSList *list);
HTupleElem* h_tuple_get                     (HTuple *tuple,
                                             const gchar *name);
gpointer    h_tuple_get_value               (HTuple *tuple,
                                             const gchar *name);
guint       h_tuple_get_size                (HTuple *tuple);
void        h_tuple_insert                  (HTuple *tuple,
                                             const gchar *name,
                                             GType type,
                                             gpointer value);
void        h_tuple_print                   (HTuple *tuple);
gboolean    h_tuple_equal                   (HTuple *tuple1,
                                             HTuple *tuple2);
gboolean    h_tuple_equal_elem              (HTuple *tuple1,
                                             HTuple *tuple2,
                                             const gchar *name);
gboolean    h_tuple_equal_elems             (HTuple *tuple1,
                                             HTuple *tuple2,
                                             ...);
gboolean    h_tuple_equal_elems_l           (HTuple *tuple1,
                                             HTuple *tuple2,
                                             GSList *list);
gint        h_tuple_compare_elem            (HTuple *tuple1,
                                             HTuple *tuple2,
                                             const gchar *name);
gint        h_tuple_compare_elems           (HTuple *tuple1,
                                             HTuple *tuple2,
                                             ...);
gint        h_tuple_compare_elems_l         (HTuple *tuple1,
                                             HTuple *tuple2,
                                             GSList *list);
guint       h_tuple_hash                    (HTuple *tuple);
guint       h_tuple_hash_elems              (HTuple *tuple,
                                             ...);
guint       h_tuple_hash_elems_l            (HTuple *tuple,
                                             GSList *list);

Description

Details

HTuple

typedef GHashTable         HTuple;

Tuple type.


HTupleElem

typedef struct {
    GType    type;
    gpointer value;
} HTupleElem;

Stores type and value of a tuple (HTuple) component.

GType type; type
gpointer value; value of type

h_tuple_new ()

HTuple*     h_tuple_new                     (void);

Creates a new empty tuple.

Returns : a newly created empty HTuple, or NULL.

h_tuple_newv ()

HTuple*     h_tuple_newv                    (gboolean typed,
                                             ...);

Constructs a tuple from a list of components.

typed : set to FALSE to create a typeless tuple
... : name, type (omitted if typeless), value of first component, followed by the second, and so on, then NULL
Returns : newly constructed HTuple, or NULL

h_tuple_new_v ()

HTuple*     h_tuple_new_v                   (gboolean typed,
                                             va_list args);

Constructs a tuple from an argument list.

typed : set to FALSE to create a typeless tuple
args : argument list
Returns : a newly constructed HTuple, or NULL

h_tuple_n_new_v ()

HTuple*     h_tuple_n_new_v                 (gboolean typed,
                                             guint size,
                                             va_list args);

Constructs an n-tuple from an argument list.

typed : set to FALSE to create a typeless tuple
size : size
args : argument list
Returns : a newly constructed HTuple, or NULL

h_tuple_free ()

void        h_tuple_free                    (HTuple *tuple);

Free memory used by tuple.

tuple : a HTuple

h_tuple_clone ()

HTuple*     h_tuple_clone                   (HTuple *tuple);

Returns a copy of tuple.

tuple : a HTuple
Returns : copy of tuple

h_tuple_clone_elems_l ()

HTuple*     h_tuple_clone_elems_l           (HTuple *tuple,
                                             GSList *list);

Constructs a subset of tuple, with attributes listed in list.

tuple : a HTuple
list : list of attribute names
Returns : subset of tuple.

h_tuple_get ()

HTupleElem* h_tuple_get                     (HTuple *tuple,
                                             const gchar *name);

Returns the type and value of an component in tuple, or NULL if component doesn't exist.

tuple : a HTuple
name : name of component
Returns : a HTupleElem containing the type and value.

h_tuple_get_value ()

gpointer    h_tuple_get_value               (HTuple *tuple,
                                             const gchar *name);

Returns the value of an component in tuple, or NULL if component doesn't exist.

tuple : a HTuple
name : name of component
Returns : a copy of the component value

h_tuple_get_size ()

guint       h_tuple_get_size                (HTuple *tuple);

Returns the degree ('size') of tuple.

tuple : a HTuple
Returns : degree ('size') of tuple

h_tuple_insert ()

void        h_tuple_insert                  (HTuple *tuple,
                                             const gchar *name,
                                             GType type,
                                             gpointer value);

Adds a new atribute named name, of type type and value value.

tuple : a HTuple
name : name of component
type : type of component
value : value of type

h_tuple_print ()

void        h_tuple_print                   (HTuple *tuple);

Prints the content of tuple to stdout.

tuple : a HTuple

h_tuple_equal ()

gboolean    h_tuple_equal                   (HTuple *tuple1,
                                             HTuple *tuple2);

Compares tuple1 and tuple2 for equality.

tuple1 : a HTuple
tuple2 : a HTuple
Returns : TRUE if equal, FALSE if not

h_tuple_equal_elem ()

gboolean    h_tuple_equal_elem              (HTuple *tuple1,
                                             HTuple *tuple2,
                                             const gchar *name);

Compares a common component in tuple1 and tuple2 for equality.

tuple1 : a HTuple
tuple2 : a HTuple
name : name of component to compare
Returns : TRUE if equal, FALSE if not

h_tuple_equal_elems ()

gboolean    h_tuple_equal_elems             (HTuple *tuple1,
                                             HTuple *tuple2,
                                             ...);

Compares common components in tuple1 and tuple2 for equality. If no component names are provided, all components are compared (equivalent to h_tuple_equal()).

tuple1 : a HTuple
tuple2 : a HTuple
... : first component name, followed by the second and so on, then NULL
Returns : TRUE if equal, FALSE if not

h_tuple_equal_elems_l ()

gboolean    h_tuple_equal_elems_l           (HTuple *tuple1,
                                             HTuple *tuple2,
                                             GSList *list);

A variation of h_tuple_equal_elems with the component name list is stored as a GSList.

tuple1 : a HTuple
tuple2 : a HTuple
list : name list of components to compare
Returns : TRUE if equal, FALSE if not

h_tuple_compare_elem ()

gint        h_tuple_compare_elem            (HTuple *tuple1,
                                             HTuple *tuple2,
                                             const gchar *name);

Compares the values of a common component in tuple1 and tuple2.

tuple1 : a HTuple
tuple2 : a HTuple
name : name of component to compare
Returns : negative if tuple1 is smaller, 0 if equal, positive if greater

h_tuple_compare_elems ()

gint        h_tuple_compare_elems           (HTuple *tuple1,
                                             HTuple *tuple2,
                                             ...);

Compares the values of each common component in tuple1 and tuple2 in the order listed.

tuple1 : a HTuple
tuple2 : a HTuple
... : name of 1st component, name of 2nd component, and so on, ending with a NULL.
Returns : negative if tuple1 is smaller, 0 if equal, positive if greater

h_tuple_compare_elems_l ()

gint        h_tuple_compare_elems_l         (HTuple *tuple1,
                                             HTuple *tuple2,
                                             GSList *list);

A variation of h_tuple_compare_elems(), where the component name list is stored as a GSList.

tuple1 : a HTuple
tuple2 : a HTuple
list : list of component names
Returns : negative if tuple1 is smaller, 0 if equal, positive if greater

h_tuple_hash ()

guint       h_tuple_hash                    (HTuple *tuple);

Returns the hash of tuple.

tuple : a HTuple
Returns : hash number

h_tuple_hash_elems ()

guint       h_tuple_hash_elems              (HTuple *tuple,
                                             ...);

Returns the hash of a subset of tuple. If no components were specified, all components are used to generate the hash. The hash is independent of the order in which component names are listed.

tuple : a HTuple
... : a component name, followed by another, and so on, ending with a NULL
Returns : hash number

h_tuple_hash_elems_l ()

guint       h_tuple_hash_elems_l            (HTuple *tuple,
                                             GSList *list);

A variation on h_tuple_hash_elems(), where the component name list is store as a GSList.

tuple : a HTuple
list : list of component names
Returns : hash number