Method

GLibSequencelookup

Declaration

GSequenceIter*
g_sequence_lookup (
  GSequence* seq,
  gpointer data,
  GCompareDataFunc cmp_func,
  gpointer cmp_data
)

Description

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.

Available since:2.28
This method is not directly available to language bindings.

Parameters

data gpointer
 

Data to look up.

 The argument can be NULL.
 The data is owned by the caller of the function.
cmp_func GCompareDataFunc
 

The function used to compare items in the sequence.

cmp_data gpointer
 

User data passed to cmp_func.

 The argument can be NULL.
 The data is owned by the caller of the function.

Return value

Returns: GSequenceIter
 

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.

 The data is owned by the instance.
 The return value can be NULL.