Sequence

Description The GSequence data structure has the API of a list, but is implemented internally with a balanced binary tree. This means that it is possible to maintain a sorted list of n elements in time O(n log n). The data contained in each element can be either integer values, by using of the Type Conversion Macros, or simply pointers to any type of data. A GSequence is accessed through iterators, represented by a GSequenceIter. An iterator represents a position between two elements of the sequence. For example, the begin iterator represents the gap immediately before the first element of the sequence, and the end iterator represents the gap immediately after the last element. In an empty sequence, the begin and end iterators are the same. Some methods on GSequence operate on ranges of items. For example g_sequence_foreach_range() will call a user-specified function on each element with the given range. The range is delimited by the gaps represented by the passed-in iterators, so if you pass in the begin and end iterators, the range in question is the entire sequence. The function g_sequence_get() is used with an iterator to access the element immediately following the gap that the iterator represents. The iterator is said to point to that element. Iterators are stable across most operations on a GSequence. For example an iterator pointing to some element of a sequence will continue to point to that element even after the sequence is sorted. Even moving an element to another sequence using for example g_sequence_move_range() will not invalidate the iterators pointing to it. The only operation that will invalidate an iterator is when the element it points to is removed from any sequence.

class Sequence {}

Constructors

this
this(GSequence* gSequence)

Sets our main struct and passes it to the parent class

this
this(GDestroyNotify dataDestroy)

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

Members

Functions

append
SequenceIter append(void* data)

Adds a new item to the end of seq. Since 2.14

foreac
void foreac(GFunc func, void* userData)

Calls func for each item in the sequence passing user_data to the function. Since 2.14

free
void 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

getBeginIter
SequenceIter getBeginIter()

Returns the begin iterator for seq. Since 2.14

getEndIter
SequenceIter getEndIter()

Returns the end iterator for seg Since 2.14

getIterAtPos
SequenceIter getIterAtPos(int 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

getLength
int getLength()

Returns the length of seq Since 2.14

getSequenceStruct
GSequence* getSequenceStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

insertSorted
SequenceIter insertSorted(void* data, GCompareDataFunc cmpFunc, void* cmpData)

Inserts data into sequence using 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

insertSortedIter
SequenceIter insertSortedIter(void* data, GSequenceIterCompareFunc iterCmp, void* cmpData)

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

lookup
SequenceIter lookup(void* data, GCompareDataFunc cmpFunc, void* cmpData)

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

lookupIter
SequenceIter lookupIter(void* data, GSequenceIterCompareFunc iterCmp, void* cmpData)

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

prepend
SequenceIter prepend(void* data)

Adds a new item to the front of seq Since 2.14

search
SequenceIter search(void* data, GCompareDataFunc cmpFunc, void* cmpData)

Returns an iterator pointing to the position where data would be inserted according to cmp_func and cmp_data. If you are simply searching for an existing element of the sequence, consider using g_sequence_lookup(). Since 2.14

searchIter
SequenceIter searchIter(void* data, GSequenceIterCompareFunc iterCmp, void* cmpData)

Like g_sequence_search(), but uses a GSequenceIterCompareFunc instead of a GCompareDataFunc as the compare function. If you are simply searching for an existing element of the sequence, consider using g_sequence_lookup_iter(). Since 2.14

sort
void sort(GCompareDataFunc cmpFunc, void* cmpData)

Sorts seq using cmp_func. Since 2.14

sortIter
void sortIter(GSequenceIterCompareFunc cmpFunc, void* cmpData)

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

Static functions

foreachRange
void foreachRange(SequenceIter begin, SequenceIter end, GFunc func, void* userData)

Calls func for each item in the range (begin, end) passing user_data to the function. Since 2.14

get
void* get(SequenceIter iter)

Returns the data that iter points to. Since 2.14

insertBefore
SequenceIter insertBefore(SequenceIter iter, void* data)

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

move
void move(SequenceIter src, SequenceIter dest)

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

moveRange
void moveRange(SequenceIter dest, SequenceIter begin, SequenceIter end)

Inserts the (begin, end) range at the destination pointed to by ptr. 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. If dest is NULL, the range indicated by begin and end is removed from the sequence. If dest iter points to a place within the (begin, end) range, the range does not move. Since 2.14

rangeGetMidpoint
SequenceIter rangeGetMidpoint(SequenceIter begin, SequenceIter end)

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. The begin and end iterators must both point to the same sequence and begin must come before or be equal to end in the sequence. Since 2.14

remove
void remove(SequenceIter iter)

Removes the item pointed to by iter. It is an error to pass the end iterator to this function. If the sequnce has a data destroy function associated with it, this function is called on the data for the removed item. Since 2.14

removeRange
void removeRange(SequenceIter begin, SequenceIter end)

Removes all items in the (begin, end) range. If the sequence has a data destroy function associated with it, this function is called on the data for the removed items. Since 2.14

set
void set(SequenceIter iter, void* data)

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

sortChanged
void sortChanged(SequenceIter iter, GCompareDataFunc cmpFunc, void* cmpData)

Moves the data pointed 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

sortChangedIter
void sortChangedIter(SequenceIter iter, GSequenceIterCompareFunc iterCmp, void* cmpData)

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

swap
void swap(SequenceIter a, SequenceIter b)

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

Variables

gSequence
GSequence* gSequence;

the main Gtk struct

Meta