Sorting

Sorting — Sorting.

Synopsis


#include <libhrel/relation.h>


            HRelationSort;
HRelation*  h_relation_sort                 (HRelation *relation,
                                             GCompareDataFunc compare_func,
                                             gpointer user_data);
HRelation*  h_relation_sort_by_attrs        (HRelation *relation,
                                             ...);
HRelation*  h_relation_sort_by_attrs_l      (HRelation *relation,
                                             GSList *list);

Object Hierarchy


  GObject
   +----HRelation
         +----HRelationSort

Description

Strictly speaking, tuples in a relation are by definition unordered. While HRelationSort is a HRelation due to inheritance, it does not represent a relation.

Details

HRelationSort

typedef struct _HRelationSort HRelationSort;

A HRelation representing a "sorted relation".


h_relation_sort ()

HRelation*  h_relation_sort                 (HRelation *relation,
                                             GCompareDataFunc compare_func,
                                             gpointer user_data);

Creates a sorted relation.

relation : a relation to sort
compare_func : function to compare a pair of tuples in relation
user_data : Custom data passed to compare_func
Returns : sorted relation

h_relation_sort_by_attrs ()

HRelation*  h_relation_sort_by_attrs        (HRelation *relation,
                                             ...);

Creates a relation sorted by attributes. Each pair of tuples are compared attribute by attribute in the order listed.

relation : relation to sort
... : name of first attribute, followed by the second and so on, then a NULL
Returns : sorted relation

h_relation_sort_by_attrs_l ()

HRelation*  h_relation_sort_by_attrs_l      (HRelation *relation,
                                             GSList *list);

A variation of h_relation_sort_by_attrs(), taking a GSList for the attribute name list.

relation : relation to sort
list : list of attribute names
Returns : sorted relation