Tuple

Tuple — Tuple.

Synopsis


#include <libhrel/tuple.h>


typedef     HTuple;
            HTupleElem;
GType       h_tuple_get_type                (void);
HTuple*     h_tuple_new                     (void);
HTuple*     h_tuple_new_v                   (guint size,
                                             va_list list);
void        h_tuple_free                    (HTuple *tuple);
HTuple*     h_tuple_clone                   (HTuple *tuple);
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);
HTupleElem* h_tuple_get                     (HTuple *tuple,
                                             const gchar *name);
gpointer    h_tuple_get_value               (HTuple *tuple,
                                             const gchar *name);
gboolean    h_tuple_equal                   (HTuple *tuple1,
                                             HTuple *tuple2);
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_v         (HTuple *tuple1,
                                             HTuple *tuple2,
                                             va_list elem_names);
guint       h_tuple_hash                    (HTuple *tuple);
guint       h_tuple_hash_elems              (HTuple *tuple,
                                             ...);

Description

Details

HTuple

typedef GHashTable         HTuple;


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_get_type ()

GType       h_tuple_get_type                (void);

Returns the Glib type ID for HTuple.

Returns : type ID for HTuple

h_tuple_new ()

HTuple*     h_tuple_new                     (void);

Creates a new empty tuple.

Returns : a newly created empty HTuple, or NULL.

h_tuple_new_v ()

HTuple*     h_tuple_new_v                   (guint size,
                                             va_list list);

Constructs a tuple from an argument list.

size : degree
list : 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_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 attribute
type : type of attribute
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_get ()

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

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

tuple : a HTuple
name : name of attribute
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 attribute in tuple, or NULL if attribute doesn't exist.

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

h_tuple_equal ()

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

Compares two tuple1 and tuple2 for equality. (TODO: Need elaboration).

tuple1 : a HTuple
tuple2 : a HTuple
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 attribute in tuple1 and tuple2.

tuple1 : left HTuple operand
tuple2 : right HTuple operand
name : name of attribute to compare
Returns : -1 if tuple1 is greater, 1 if tuple2 is greater, 0 if equal

h_tuple_compare_elems ()

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

Compares the values of each common attribute in tuple1 and tuple2 in the order listed. (TODO: needs elaboration)

tuple1 : left HTuple operand
tuple2 : right HTuple operand
... : name of 1st attribute, name of 2nd attribute, and so on, ending with a NULL.
Returns : -1 if tuple1 is greater, 1 if tuple2 is greater, 0 if equal

h_tuple_compare_elems_v ()

gint        h_tuple_compare_elems_v         (HTuple *tuple1,
                                             HTuple *tuple2,
                                             va_list elem_names);

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

tuple1 : left HTuple operand
tuple2 : right HTuple operand
elem_names : argument list (see h_tuple_compare_elems)
Returns : -1 if tuple1 is greater, 1 if tuple2 is greater, 0 if equal

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. Note that the hash is independent of the order in which attribute names are listed. (TODO: elaborate).

tuple : a HTuple
... : first attribute name, followed by the second, and so on, ending with a NULL.
Returns : hash number