Package ch.bailu.gtk.glib
Klasse Array
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.glib.Array
- Alle implementierten Schnittstellen:
PointerInterface
Contains the public fields of a GArray.
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic interface
static interface
static interface
-
Feldübersicht
Felder -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic Array
_new
(boolean zero_terminated, boolean clear_, int element_size) Creates a new #GArray with a reference count of 1.static Array
appendVals
(Array array, Pointer data, int len) Adds @len elements onto the end of the array.static Array
Create a shallow copy of a #GArray.static Str
Frees the memory allocated for the #GArray.static ClassHandler
static int
getElementSize
(Array array) Gets the size of the elements in @array.a pointer to the element data.int
the number of elements in the #GArray not including the
possible terminating zero element.static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
static Array
insertVals
(Array array, int index_, Pointer data, int len) Inserts @len elements into a #GArray at the given index.static Array
Creates a new #GArray with @data as array data, @len as length and a
reference count of 1.static Array
newTakeZeroTerminated
(Pointer data, boolean clear, long element_size) Creates a new #GArray with @data as array data, computing the length of it
and setting the reference count to 1.static Array
prependVals
(Array array, Pointer data, int len) Adds @len elements onto the start of the array.static Array
Atomically increments the reference count of @array by one.static Array
removeIndex
(Array array, int index_) Removes the element at the given index from a #GArray.static Array
removeIndexFast
(Array array, int index_) Removes the element at the given index from a #GArray.static Array
removeRange
(Array array, int index_, int length) Removes the given number of elements starting at the given index
from a #GArray.static void
setClearFunc
(Array array, Array.OnDestroyNotify clear_func) Sets a function to clear an element of @array.void
setFieldData
(Str data) a pointer to the element data.void
setFieldLen
(int len) the number of elements in the #GArray not including the
possible terminating zero element.static Array
Sets the size of the array, expanding it if necessary.static Array
sizedNew
(boolean zero_terminated, boolean clear_, int element_size, int reserved_size) Creates a new #GArray with @reserved_size elements preallocated and
a reference count of 1.static void
sort
(Array array, Array.OnCompareFunc compare_func) 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).static void
sortWithData
(Array array, Array.OnCompareDataFunc compare_func, Pointer user_data) Like g_array_sort(), but the comparison function receives an extra
user data argument.static Pointer
Frees the data in the array and resets the size to zero, while
the underlying array is preserved for use elsewhere and returned
to the caller.static void
Atomically decrements the reference count of @array by one.Von Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Von Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Von Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Von Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Felddetails
-
DATA
a pointer to the element data. The data may be moved as
elements are added to the #GArray.- Siehe auch:
-
LEN
the number of elements in the #GArray not including the
possible terminating zero element.- Siehe auch:
-
-
Konstruktordetails
-
Array
-
Array
public Array()
-
-
Methodendetails
-
getClassHandler
-
setFieldData
a pointer to the element data. The data may be moved as
elements are added to the #GArray. -
getFieldData
a pointer to the element data. The data may be moved as
elements are added to the #GArray. -
setFieldLen
public void setFieldLen(int len) the number of elements in the #GArray not including the
possible terminating zero element. -
getFieldLen
public int getFieldLen()the number of elements in the #GArray not including the
possible terminating zero element. -
appendVals
Adds @len elements onto the end of the array.- Parameter:
array
- a #GArraydata
- a pointer to the elements to append to the end of the arraylen
- the number of elements to append- Gibt zurück:
- the #GArray
-
copy
Create a shallow copy of a #GArray. If the array elements consist of
pointers to data, the pointers are copied but the actual data is not.- Parameter:
array
- A #GArray.- Gibt zurück:
- A copy of @array.
-
free
Frees the memory allocated for the #GArray. If @free_segment is
%TRUE it frees the memory block holding the elements as well. 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.
If array contents point to dynamically-allocated memory, they should
be freed separately if @free_segment is %TRUE and no @clear_func
function has been set for @array.
This function is not thread-safe. If using a #GArray from multiple
threads, use only the atomic g_array_ref() and g_array_unref()
functions.- Parameter:
array
- a #GArrayfree_segment
- if %TRUE the actual element data is freed as well- Gibt zurück:
- the element data if @free_segment is %FALSE, otherwise %NULL. The element data should be freed using g_free().
-
getElementSize
Gets the size of the elements in @array.- Parameter:
array
- A #GArray- Gibt zurück:
- Size of each element, in bytes
-
insertVals
Inserts @len elements into a #GArray at the given index.
If @index_ is greater than the array’s current length, the array is expanded.
The elements between the old end of the array and the newly inserted elements
will be initialised to zero if the array was configured to clear elements;
otherwise their values will be undefined.
If @index_ is less than the array’s current length, new entries will be
inserted into the array, and the existing entries above @index_ will be moved
upwards.
@data may be %NULL if (and only if) @len is zero. If @len is zero, this
function is a no-op.- Parameter:
array
- a #GArrayindex_
- the index to place the elements atdata
- a pointer to the elements to insertlen
- the number of elements to insert- Gibt zurück:
- the #GArray
-
_new
Creates a new #GArray with a reference count of 1.- Parameter:
zero_terminated
- %TRUE if the array should have an extra element at the end which is set to 0clear_
- %TRUE if #GArray elements should be automatically cleared to 0 when they are allocatedelement_size
- the size of each element in bytes- Gibt zurück:
- the new #GArray
-
newTake
Creates a new #GArray with @data as array data, @len as length and a
reference count of 1.
This avoids having to copy the data manually, when it can just be
inherited.
After this call, @data belongs to the #GArray and may no longer be
modified by the caller. The memory of @data has to be dynamically
allocated and will eventually be freed with g_free().
In case the elements need to be cleared when the array is freed, use
g_array_set_clear_func() to set a #GDestroyNotify function to perform
such task.
Do not use it if @len or @element_size are greater than %G_MAXUINT.
#GArray stores the length of its data in #guint, which may be shorter
than #gsize.- Parameter:
data
- an array of elements of @element_size, or %NULL for an empty arraylen
- the number of elements in @dataclear
- %TRUE if #GArray elements should be automatically cleared to 0 when they are allocatedelement_size
- the size of each element in bytes- Gibt zurück:
- A new #GArray
-
newTakeZeroTerminated
Creates a new #GArray with @data as array data, computing the length of it
and setting the reference count to 1.
This avoids having to copy the data manually, when it can just be
inherited.
After this call, @data belongs to the #GArray and may no longer be
modified by the caller. The memory of @data has to be dynamically
allocated and will eventually be freed with g_free().
The length is calculated by iterating through @data until the first %NULL
element is found.
In case the elements need to be cleared when the array is freed, use
g_array_set_clear_func() to set a #GDestroyNotify function to perform
such task.
Do not use it if @data length or @element_size are greater than %G_MAXUINT.
#GArray stores the length of its data in #guint, which may be shorter
than #gsize.- Parameter:
data
- an array of elements of @element_sizeclear
- %TRUE if #GArray elements should be automatically cleared to 0 when they are allocatedelement_size
- the size of each element in bytes- Gibt zurück:
- A new #GArray
-
prependVals
Adds @len elements onto the start of the array.
@data may be %NULL if (and only if) @len is zero. If @len is zero, this
function is a no-op.
This operation is slower than g_array_append_vals() since the
existing elements in the array have to be moved to make space for
the new elements.- Parameter:
array
- a #GArraydata
- a pointer to the elements to prepend to the start of the arraylen
- the number of elements to prepend, which may be zero- Gibt zurück:
- the #GArray
-
ref
Atomically increments the reference count of @array by one.
This function is thread-safe and may be called from any thread.- Parameter:
array
- A #GArray- Gibt zurück:
- The passed in #GArray
-
removeIndex
Removes the element at the given index from a #GArray. The following
elements are moved down one place.- Parameter:
array
- a #GArrayindex_
- the index of the element to remove- Gibt zurück:
- the #GArray
-
removeIndexFast
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().- Parameter:
array
- a @GArrayindex_
- the index of the element to remove- Gibt zurück:
- the #GArray
-
removeRange
Removes the given number of elements starting at the given index
from a #GArray. The following elements are moved to close the gap.- Parameter:
array
- a @GArrayindex_
- the index of the first element to removelength
- the number of elements to remove- Gibt zurück:
- the #GArray
-
setClearFunc
Sets a function to clear an element of @array.
The @clear_func will be called when an element in the array
data segment is removed and when the array is freed and data
segment is deallocated as well. @clear_func will be passed a
pointer to the element to clear, rather than the element itself.
Note that in contrast with other uses of #GDestroyNotify
functions, @clear_func is expected to clear the contents of
the array element it is given, but not free the element itself.
<!-- language="C" --> typedef struct { gchar *str; GObject *obj; } ArrayElement; static void array_element_clear (ArrayElement *element) { g_clear_pointer (&element->str, g_free); g_clear_object (&element->obj); } // main code GArray *garray = g_array_new (FALSE, FALSE, sizeof (ArrayElement)); g_array_set_clear_func (garray, (GDestroyNotify) array_element_clear); // assign data to the structure g_array_free (garray, TRUE);
- Parameter:
array
- A #GArrayclear_func
- a function to clear an element of @array
-
setSize
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.- Parameter:
array
- a #GArraylength
- the new size of the #GArray- Gibt zurück:
- the #GArray
-
sizedNew
public static Array sizedNew(boolean zero_terminated, boolean clear_, int element_size, int reserved_size) 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.- Parameter:
zero_terminated
- %TRUE if the array should have an extra element at the end with all bits clearedclear_
- %TRUE if all bits in the array should be cleared to 0 on allocationelement_size
- size of each element in the arrayreserved_size
- number of elements preallocated- Gibt zurück:
- the new #GArray
-
sort
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).
This is guaranteed to be a stable sort since version 2.32.- Parameter:
array
- a #GArraycompare_func
- comparison function
-
sortWithData
public static void sortWithData(@Nonnull Array array, Array.OnCompareDataFunc compare_func, @Nullable Pointer user_data) Like g_array_sort(), but the comparison function receives an extra
user data argument.
This is guaranteed to be a stable sort since version 2.32.
There used to be a comment here about making the sort stable by
using the addresses of the elements in the comparison function.
This did not actually work, so any such code should be removed.- Parameter:
array
- a #GArraycompare_func
- comparison functionuser_data
- data to pass to @compare_func
-
steal
Frees the data in the array and resets the size to zero, while
the underlying array is preserved for use elsewhere and returned
to the caller.
If the array was created with the @zero_terminate property
set to %TRUE, the returned data is zero terminated too.
If array elements contain dynamically-allocated memory,
the array elements should also be freed by the caller.
A short example of use:<!-- language="C" --> ... gpointer data; gsize data_len; data = g_array_steal (some_array, &data_len); ...
- Parameter:
array
- a #GArray.len
- pointer to retrieve the number of elements of the original array- Gibt zurück:
- the element data, which should be freed using g_free().
-
unref
Atomically decrements the reference count of @array by one. If the
reference count drops to 0, the effect is the same as calling
g_array_free() with @free_segment set to %TRUE. This function is
thread-safe and may be called from any thread.- Parameter:
array
- A #GArray
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-