Class Sequence
-
Constructor Summary
ConstructorsConstructorDescriptionSequence(MemorySegment address) Create a Sequence proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionappend(@Nullable MemorySegment data) Adds a new item to the end ofseq.voidCallsfuncfor each item in the sequence passinguserDatato the function.static voidforeachRange(SequenceIter begin, SequenceIter end, @Nullable Func func) Callsfuncfor each item in the range (begin,end)passinguserDatato the function.voidfree()Frees the memory allocated forseq.If this Sequence has a data destroy function associated with it, that function is called on all items inseq.static @Nullable MemorySegmentget(SequenceIter iter) Returns the data thatiterpoints to.Returns the begin iterator forseq.Returns the end iterator forseggetIterAtPos(int pos) Returns the iterator at positionpos.Ifposis negative or larger than the number of items inseq,the end iterator is returned.intReturns the positive length (>= 0) ofseq.Note that this method is O(h) where `h' is the height of the tree.static SequenceIterinsertBefore(SequenceIter iter, @Nullable MemorySegment data) Inserts a new item just before the item pointed to byiter.insertSorted(@Nullable MemorySegment data, @Nullable CompareDataFunc cmpFunc) Insertsdatainto this Sequence usingcmpFuncto determine the new position.insertSortedIter(@Nullable MemorySegment data, @Nullable SequenceIterCompareFunc iterCmp) Like g_sequence_insert_sorted(), but uses aGSequenceIterCompareFuncinstead of aGCompareDataFuncas the compare function.booleanisEmpty()Returnstrueif the sequence contains zero items.@Nullable SequenceIterlookup(@Nullable MemorySegment data, @Nullable CompareDataFunc cmpFunc) Returns an iterator pointing to the position of the first item found equal todataaccording tocmpFuncandcmpData.If more than one item is equal, it is not guaranteed that it is the first which is returned.@Nullable SequenceIterlookupIter(@Nullable MemorySegment data, @Nullable SequenceIterCompareFunc iterCmp) Like g_sequence_lookup(), but uses aGSequenceIterCompareFuncinstead of aGCompareDataFuncas the compare function.static voidmove(SequenceIter src, SequenceIter dest) Moves the item pointed to bysrcto the position indicated bydest.After calling this functiondestwill point to the position immediately aftersrc.It is allowed forsrcanddestto point into different sequences.static voidmoveRange(SequenceIter dest, SequenceIter begin, SequenceIter end) Inserts the (begin,end)range at the destination pointed to bydest.Thebeginandenditers must point into the same sequence.static Sequencenew_()Creates a new GSequence.prepend(@Nullable MemorySegment data) Adds a new item to the front of this Sequencestatic SequenceIterrangeGetMidpoint(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.static voidremove(SequenceIter iter) Removes the item pointed to byiter.It is an error to pass the end iterator to this function.static voidremoveRange(SequenceIter begin, SequenceIter end) Removes all items in the (begin,end)range.search(@Nullable MemorySegment data, @Nullable CompareDataFunc cmpFunc) Returns an iterator pointing to the position wheredatawould be inserted according tocmpFuncandcmpData.searchIter(@Nullable MemorySegment data, @Nullable SequenceIterCompareFunc iterCmp) Like g_sequence_search(), but uses aGSequenceIterCompareFuncinstead of aGCompareDataFuncas the compare function.static voidset(SequenceIter iter, @Nullable MemorySegment data) Changes the data for the item pointed to byiterto bedata.If the sequence has a data destroy function associated with it, that function is called on the existing data thatiterpointed to.voidsort(@Nullable CompareDataFunc cmpFunc) Sorts this Sequence usingcmpFunc.static voidsortChanged(SequenceIter iter, @Nullable CompareDataFunc cmpFunc) Moves the data pointed to byiterto a new position as indicated bycmpFunc.This function should be called for items in a sequence already sorted according tocmpFuncwhenever some aspect of an item changes so thatcmpFuncmay return different values for that item.static voidsortChangedIter(SequenceIter iter, @Nullable SequenceIterCompareFunc iterCmp) Like g_sequence_sort_changed(), but uses aGSequenceIterCompareFuncinstead of aGCompareDataFuncas the compare function.voidsortIter(@Nullable SequenceIterCompareFunc cmpFunc) Like g_sequence_sort(), but uses aGSequenceIterCompareFuncinstead of aGCompareDataFuncas the compare functionstatic voidswap(SequenceIter a, SequenceIter b) Swaps the items pointed to byaandb.It is allowed foraandbto point into difference sequences.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Sequence
Create a Sequence proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
-
Method Details
-
foreachRange
Callsfuncfor each item in the range (begin,end)passinguserDatato the function.funcmust not modify the sequence itself.- Parameters:
begin- aGSequenceIterend- aGSequenceIterfunc- aGFunc- Since:
- 2.14
-
get
Returns the data thatiterpoints to.- Parameters:
iter- aGSequenceIter- Returns:
- the data that
iterpoints to - Since:
- 2.14
-
insertBefore
Inserts a new item just before the item pointed to byiter.- Parameters:
iter- aGSequenceIterdata- the data for the new item- Returns:
- an iterator pointing to the new item
- Since:
- 2.14
-
move
Moves the item pointed to bysrcto the position indicated bydest.After calling this functiondestwill point to the position immediately aftersrc.It is allowed forsrcanddestto point into different sequences.- Parameters:
src- aGSequenceIterpointing to the item to movedest- aGSequenceIterpointing to the position to which the item is moved- Since:
- 2.14
-
moveRange
Inserts the (begin,end)range at the destination pointed to bydest.Thebeginandenditers must point into the same sequence. It is allowed fordestto point to a different sequence than the one pointed into bybeginandend.If
destisnull, the range indicated bybeginandendis removed from the sequence. Ifdestpoints to a place within the (begin,end)range, the range does not move.- Parameters:
dest- aGSequenceIterbegin- aGSequenceIterend- aGSequenceIter- Since:
- 2.14
-
new_
Creates a new GSequence. ThedataDestroyfunction, if non-nullwill be called on all items when the sequence is destroyed and on items that are removed from the sequence.- Returns:
- a new
GSequence - Since:
- 2.14
-
rangeGetMidpoint
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
beginandenditerators must both point to the same sequence andbeginmust come before or be equal toendin the sequence.- Parameters:
begin- aGSequenceIterend- aGSequenceIter- Returns:
- a
GSequenceIterpointing somewhere in the (begin,end)range - Since:
- 2.14
-
remove
Removes the item pointed to byiter.It is an error to pass the end iterator to this function.If the sequence has a data destroy function associated with it, this function is called on the data for the removed item.
- Parameters:
iter- aGSequenceIter- Since:
- 2.14
-
removeRange
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.
- Parameters:
begin- aGSequenceIterend- aGSequenceIter- Since:
- 2.14
-
set
Changes the data for the item pointed to byiterto bedata.If the sequence has a data destroy function associated with it, that function is called on the existing data thatiterpointed to.- Parameters:
iter- aGSequenceIterdata- new data for the item- Since:
- 2.14
-
sortChanged
Moves the data pointed to byiterto a new position as indicated bycmpFunc.This function should be called for items in a sequence already sorted according tocmpFuncwhenever some aspect of an item changes so thatcmpFuncmay return different values for that item.cmpFuncis called with two items of theseq,andcmpData.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.- Parameters:
iter- AGSequenceItercmpFunc- the function used to compare items in the sequence- Since:
- 2.14
-
sortChangedIter
Like g_sequence_sort_changed(), but uses aGSequenceIterCompareFuncinstead of aGCompareDataFuncas the compare function.iterCmpis called with two iterators pointing into theGSequencethatiterpoints into. 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.- Parameters:
iter- aGSequenceIteriterCmp- the function used to compare iterators in the sequence- Since:
- 2.14
-
swap
Swaps the items pointed to byaandb.It is allowed foraandbto point into difference sequences.- Parameters:
a- aGSequenceIterb- aGSequenceIter- Since:
- 2.14
-
append
Adds a new item to the end ofseq.- Parameters:
data- the data for the new item- Returns:
- an iterator pointing to the new item
- Since:
- 2.14
-
foreach
Callsfuncfor each item in the sequence passinguserDatato the function.funcmust not modify the sequence itself.- Parameters:
func- the function to call for each item in this Sequence- Since:
- 2.14
-
free
public void free()Frees the memory allocated forseq.If this Sequence has a data destroy function associated with it, that function is called on all items inseq.- Since:
- 2.14
-
getBeginIter
Returns the begin iterator forseq.- Returns:
- the begin iterator for
seq. - Since:
- 2.14
-
getEndIter
Returns the end iterator forseg- Returns:
- the end iterator for this Sequence
- Since:
- 2.14
-
getIterAtPos
Returns the iterator at positionpos.Ifposis negative or larger than the number of items inseq,the end iterator is returned.- Parameters:
pos- a position inseq,or -1 for the end- Returns:
- The
GSequenceIterat positionpos - Since:
- 2.14
-
getLength
public int getLength()Returns the positive length (>= 0) ofseq.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.- Returns:
- the length of this Sequence
- Since:
- 2.14
-
insertSorted
Insertsdatainto this Sequence usingcmpFuncto determine the new position. The sequence must already be sorted according tocmpFunc;otherwise the new position ofdatais undefined.cmpFuncis called with two items of theseq,andcmpData.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().- Parameters:
data- the data to insertcmpFunc- the function used to compare items in the sequence- Returns:
- a
GSequenceIterpointing to the new item. - Since:
- 2.14
-
insertSortedIter
public SequenceIter insertSortedIter(@Nullable MemorySegment data, @Nullable SequenceIterCompareFunc iterCmp) Like g_sequence_insert_sorted(), but uses aGSequenceIterCompareFuncinstead of aGCompareDataFuncas the compare function.iterCmpis called with two iterators pointing intoseq.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().- Parameters:
data- data for the new itemiterCmp- the function used to compare iterators in the sequence- Returns:
- a
GSequenceIterpointing to the new item - Since:
- 2.14
-
isEmpty
public boolean isEmpty()Returnstrueif 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.
- Returns:
trueif the sequence is empty, otherwisefalse.- Since:
- 2.48
-
lookup
public @Nullable SequenceIter lookup(@Nullable MemorySegment data, @Nullable CompareDataFunc cmpFunc) Returns an iterator pointing to the position of the first item found equal todataaccording tocmpFuncandcmpData.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.cmpFuncis called with two items of theseq,andcmpData.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.
- Parameters:
data- data to look upcmpFunc- the function used to compare items in the sequence- Returns:
- an
GSequenceIterpointing to the position of the first item found equal todataaccording tocmpFuncandcmpData,ornullif no such item exists - Since:
- 2.28
-
lookupIter
public @Nullable SequenceIter lookupIter(@Nullable MemorySegment data, @Nullable SequenceIterCompareFunc iterCmp) Like g_sequence_lookup(), but uses aGSequenceIterCompareFuncinstead of aGCompareDataFuncas the compare function.iterCmpis called with two iterators pointing intoseq.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.
- Parameters:
data- data to look upiterCmp- the function used to compare iterators in the sequence- Returns:
- an
GSequenceIterpointing to the position of the first item found equal todataaccording toiterCmpandcmpData,ornullif no such item exists - Since:
- 2.28
-
prepend
Adds a new item to the front of this Sequence- Parameters:
data- the data for the new item- Returns:
- an iterator pointing to the new item
- Since:
- 2.14
-
search
Returns an iterator pointing to the position wheredatawould be inserted according tocmpFuncandcmpData.cmpFuncis called with two items of theseq,andcmpData.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.
- Parameters:
data- data for the new itemcmpFunc- the function used to compare items in the sequence- Returns:
- an
GSequenceIterpointing to the position wheredatawould have been inserted according tocmpFuncandcmpData - Since:
- 2.14
-
searchIter
public SequenceIter searchIter(@Nullable MemorySegment data, @Nullable SequenceIterCompareFunc iterCmp) Like g_sequence_search(), but uses aGSequenceIterCompareFuncinstead of aGCompareDataFuncas the compare function.iterCmpis called with two iterators pointing intoseq.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.
- Parameters:
data- data for the new itemiterCmp- the function used to compare iterators in the sequence- Returns:
- a
GSequenceIterpointing to the position in this Sequence wheredatawould have been inserted according toiterCmpandcmpData - Since:
- 2.14
-
sort
Sorts this Sequence usingcmpFunc.cmpFuncis passed two items of this Sequence 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.- Parameters:
cmpFunc- the function used to sort the sequence- Since:
- 2.14
-
sortIter
Like g_sequence_sort(), but uses aGSequenceIterCompareFuncinstead of aGCompareDataFuncas the compare functioncmpFuncis called with two iterators pointing intoseq.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.- Parameters:
cmpFunc- the function used to compare iterators in the sequence- Since:
- 2.14
-