Data Model API (libmodel) | ||||
---|---|---|---|---|
Top | Description |
ModelSimpleListModelSimpleList — a very simple implementation of ModelList |
Synopsis
ModelSimpleList; void model_simple_list_splice (ModelSimpleList *list, gulong position, gulong n_removes, ModelObject * const *inserts, gulong n_inserts, gboolean more); void model_simple_list_remove (ModelSimpleList *list, gulong position); void model_simple_list_insert (ModelSimpleList *list, gulong position, ModelObject *value); void model_simple_list_append (ModelSimpleList *list, ModelObject *value);
Description
ModelSimpleList is a simple ModelList implementation. It is empty when constructed. There are simple APIs for inserting and removing items by their index. There is also a more complicated "splice" API to allow performing adjacent removes and inserts simultaneously.
If your list contains items that can be identified by some sort of key (such as files in a directory) then ModelAbstractSortedList might be more useful.
Details
ModelSimpleList
typedef struct _ModelSimpleList ModelSimpleList;
This is an opaque structure; it may not be accessed directly.
model_simple_list_splice ()
void model_simple_list_splice (ModelSimpleList *list, gulong position, gulong n_removes, ModelObject * const *inserts, gulong n_inserts, gboolean more);
Performs a splice operation on the list. This is similar to the JavaScript list operation of the same name.
Starting at position
, n_removes
items are removed from the list.
In their place, the items given in inserts
are added.
This function takes its own references to each of the items in
inserts
, but does not modify the array.
|
a ModelSimpleList |
|
the position at which to perform the splice |
|
the number of items to remove from position
|
|
the list of items to insert at position
|
|
the number of items to insert (the length of inserts )
|
|
TRUE if more events are coming
|
model_simple_list_remove ()
void model_simple_list_remove (ModelSimpleList *list, gulong position);
Removes a single item from the list.
|
a ModelSimpleList |
|
the index of the item to remove |
model_simple_list_insert ()
void model_simple_list_insert (ModelSimpleList *list, gulong position, ModelObject *value);
Inserts a single item to the list. position
is the index of the
item to insert before.
|
a ModelSimpleList |
|
the position to insert at |
|
the item to insert into the list |
model_simple_list_append ()
void model_simple_list_append (ModelSimpleList *list, ModelObject *value);
Appends an item to the end of the list.
|
a ModelSimpleList |
|
the item to insert into the list |