W Wrapl, The Programming Language

Libraries:Gtk:Glib:GPtrArray

Types

T

Constants

Nil : T

Functions

New() : Gtk.Glib.GPtrArray.T

Creates a new T with a reference count of 1.

Returns the new T.


NewWithFreeFunc(element_free_func @ Std.Function.T) : Gtk.Glib.GPtrArray.T

Creates a new T with a reference count of 1 and use element_free_func for freeing each element when the array is destroyed either via Unref, when Free is called with free_segment set to TRUE or when removing elements.

element_free_func A function to free elements with destroy array or NULL.
Returns A new T.


SizedNew(reserved_size @ Std.Integer.SmallT) : Gtk.Glib.GPtrArray.T

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

reserved_size number of pointers preallocated.
Returns the new T.


Methods

:"="(_ @ T, _ @ T)

:Add(self @ T, data @ Std.Address.T) : Std.Object.T

Adds a pointer to the end of the pointer array. The array will grow in size automatically if necessary.

array a T.
data the pointer to add.


:Foreach(self @ T, func @ Std.Function.T, user_data) : Std.Object.T

Calls a function for each element of a T.

array a T
func the function to call for each array element
user_data user data to pass to the function


:Free(self @ T, free_seg @ Std.Symbol.T) : Std.Object.T

Frees the memory allocated for the T. If free_seg is TRUE it frees the memory block holding the elements as well. 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 contents point to dynamically-allocated memory, they should be freed separately if free_seg is TRUE and no Gtk.Glib.GDestroyNotify function has been set for array.



:Len(self @ T) : Std.Integer.SmallT

:Pdata(self @ T) : Std.Object.T

:Ref(self @ T) : Gtk.Glib.GPtrArray.T

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

array A Gtk.Glib.GArray.T.
Returns The passed in T.


:Remove(self @ T, data @ Std.Address.T) : Std.Symbol.T

Removes the first occurrence of the given pointer from the pointer array. The following elements are moved down one place. If array has a non-NULL Gtk.Glib.GDestroyNotify function it is called for the removed element.

It returns TRUE if the pointer was removed, or FALSE if the pointer was not found.

array a T.
data the pointer to remove.
Returns TRUE if the pointer is removed. FALSE if the pointer is not found in the array.


:RemoveFast(self @ T, data @ Std.Address.T) : Std.Symbol.T

Removes the first occurrence of the given pointer from the pointer array. The last element in the array is used to fill in the space, so this function does not preserve the order of the array. But it is faster than Remove. If array has a non-NULL Gtk.Glib.GDestroyNotify function it is called for the removed element.

It returns TRUE if the pointer was removed, or FALSE if the pointer was not found.

array a T.
data the pointer to remove.
Returns TRUE if the pointer was found in the array.


:RemoveIndex(self @ T, index_ @ Std.Integer.SmallT) : Std.Address.T

Removes the pointer at the given index from the pointer array. The following elements are moved down one place. If array has a non-NULL Gtk.Glib.GDestroyNotify function it is called for the removed element.

array a T.
index_ the index of the pointer to remove.
Returns the pointer which was removed.


:RemoveIndexFast(self @ T, index_ @ Std.Integer.SmallT) : Std.Address.T

Removes the pointer at the given index from the pointer array. The last element in the array is used to fill in the space, so this function does not preserve the order of the array. But it is faster than RemoveIndex. If array has a non-NULL Gtk.Glib.GDestroyNotify function it is called for the removed element.

array a T.
index_ the index of the pointer to remove.
Returns the pointer which was removed.


:RemoveRange(self @ T, index_ @ Std.Integer.SmallT, length @ Std.Integer.SmallT) : Std.Object.T

Removes the given number of pointers starting at the given index from a T. The following elements are moved to close the gap. If array has a non-NULL Gtk.Glib.GDestroyNotify function it is called for the removed elements.

array a GPtrArray.
index_ the index of the first pointer to remove.
length the number of pointers to remove.


:SetFreeFunc(self @ T, element_free_func @ Std.Function.T) : Std.Object.T

Sets a function for freeing each element when array is destroyed either via Unref, when Free is called with free_segment set to TRUE or when removing elements.

array A T.
element_free_func A function to free elements with destroy array or NULL.


:SetSize(self @ T, length @ Std.Integer.SmallT) : Std.Object.T

Sets the size of the array. When making the array larger, newly-added elements will be set to NULL. When making it smaller, if array has a non-NULL Gtk.Glib.GDestroyNotify function then it will be called for the removed elements.

array a T.
length the new length of the pointer array.


:Sort(self @ T, compare_func @ Std.Function.T) : Std.Object.T

Sorts the array, 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 than zero if irst 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.

Note

The comparison function for Sort doesn't take the pointers from the array as arguments, it takes pointers to the pointers in the array.



:SortWithData(self @ T, compare_func @ Std.Function.T, user_data) : Std.Object.T

Like Sort, but the comparison function has an extra user data argument.

Note

The comparison function for SortWithData doesn't take the pointers from the array as arguments, it takes pointers to the pointers in the array.



:Unref(self @ T) : Std.Object.T

Atomically decrements the reference count of array by one. If the reference count drops to 0, the effect is the same as calling Free with free_segment set to TRUE. This function is MT-safe and may be called from any thread.

array A T.


:setLen(self @ T, value @ Std.Integer.SmallT) : Std.Integer.SmallT

:setPdata(self @ T, value @ Std.Object.T) : Std.Object.T

:"~="(_ @ T, _ @ T)