GLib.Sequence
Description: Reference for GLib.Sequence

### Struct

# GLibSequence

#### Description [src]

    struct GSequence {
      /* No available fields */
    }

The `GSequence` struct is an opaque data type representing a sequence data type.

#### Functions

###### g_sequence_foreach_range

Calls `func` for each item in the range (`begin`, `end`) passing `user_data` to the function. `func` must not modify the sequence itself.

since: 2.14

###### g_sequence_get

Returns the data that `iter` points to.

since: 2.14

###### g_sequence_insert_before

Inserts a new item just before the item pointed to by `iter`.

since: 2.14

###### g_sequence_move

Moves the item pointed to by `src` to the position indicated by `dest`. After calling this function `dest` will point to the position immediately after `src`. It is allowed for `src` and `dest` to point into different sequences.

since: 2.14

###### g_sequence_move_range

Inserts the (`begin`, `end`) range at the destination pointed to by `dest`. The `begin` and `end` iters must point into the same sequence. It is allowed for `dest` to point to a different sequence than the one pointed into by `begin` and `end`.

since: 2.14

###### g_sequence_new

Creates a new GSequence. The `data_destroy` function, if non-`NULL` will be called on all items when the sequence is destroyed and on items that are removed from the sequence.

since: 2.14

###### g_sequence_range_get_midpoint

Finds an iterator somewhere in the range (`begin`, `end`). This iterator will be close to the middle of the range, but is not guaranteed to be exactly in the middle.

since: 2.14

###### g_sequence_remove

Removes the item pointed to by `iter`. It is an error to pass the end iterator to this function.

since: 2.14

###### g_sequence_remove_range

Removes all items in the (`begin`, `end`) range.

since: 2.14

###### g_sequence_set

Changes the data for the item pointed to by `iter` to be `data`. If the sequence has a data destroy function associated with it, that function is called on the existing data that `iter` pointed to.

since: 2.14

###### g_sequence_sort_changed

Moves the data pointed to by `iter` to a new position as indicated by `cmp_func`. This function should be called for items in a sequence already sorted according to `cmp_func` whenever some aspect of an item changes so that `cmp_func` may return different values for that item.

since: 2.14

###### g_sequence_sort_changed_iter

Like g_sequence_sort_changed(), but uses a `GSequenceIterCompareFunc` instead of a `GCompareDataFunc` as the compare function.

since: 2.14

###### g_sequence_swap

Swaps the items pointed to by `a` and `b`. It is allowed for `a` and `b` to point into difference sequences.

since: 2.14

#### Instance methods

###### g_sequence_append

Adds a new item to the end of `seq`.

since: 2.14

###### g_sequence_foreach

Calls `func` for each item in the sequence passing `user_data` to the function. `func` must not modify the sequence itself.

since: 2.14

###### g_sequence_free

Frees the memory allocated for `seq`. If `seq` has a data destroy function associated with it, that function is called on all items in `seq`.

since: 2.14

###### g_sequence_get_begin_iter

Returns the begin iterator for `seq`.

since: 2.14

###### g_sequence_get_end_iter

Returns the end iterator for `seg`.

since: 2.14

###### g_sequence_get_iter_at_pos

Returns the iterator at position `pos`. If `pos` is negative or larger than the number of items in `seq`, the end iterator is returned.

since: 2.14

###### g_sequence_get_length

Returns the positive length (>= 0) of `seq`. Note that this method is O(h) where `h' is the height of the tree. It is thus more efficient to use`g_sequence_is_empty()` when comparing the length to zero.

since: 2.14

###### g_sequence_insert_sorted

Inserts `data` into `seq` using `cmp_func` to determine the new position. The sequence must already be sorted according to `cmp_func`; otherwise the new position of `data` is undefined.

since: 2.14

###### g_sequence_insert_sorted_iter

Like g_sequence_insert_sorted(), but uses a `GSequenceIterCompareFunc` instead of a `GCompareDataFunc` as the compare function.

since: 2.14

###### g_sequence_is_empty

Returns `TRUE` if the sequence contains zero items.

since: 2.48

###### g_sequence_lookup

Returns an iterator pointing to the position of the first item found equal to `data` according to `cmp_func` and `cmp_data`. If more than one item is equal, it is not guaranteed that it is the first which is returned. In that case, you can use `g_sequence_iter_next()` and `g_sequence_iter_prev()` to get others.

since: 2.28

###### g_sequence_lookup_iter

Like g_sequence_lookup(), but uses a `GSequenceIterCompareFunc` instead of a `GCompareDataFunc` as the compare function.

since: 2.28

###### g_sequence_prepend

Adds a new item to the front of `seq`.

since: 2.14

###### g_sequence_search

Returns an iterator pointing to the position where `data` would be inserted according to `cmp_func` and `cmp_data`.

since: 2.14

###### g_sequence_search_iter

Like g_sequence_search(), but uses a `GSequenceIterCompareFunc` instead of a `GCompareDataFunc` as the compare function.

since: 2.14

###### g_sequence_sort

Sorts `seq` using `cmp_func`.

since: 2.14

###### g_sequence_sort_iter

Like g_sequence_sort(), but uses a `GSequenceIterCompareFunc` instead of a `GCompareDataFunc` as the compare function.

since: 2.14