GObject.ValueArray

Fields

Name

Type

Access

Description

n_prealloced

int

r

n_values

int

r/w

number of values contained in the array

values

GObject.Value

r/w

array of values

Methods

class

new (n_prealloced)

append (value)

copy ()

get_nth (index_)

insert (index_, value)

prepend (value)

remove (index_)

sort (compare_func, *user_data)

Details

class GObject.ValueArray

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 [method`GObject`.Value.unset] as the clear function using [func`GLib`.Array.set_clear_func], for instance, the following code:

``c

GValueArray *array = g_value_array_new (10);

``

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 GArray instead, 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.ValueArray with 0 values

Return type:

GObject.ValueArray

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.Array and g_array_sized_new() instead.

append(value)[source]
Parameters:

value (GObject.Value or None) – GObject.Value to copy into GObject.ValueArray, or None

Returns:

the GObject.ValueArray passed in as self

Return type:

GObject.ValueArray

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.Array and g_array_append_val() instead.

copy()[source]
Returns:

Newly allocated copy of GObject.ValueArray

Return type:

GObject.ValueArray

Construct an exact copy of a GObject.ValueArray by duplicating all its contents.

Deprecated since version 2.32: Use GLib.Array and 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:

GObject.Value

Return a pointer to the value at index_ containd in self.

Deprecated since version 2.32: Use g_array_index() instead.

insert(index_, value)[source]
Parameters:
Returns:

the GObject.ValueArray passed in as self

Return type:

GObject.ValueArray

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.Array and g_array_insert_val() instead.

prepend(value)[source]
Parameters:

value (GObject.Value or None) – GObject.Value to copy into GObject.ValueArray, or None

Returns:

the GObject.ValueArray passed in as self

Return type:

GObject.ValueArray

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.Array and 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.ValueArray passed in as self

Return type:

GObject.ValueArray

Remove the value at position index_ from self.

Deprecated since version 2.32: Use GLib.Array and g_array_remove_index() instead.

sort(compare_func, *user_data)[source]
Parameters:
Returns:

the GObject.ValueArray passed in as self

Return type:

GObject.ValueArray

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.Array and g_array_sort_with_data().