Libraries:Gtk:Glib:GArray
Types
T
Constants
Nil : T
Functions
New(zero_terminated @ Std.Symbol.T, clear_ @ Std.Symbol.T, element_size @ Std.Integer.SmallT) : Gtk.Glib.GArray.T
Creates a new T with a reference count of 1.
zero_terminated | TRUE if the array should have an extra element at the end which is set to 0. |
clear_ | TRUE if T elements should be automatically cleared to 0 when they are allocated. |
element_size | the size of each element in bytes. |
Returns | the new T. |
SizedNew(zero_terminated @ Std.Symbol.T, clear_ @ Std.Symbol.T, element_size @ Std.Integer.SmallT, reserved_size @ Std.Integer.SmallT) : Gtk.Glib.GArray.T
Creates a new T 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.
zero_terminated | TRUE if the array should have an extra element at the end with all bits cleared. |
clear_ | TRUE if all bits in the array should be cleared to 0 on allocation. |
element_size | size of each element in the array. |
reserved_size | number of elements preallocated. |
Returns | the new T. |
Methods
:"="(_ @ T, _ @ T)
:AppendVals(self @ T, data @ Std.Address.T, len @ Std.Integer.SmallT) : Gtk.Glib.GArray.T
Adds len elements onto the end of the array.
array | a T. |
data | a pointer to the elements to append to the end of the array. |
len | the number of elements to append. |
Returns | the T. |
:Data(self @ T) : Std.String.T
:Free(self @ T, free_segment @ Std.Symbol.T) : Std.String.T
Frees the memory allocated for the T. 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 T wrapper but preserve the underlying array for use elsewhere. If the reference count of array is greater than one, the T wrapper is preserved but the size of array will be set to zero.
Note
If array elements contain dynamically-allocated memory, they should be freed separately.
:GetElementSize(self @ T) : Std.Integer.SmallT
:InsertVals(self @ T, index_ @ Std.Integer.SmallT, data @ Std.Address.T, len @ Std.Integer.SmallT) : Gtk.Glib.GArray.T
Inserts len elements into a T at the given index.
array | a T. |
index_ | the index to place the elements at. |
data | a pointer to the elements to insert. |
len | the number of elements to insert. |
Returns | the T. |
:Len(self @ T) : Std.Integer.SmallT
:PrependVals(self @ T, data @ Std.Address.T, len @ Std.Integer.SmallT) : Gtk.Glib.GArray.T
Adds len elements onto the start of the array.
This operation is slower than AppendVals since the existing elements in the array have to be moved to make space for the new elements.
array | a T. |
data | a pointer to the elements to prepend to the start of the array. |
len | the number of elements to prepend. |
Returns | the T. |
:Ref(self @ T) : Gtk.Glib.GArray.T
Atomically increments the reference count of array by one. This function is MT-safe and may be called from any thread.
:RemoveIndex(self @ T, index_ @ Std.Integer.SmallT) : Gtk.Glib.GArray.T
Removes the element at the given index from a T. The following elements are moved down one place.
:RemoveIndexFast(self @ T, index_ @ Std.Integer.SmallT) : Gtk.Glib.GArray.T
Removes the element at the given index from a T. The last element in the array is used to fill in the space, so this function does not preserve the order of the T. But it is faster than RemoveIndex.
array | a GArray. |
index_ | the index of the element to remove. |
Returns | the T. |
:RemoveRange(self @ T, index_ @ Std.Integer.SmallT, length @ Std.Integer.SmallT) : Gtk.Glib.GArray.T
Removes the given number of elements starting at the given index from a T. The following elements are moved to close the gap.
array | a GArray. |
index_ | the index of the first element to remove. |
length | the number of elements to remove. |
Returns | the T. |
:SetSize(self @ T, length @ Std.Integer.SmallT) : Gtk.Glib.GArray.T
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(self @ T, compare_func @ Std.Function.T) : Std.Object.T
Sorts a T 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).
If two array elements compare equal, their order in the sorted array is undefined. If you want equal elements to keep their order &8211; i.e. you want a stable sort &8211; you can write a comparison function that, if two elements would otherwise compare equal, compares them by their addresses.
array | a T. |
compare_func | comparison function. |
:SortWithData(self @ T, compare_func @ Std.Function.T, user_data) : Std.Object.T
Like Sort, but the comparison function receives an extra user data argument.
array | a T. |
compare_func | comparison function. |
user_data | data to pass to compare_func. |
:Unref(self @ T) : Std.Object.T
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.
array | A T. |