Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: GSequence

[13:7] extends: object

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

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • GSequence (Handle = null)

    Creates a new Sequence by wrapping a native handle or another wrapper.

    • @p Handle is the native handle or another wrapper whose handle to adopt.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • append (data)

    Adds a new item to the end of @seq.

    • @p data is the data for the new item.
    • @r an iterator pointing to the new item.
  • foreach (user_data)

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

    • @p func is the function to call for each item in @seq.
    • @p user_data is user data passed to @func.
    • @r None.
  • 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.

    • @r None.
  • get_begin_iter ()

    Returns the begin iterator for @seq.

    • @r the begin iterator for @seq..
  • get_end_iter ()

    Returns the end iterator for @seg

    • @r the end iterator for @seq.
  • get_iter_at_pos (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.

    • @p pos is a position in @seq, or -1 for the end.
    • @r The #GSequenceIter at position @pos.
  • 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.

    • @r the length of @seq.
  • insert_sorted (data, cmp_data)

    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. @cmp_func is called with two items of the @seq, and @cmp_data. It should return 0 if the items are equal, a negative value if the first item comes before the second, and a positive value if the second item comes before the first. Note that when adding a large amount of data to a #GSequence, it is more efficient to do unsorted insertions and then call g_sequence_sort() or g_sequence_sort_iter().

    • @p data is the data to insert.
    • @p cmp_func is the function used to compare items in the sequence.
    • @p cmp_data is user data passed to @cmp_func..
    • @r a #GSequenceIter pointing to the new item..
  • insert_sorted_iter (data, cmp_data)

    Like g_sequence_insert_sorted(), but uses a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as the compare function. @iter_cmp is called with two iterators pointing into @seq. It should return 0 if the iterators are equal, a negative value if the first iterator comes before the second, and a positive value if the second iterator comes before the first. Note that when adding a large amount of data to a #GSequence, it is more efficient to do unsorted insertions and then call g_sequence_sort() or g_sequence_sort_iter().

    • @p data is data for the new item.
    • @p iter_cmp is the function used to compare iterators in the sequence.
    • @p cmp_data is user data passed to @iter_cmp.
    • @r a #GSequenceIter pointing to the new item.
  • is_empty ()

    Returns %TRUE if the sequence contains zero items. This function is functionally identical to checking the result of g_sequence_get_length() being equal to zero. However this function is implemented in O(1) running time.

    • @r %TRUE if the sequence is empty, otherwise %FALSE..
  • lookup (data, cmp_data)

    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. @cmp_func is called with two items of the @seq, and @cmp_data. It should return 0 if the items are equal, a negative value if the first item comes before the second, and a positive value if the second item comes before the first. This function will fail if the data contained in the sequence is unsorted.

    • @p data is data to look up.
    • @p cmp_func is the function used to compare items in the sequence.
    • @p cmp_data is user data passed to @cmp_func.
    • @r an #GSequenceIter pointing to the position of the first item found equal to @data according to @cmp_func and @cmp_data, or %NULL if no such item exists.
  • lookup_iter (data, cmp_data)

    Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as the compare function. @iter_cmp is called with two iterators pointing into @seq. It should return 0 if the iterators are equal, a negative value if the first iterator comes before the second, and a positive value if the second iterator comes before the first. This function will fail if the data contained in the sequence is unsorted.

    • @p data is data to look up.
    • @p iter_cmp is the function used to compare iterators in the sequence.
    • @p cmp_data is user data passed to @iter_cmp.
    • @r an #GSequenceIter pointing to the position of the first item found equal to @data according to @iter_cmp and @cmp_data, or %NULL if no such item exists.
  • prepend (data)

    Adds a new item to the front of @seq

    • @p data is the data for the new item.
    • @r an iterator pointing to the new item.
  • search (data, cmp_data)

    Returns an iterator pointing to the position where @data would be inserted according to @cmp_func and @cmp_data. @cmp_func is called with two items of the @seq, and @cmp_data. It should return 0 if the items are equal, a negative value if the first item comes before the second, and a positive value if the second item comes before the first. If you are simply searching for an existing element of the sequence, consider using g_sequence_lookup(). This function will fail if the data contained in the sequence is unsorted.

    • @p data is data for the new item.
    • @p cmp_func is the function used to compare items in the sequence.
    • @p cmp_data is user data passed to @cmp_func.
    • @r an #GSequenceIter pointing to the position where @data would have been inserted according to @cmp_func and @cmp_data.
  • search_iter (data, cmp_data)

    Like g_sequence_search(), but uses a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as the compare function. @iter_cmp is called with two iterators pointing into @seq. It should return 0 if the iterators are equal, a negative value if the first iterator comes before the second, and a positive value if the second iterator comes before the first. If you are simply searching for an existing element of the sequence, consider using g_sequence_lookup_iter(). This function will fail if the data contained in the sequence is unsorted.

    • @p data is data for the new item.
    • @p iter_cmp is the function used to compare iterators in the sequence.
    • @p cmp_data is user data passed to @iter_cmp.
    • @r a #GSequenceIter pointing to the position in @seq where @data would have been inserted according to @iter_cmp and @cmp_data.
  • sort (cmp_data)

    Sorts @seq using @cmp_func. @cmp_func is passed two items of @seq and should return 0 if they are equal, a negative value if the first comes before the second, and a positive value if the second comes before the first.

    • @p cmp_func is the function used to sort the sequence.
    • @p cmp_data is user data passed to @cmp_func.
    • @r None.
  • sort_iter (cmp_data)

    Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as the compare function @cmp_func is called with two iterators pointing into @seq. It should return 0 if the iterators are equal, a negative value if the first iterator comes before the second, and a positive value if the second iterator comes before the first.

    • @p cmp_func is the function used to compare iterators in the sequence.
    • @p cmp_data is user data passed to @cmp_func.
    • @r None.