GLib.Sequence¶
Fields¶
None
Methods¶
class | get (iter) |
class | insert_before (iter, data) |
class | move (src, dest) |
class | move_range (dest, begin, end) |
class | range_get_midpoint (begin, end) |
class | remove (iter) |
class | remove_range (begin, end) |
class | set (iter, data) |
class | swap (a, b) |
append (data) |
|
free () |
|
get_begin_iter () |
|
get_end_iter () |
|
get_iter_at_pos (pos) |
|
get_length () |
|
is_empty () |
|
prepend (data) |
Details¶
-
class
GLib.
Sequence
¶ The
GLib.Sequence
struct is an opaque data type representing a sequence data type.-
classmethod
get
(iter)[source]¶ Parameters: iter ( GLib.SequenceIter
) – aGLib.SequenceIter
Returns: the data that iter points to Return type: object
orNone
Returns the data that iter points to.
New in version 2.14.
-
classmethod
insert_before
(iter, data)[source]¶ Parameters: - iter (
GLib.SequenceIter
) – aGLib.SequenceIter
- data (
object
orNone
) – the data for the new item
Returns: an iterator pointing to the new item
Return type: Inserts a new item just before the item pointed to by iter.
New in version 2.14.
- iter (
-
classmethod
move
(src, dest)[source]¶ Parameters: - src (
GLib.SequenceIter
) – aGLib.SequenceIter
pointing to the item to move - dest (
GLib.SequenceIter
) – aGLib.SequenceIter
pointing to the position to which the item is moved
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.
New in version 2.14.
- src (
-
classmethod
move_range
(dest, begin, end)[source]¶ Parameters: - dest (
GLib.SequenceIter
) – aGLib.SequenceIter
- begin (
GLib.SequenceIter
) – aGLib.SequenceIter
- end (
GLib.SequenceIter
) – aGLib.SequenceIter
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.
If dest is
None
, the range indicated by begin and end is removed from the sequence. If dest points to a place within the (begin, end) range, the range does not move.New in version 2.14.
- dest (
-
classmethod
range_get_midpoint
(begin, end)[source]¶ Parameters: - begin (
GLib.SequenceIter
) – aGLib.SequenceIter
- end (
GLib.SequenceIter
) – aGLib.SequenceIter
Returns: a
GLib.SequenceIter
pointing somewhere in the (begin, end) rangeReturn type: 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.
New in version 2.14.
- begin (
-
classmethod
remove
(iter)[source]¶ Parameters: iter ( GLib.SequenceIter
) – aGLib.SequenceIter
Removes the item pointed to by iter. 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.
New in version 2.14.
-
classmethod
remove_range
(begin, end)[source]¶ Parameters: - begin (
GLib.SequenceIter
) – aGLib.SequenceIter
- end (
GLib.SequenceIter
) – aGLib.SequenceIter
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.
New in version 2.14.
- begin (
-
classmethod
set
(iter, data)[source]¶ Parameters: - iter (
GLib.SequenceIter
) – aGLib.SequenceIter
- data (
object
orNone
) – new data for the item
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.
New in version 2.14.
- iter (
-
classmethod
swap
(a, b)[source]¶ Parameters: - a (
GLib.SequenceIter
) – aGLib.SequenceIter
- b (
GLib.SequenceIter
) – aGLib.SequenceIter
Swaps the items pointed to by a and b. It is allowed for a and b to point into difference sequences.
New in version 2.14.
- a (
-
append
(data)[source]¶ Parameters: data ( object
orNone
) – the data for the new itemReturns: an iterator pointing to the new item Return type: GLib.SequenceIter
Adds a new item to the end of self.
New in version 2.14.
-
free
()[source]¶ Frees the memory allocated for self. If self has a data destroy function associated with it, that function is called on all items in self.
New in version 2.14.
-
get_begin_iter
()[source]¶ Returns: the begin iterator for self. Return type: GLib.SequenceIter
Returns the begin iterator for self.
New in version 2.14.
-
get_end_iter
()[source]¶ Returns: the end iterator for self Return type: GLib.SequenceIter
Returns the end iterator for seg
New in version 2.14.
-
get_iter_at_pos
(pos)[source]¶ Parameters: pos ( int
) – a position in self, or -1 for the endReturns: The GLib.SequenceIter
at position posReturn type: GLib.SequenceIter
Returns the iterator at position pos. If pos is negative or larger than the number of items in self, the end iterator is returned.
New in version 2.14.
-
get_length
()[source]¶ Returns: the length of self Return type: int
Returns the length of self. Note that this method is O(h) where `h’ is the height of the tree. It is thus more efficient to use
GLib.Sequence.is_empty
() when comparing the length to zero.New in version 2.14.
-
is_empty
()[source]¶ Returns: True
if the sequence is empty, otherwiseFalse
.Return type: bool
Returns
True
if the sequence contains zero items.This function is functionally identical to checking the result of
GLib.Sequence.get_length
() being equal to zero. However this function is implemented in O(1) running time.New in version 2.48.
-
prepend
(data)[source]¶ Parameters: data ( object
orNone
) – the data for the new itemReturns: an iterator pointing to the new item Return type: GLib.SequenceIter
Adds a new item to the front of self
New in version 2.14.
-
classmethod