ValueArray#
Deprecated since version 2.32: Use GArray
instead, 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_prealloced
elements. New arrays always contain 0 elements, regardless of the value ofn_prealloced
.Deprecated since version 2.32: Use
GArray
andsized_new()
instead.- Parameters:
n_prealloced – number of values to preallocate space for
Methods#
- class ValueArray
- append(value: Any | None = None) ValueArray #
Insert a copy of
value
as last element ofvalue_array
. Ifvalue
isNone
, an uninitialized value is appended.Deprecated since version 2.32: Use
GArray
andarray_append_val()
instead.- Parameters:
value –
Value
to copy intoValueArray
, orNone
- get_nth(index_: int) Any #
Return a pointer to the value at @``index_`` contained in
value_array
.Deprecated since version 2.32: Use
array_index()
instead.- Parameters:
index – index of the value of interest
- insert(index_: int, value: Any | None = None) ValueArray #
Insert a copy of
value
at specified position intovalue_array
. Ifvalue
isNone
, an uninitialized value is inserted.Deprecated since version 2.32: Use
GArray
andarray_insert_val()
instead.- Parameters:
index – insertion position, must be <= value_array->;n_values
value –
Value
to copy intoValueArray
, orNone
- prepend(value: Any | None = None) ValueArray #
Insert a copy of
value
as first element ofvalue_array
. Ifvalue
isNone
, an uninitialized value is prepended.Deprecated since version 2.32: Use
GArray
andarray_prepend_val()
instead.- Parameters:
value –
Value
to copy intoValueArray
, orNone
- remove(index_: int) ValueArray #
Remove the value at position @``index_`` from
value_array
.Deprecated since version 2.32: Use
GArray
andremove_index()
instead.- Parameters:
index – position of value to remove, which must be less than
value_array
->n_values
- sort(compare_func: Callable[[...], int], *user_data: Any) ValueArray #
Sort
value_array
usingcompare_func
to 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
GArray
andsort()
.- Parameters:
compare_func – function to compare elements
user_data