Package ch.bailu.gtk.glib
Class ByteArray
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.glib.ByteArray
- All Implemented Interfaces:
PointerInterface
Contains the public fields of a GByteArray.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ByteArray
_new()
Creates a new #GByteArray with a reference count of 1.static Bytes
freeToBytes
(ByteArray array) Transfers the data from the #GByteArray into a new immutable #GBytes.static ClassHandler
static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
static ByteArray
Atomically increments the reference count of @array by one.static ByteArray
removeIndex
(ByteArray array, int index_) Removes the byte at the given index from a #GByteArray.static ByteArray
removeIndexFast
(ByteArray array, int index_) Removes the byte at the given index from a #GByteArray.static ByteArray
removeRange
(ByteArray array, int index_, int length) Removes the given number of bytes starting at the given index from a
#GByteArray.static ByteArray
Sets the size of the #GByteArray, expanding it if necessary.static ByteArray
sizedNew
(int reserved_size) Creates a new #GByteArray with @reserved_size bytes preallocated.static void
sort
(ByteArray array, ByteArray.OnCompareFunc compare_func) Sorts a byte 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
first arg is greater than second arg).static void
sortWithData
(ByteArray array, ByteArray.OnCompareDataFunc compare_func, Pointer user_data) Like g_byte_array_sort(), but the comparison function takes an extra
user data argument.static void
Atomically decrements the reference count of @array by one.Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
ByteArray
-
-
Method Details
-
getClassHandler
-
freeToBytes
Transfers the data from the #GByteArray into a new immutable #GBytes.
The #GByteArray is freed unless the reference count of @array is greater
than one, the #GByteArray wrapper is preserved but the size of @array
will be set to zero.
This is identical to using g_bytes_new_take() and g_byte_array_free()
together.- Parameters:
array
- a #GByteArray- Returns:
- a new immutable #GBytes representing same byte data that was in the array
-
_new
Creates a new #GByteArray with a reference count of 1.- Returns:
- the new #GByteArray
-
ref
Atomically increments the reference count of @array by one.
This function is thread-safe and may be called from any thread.- Parameters:
array
- A #GByteArray- Returns:
- The passed in #GByteArray
-
removeIndex
Removes the byte at the given index from a #GByteArray.
The following bytes are moved down one place.- Parameters:
array
- a #GByteArrayindex_
- the index of the byte to remove- Returns:
- the #GByteArray
-
removeIndexFast
Removes the byte at the given index from a #GByteArray. The last
element in the array is used to fill in the space, so this function
does not preserve the order of the #GByteArray. But it is faster
than g_byte_array_remove_index().- Parameters:
array
- a #GByteArrayindex_
- the index of the byte to remove- Returns:
- the #GByteArray
-
removeRange
Removes the given number of bytes starting at the given index from a
#GByteArray. The following elements are moved to close the gap.- Parameters:
array
- a @GByteArrayindex_
- the index of the first byte to removelength
- the number of bytes to remove- Returns:
- the #GByteArray
-
setSize
Sets the size of the #GByteArray, expanding it if necessary.- Parameters:
array
- a #GByteArraylength
- the new size of the #GByteArray- Returns:
- the #GByteArray
-
sizedNew
Creates a new #GByteArray with @reserved_size bytes preallocated.
This avoids frequent reallocation, if you are going to add many
bytes to the array. Note however that the size of the array is still
0.- Parameters:
reserved_size
- number of bytes preallocated- Returns:
- the new #GByteArray
-
sort
Sorts a byte 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
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 (i.e.
you want a stable sort) you can write a comparison function that,
if two elements would otherwise compare equal, compares them by
their addresses.- Parameters:
array
- a #GByteArraycompare_func
- comparison function
-
sortWithData
public static void sortWithData(@Nonnull ByteArray array, ByteArray.OnCompareDataFunc compare_func, @Nullable Pointer user_data) Like g_byte_array_sort(), but the comparison function takes an extra
user data argument.- Parameters:
array
- a #GByteArraycompare_func
- comparison functionuser_data
- data to pass to @compare_func
-
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 thread-safe and may be called from any
thread.- Parameters:
array
- A #GByteArray
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-