GObject.ValueArray¶
Fields¶
Name |
Type |
Access |
Description |
|---|---|---|---|
n_prealloced |
r |
||
n_values |
r/w |
number of values contained in the array |
|
values |
r/w |
array of values |
Methods¶
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class GObject.ValueArray¶
A
GValueArrayis a container structure to hold an array of generic values.The prime purpose of a
GValueArrayis for it to be used as an object property that holds an array of values. AGValueArraywraps an array ofGValueelements in order for it to be used as a boxed type throughG_TYPE_VALUE_ARRAY.GValueArrayis deprecated in favour ofGArraysince GLib 2.32. It is possible to create aGArraythat behaves like aGValueArrayby using the size ofGValueas the element size, and by setting [method`GObject`.Value.unset] as the clear function using [func`GLib`.Array.set_clear_func], for instance, the following code:can be replaced by:
- ``c
GArray *array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 10); g_array_set_clear_func (array, (GDestroyNotify) g_value_unset);
Deprecated since version 2.32: Use
GArrayinstead, if possible for the given use case, as described above.- classmethod new(n_prealloced)[source]¶
- Parameters:
n_prealloced (
int) – number of values to preallocate space for- Returns:
a newly allocated
GObject.ValueArraywith 0 values- Return type:
Allocate and initialize a new
GObject.ValueArray, optionally preserve space for n_prealloced elements. New arrays always contain 0 elements, regardless of the value of n_prealloced.Deprecated since version 2.32: Use
GLib.Arrayand g_array_sized_new() instead.
- append(value)[source]¶
- Parameters:
value (
GObject.ValueorNone) –GObject.Valueto copy intoGObject.ValueArray, orNone- Returns:
the
GObject.ValueArraypassed in as self- Return type:
Insert a copy of value as last element of self. If value is
None, an uninitialized value is appended.Deprecated since version 2.32: Use
GLib.Arrayand g_array_append_val() instead.
- copy()[source]¶
- Returns:
Newly allocated copy of
GObject.ValueArray- Return type:
Construct an exact copy of a
GObject.ValueArrayby duplicating all its contents.Deprecated since version 2.32: Use
GLib.Arrayand g_array_ref() instead.
- get_nth(index_)[source]¶
- Parameters:
index (
int) – index of the value of interest- Returns:
pointer to a value at index_ in self
- Return type:
Return a pointer to the value at index_ contained in self.
Deprecated since version 2.32: Use g_array_index() instead.
- insert(index_, value)[source]¶
- Parameters:
index (
int) – insertion position, must be <= value_array->;n_valuesvalue (
GObject.ValueorNone) –GObject.Valueto copy intoGObject.ValueArray, orNone
- Returns:
the
GObject.ValueArraypassed in as self- Return type:
Insert a copy of value at specified position into self. If value is
None, an uninitialized value is inserted.Deprecated since version 2.32: Use
GLib.Arrayand g_array_insert_val() instead.
- prepend(value)[source]¶
- Parameters:
value (
GObject.ValueorNone) –GObject.Valueto copy intoGObject.ValueArray, orNone- Returns:
the
GObject.ValueArraypassed in as self- Return type:
Insert a copy of value as first element of self. If value is
None, an uninitialized value is prepended.Deprecated since version 2.32: Use
GLib.Arrayand g_array_prepend_val() instead.
- remove(index_)[source]¶
- Parameters:
index (
int) – position of value to remove, which must be less than self->n_values- Returns:
the
GObject.ValueArraypassed in as self- Return type:
Remove the value at position index_ from self.
Deprecated since version 2.32: Use
GLib.Arrayand g_array_remove_index() instead.
- sort(compare_func, *user_data)[source]¶
- Parameters:
compare_func (
GLib.CompareDataFunc) – function to compare elementsuser_data (
objectorNone) – extra data argument provided for compare_func
- Returns:
the
GObject.ValueArraypassed in as self- Return type:
Sort self using compare_func to compare the elements according to the semantics of
GLib.CompareDataFunc.The current implementation uses the same sorting algorithm as standard C qsort() function.
Deprecated since version 2.32: Use
GLib.Arrayand g_array_sort_with_data().