ArrayG

Contains the public fields of a GArray.

Constructors

this
this(GArray* gArray, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this(bool zeroTerminated, bool clear, uint elementSize)

Creates a new #GArray with a reference count of 1.

Members

Functions

appendVals
ArrayG appendVals(void* data, uint len)

Adds @len elements onto the end of the array.

doref
ArrayG doref()

Atomically increments the reference count of @array by one. This function is MT-safe and may be called from any thread.

free
string free(bool freeSegment)

Frees the memory allocated for the #GArray. If @free_segment is %TRUE it frees the memory block holding the elements as well and also each element if @array has a @element_free_func set. Pass %FALSE if you want to free the #GArray wrapper but preserve the underlying array for use elsewhere. If the reference count of @array is greater than one, the #GArray wrapper is preserved but the size of @array will be set to zero.

getArrayGStruct
GArray* getArrayGStruct()

Get the main Gtk struct

getElementSize
uint getElementSize()

Gets the size of the elements in @array.

getStruct
void* getStruct()

the main Gtk struct as a void*

insertVals
ArrayG insertVals(uint index, void* data, uint len)

Inserts @len elements into a #GArray at the given index.

prependVals
ArrayG prependVals(void* data, uint len)

Adds @len elements onto the start of the array.

removeIndex
ArrayG removeIndex(uint index)

Removes the element at the given index from a #GArray. The following elements are moved down one place.

removeIndexFast
ArrayG removeIndexFast(uint index)

Removes the element at the given index from a #GArray. The last element in the array is used to fill in the space, so this function does not preserve the order of the #GArray. But it is faster than g_array_remove_index().

removeRange
ArrayG removeRange(uint index, uint length)

Removes the given number of elements starting at the given index from a #GArray. The following elements are moved to close the gap.

setClearFunc
void setClearFunc(GDestroyNotify clearFunc)

Sets a function to clear an element of @array.

setSize
ArrayG setSize(uint length)

Sets the size of the array, expanding it if necessary. If the array was created with @clear_ set to %TRUE, the new elements are set to 0.

sort
void sort(GCompareFunc compareFunc)

Sorts a #GArray using @compare_func which should be a qsort()-style comparison function (returns less than zero for first arg is less than second arg, zero for equal, greater zero if first arg is greater than second arg).

sortWithData
void sortWithData(GCompareDataFunc compareFunc, void* userData)

Like g_array_sort(), but the comparison function receives an extra user data argument.

unref
void unref()

Atomically decrements the reference count of @array by one. If the reference count drops to 0, all memory allocated by the array is released. This function is MT-safe and may be called from any thread.

Static functions

sizedNew
ArrayG sizedNew(bool zeroTerminated, bool clear, uint elementSize, uint reservedSize)

Creates a new #GArray with @reserved_size elements preallocated and a reference count of 1. This avoids frequent reallocation, if you are going to add many elements to the array. Note however that the size of the array is still 0.

Variables

gArray
GArray* gArray;

the main Gtk struct

ownedRef
bool ownedRef;
Undocumented in source.

Meta