ModelSimpleList

ModelSimpleList — 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.

simple :

a ModelSimpleList

position :

the position at which to perform the splice

n_removes :

the number of items to remove from position

inserts :

the list of items to insert at position

n_inserts :

the number of items to insert (the length of inserts)

more :

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.

simple :

a ModelSimpleList

position :

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.

simple :

a ModelSimpleList

position :

the position to insert at

value :

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.

simple :

a ModelSimpleList

value :

the item to insert into the list