ValueArray#
Deprecated since version 2.32:
- Use
GArrayinstead, if possible for the given use case, as described above.
- class ValueArray(*args, **kwargs)#
A GValueArray is a container structure to hold an array of generic values.
The prime purpose of a GValueArray is for it to be used as an
object property that holds an array of values. A GValueArray wraps
an array of GValue elements in order for it to be used as a boxed
type through G_TYPE_VALUE_ARRAY.
GValueArray is deprecated in favour of GArray since GLib 2.32.
It is possible to create a GArray that behaves like a GValueArray
by using the size of GValue as the element size, and by setting
unset as the clear function using
set_clear_func, for instance, the following code:
GValueArray *array = g_value_array_new (10);
can be replaced by:
GArray *array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 10);
g_array_set_clear_func (array, (GDestroyNotify) g_value_unset);
Constructors#
- class ValueArray
- classmethod new(n_prealloced: int) ValueArray#
Allocate and initialize a new
ValueArray, optionally preserve space forn_preallocedelements. New arrays always contain 0 elements, regardless of the value ofn_prealloced.Deprecated since version 2.32: Use
GArrayandsized_new()instead.- Parameters:
n_prealloced – number of values to preallocate space for
Methods#
- class ValueArray
- append(value: Value | None = None) ValueArray#
Insert a copy of
valueas last element ofvalue_array. IfvalueisNone, an uninitialized value is appended.Deprecated since version 2.32: Use
GArrayandarray_append_val()instead.- Parameters:
value –
Valueto copy intoValueArray, orNone
- get_nth(index_: int) Value#
Return a pointer to the value at
index_contained invalue_array.Deprecated since version 2.32: Use
array_index()instead.- Parameters:
index – index of the value of interest
- insert(index_: int, value: Value | None = None) ValueArray#
Insert a copy of
valueat specified position intovalue_array. IfvalueisNone, an uninitialized value is inserted.Deprecated since version 2.32: Use
GArrayandarray_insert_val()instead.- Parameters:
index – insertion position, must be <= value_array->;n_values
value –
Valueto copy intoValueArray, orNone
- prepend(value: Value | None = None) ValueArray#
Insert a copy of
valueas first element ofvalue_array. IfvalueisNone, an uninitialized value is prepended.Deprecated since version 2.32: Use
GArrayandarray_prepend_val()instead.- Parameters:
value –
Valueto copy intoValueArray, orNone
- remove(index_: int) ValueArray#
Remove the value at position
index_fromvalue_array.Deprecated since version 2.32: Use
GArrayandremove_index()instead.- Parameters:
index – position of value to remove, which must be less than
value_array->n_values
- sort(compare_func: Callable[[Any, Any, Any], int], user_data: Any = None) ValueArray#
Sort
value_arrayusingcompare_functo compare the elements according to the semantics ofCompareFunc.The current implementation uses the same sorting algorithm as standard C qsort() function.
Deprecated since version 2.32: Use
GArrayandsort().- Parameters:
compare_func – function to compare elements
user_data