Top |
GListStoreGListStore — A simple implementation of GListModel |
GListStore * | g_list_store_new () |
void | g_list_store_insert () |
guint | g_list_store_insert_sorted () |
void | g_list_store_append () |
void | g_list_store_remove () |
void | g_list_store_remove_all () |
void | g_list_store_splice () |
void | g_list_store_sort () |
GListStore is a simple implementation of GListModel that stores all items in memory.
It provides insertions, deletions, and lookups in logarithmic time with a fast path for the common case of iterating the list linearly.
GListStore *
g_list_store_new (GType item_type
);
Creates a new GListStore with items of type item_type
. item_type
must be a subclass of GObject.
Since: 2.44
void g_list_store_insert (GListStore *store
,guint position
,gpointer item
);
Inserts item
into store
at position
. item
must be of type
“item-type” or derived from it. position
must be smaller
than the length of the list, or equal to it to append.
This function takes a ref on item
.
Use g_list_store_splice()
to insert multiple items at the same time
efficiently.
store |
||
position |
the position at which to insert the new item |
|
item |
the new item. |
[type GObject] |
Since: 2.44
guint g_list_store_insert_sorted (GListStore *store
,gpointer item
,GCompareDataFunc compare_func
,gpointer user_data
);
Inserts item
into store
at a position to be determined by the
compare_func
.
The list must already be sorted before calling this function or the result is undefined. Usually you would approach this by only ever inserting items by way of this function.
This function takes a ref on item
.
store |
||
item |
the new item. |
[type GObject] |
compare_func |
pairwise comparison function for sorting. |
[scope call] |
user_data |
user data for |
[closure] |
Since: 2.44
void g_list_store_append (GListStore *store
,gpointer item
);
Appends item
to store
. item
must be of type “item-type”.
This function takes a ref on item
.
Use g_list_store_splice()
to append multiple items at the same time
efficiently.
Since: 2.44
void g_list_store_remove (GListStore *store
,guint position
);
Removes the item from store
that is at position
. position
must be
smaller than the current length of the list.
Use g_list_store_splice()
to remove multiple items at the same time
efficiently.
Since: 2.44
void
g_list_store_remove_all (GListStore *store
);
Removes all items from store
.
Since: 2.44
void g_list_store_splice (GListStore *store
,guint position
,guint n_removals
,gpointer *additions
,guint n_additions
);
Changes store
by removing n_removals
items and adding n_additions
items to it. additions
must contain n_additions
items of type
“item-type”. NULL
is not permitted.
This function is more efficient than g_list_store_insert()
and
g_list_store_remove()
, because it only emits
“items-changed” once for the change.
This function takes a ref on each item in additions
.
The parameters position
and n_removals
must be correct (ie:
position
+ n_removals
must be less than or equal to the length of
the list at the time this function is called).
store |
||
position |
the position at which to make the change |
|
n_removals |
the number of items to remove |
|
additions |
the items to add. |
[array length=n_additions][element-type GObject] |
n_additions |
the number of items to add |
Since: 2.44
void g_list_store_sort (GListStore *store
,GCompareDataFunc compare_func
,gpointer user_data
);
Sort the items in store
according to compare_func
.
store |
||
compare_func |
pairwise comparison function for sorting. |
[scope call] |
user_data |
user data for |
[closure] |
Since: 2.46
typedef struct _GListStore GListStore;
GListStore is an opaque data structure and can only be accessed using the following functions.