Package ch.bailu.gtk.glib
Class Queue
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.glib.Queue
- All Implemented Interfaces:
PointerInterface
Contains the public fields of a
[Queue][glib-Double-ended-Queues].
[Queue][glib-Double-ended-Queues].
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Queue
_new()
Creates a new #GQueue.void
clear()
Removes all the elements in @queue.void
clearFull
(Queue.OnDestroyNotify free_func) Convenience method, which frees all the memory used by a #GQueue,
and calls the provided @free_func on each item in the #GQueue.copy()
Copies a @queue.void
deleteLink
(List link_) Removes @link_ from @queue and frees it.Finds the first link in @queue which contains @data.findCustom
(Pointer data, Queue.OnCompareFunc func) Finds an element in a #GQueue, using a supplied function to find the
desired element.void
foreach
(Queue.OnFunc func, Pointer user_data) Calls @func for each element in the queue passing @user_data to the
function.void
free()
Frees the memory allocated for the #GQueue.void
freeFull
(Queue.OnDestroyNotify free_func) Convenience method, which frees all the memory used by a #GQueue,
and calls the specified destroy function on every element's data.static ClassHandler
a pointer to the first element of the queueint
the number of elements in the queuea pointer to the last element of the queueint
Returns the number of items in @queue.int
Returns the position of the first element in @queue which contains @data.void
init()
A statically-allocated #GQueue must be initialized with this function
before it can be used.void
insertAfter
(List sibling, Pointer data) Inserts @data into @queue after @sibling.void
insertAfterLink
(List sibling, List link_) Inserts @link_ into @queue after @sibling.void
insertBefore
(List sibling, Pointer data) Inserts @data into @queue before @sibling.void
insertBeforeLink
(List sibling, List link_) Inserts @link_ into @queue before @sibling.void
insertSorted
(Pointer data, Queue.OnCompareDataFunc func, Pointer user_data) Inserts @data into @queue using @func to determine the new position.boolean
isEmpty()
Returns %TRUE if the queue is empty.int
Returns the position of @link_ in @queue.peekHead()
Returns the first element of the queue.Returns the first link in @queue.peekNth
(int n) Returns the @n'th element of @queue.peekNthLink
(int n) Returns the link at the given positionpeekTail()
Returns the last element of the queue.Returns the last link in @queue.popHead()
Removes the first element of the queue and returns its data.Removes and returns the first element of the queue.popNth
(int n) Removes the @n'th element of @queue and returns its data.popNthLink
(int n) Removes and returns the link at the given position.popTail()
Removes the last element of the queue and returns its data.Removes and returns the last element of the queue.void
Adds a new element at the head of the queue.void
pushHeadLink
(List link_) Adds a new element at the head of the queue.void
Inserts a new element into @queue at the given position.void
pushNthLink
(int n, List link_) Inserts @link into @queue at the given position.void
Adds a new element at the tail of the queue.void
pushTailLink
(List link_) Adds a new element at the tail of the queue.boolean
Removes the first element in @queue that contains @data.int
Remove all elements whose data equals @data from @queue.void
reverse()
Reverses the order of the items in @queue.void
setFieldHead
(List head) a pointer to the first element of the queuevoid
setFieldLength
(int length) the number of elements in the queuevoid
setFieldTail
(List tail) a pointer to the last element of the queuevoid
sort
(Queue.OnCompareDataFunc compare_func, Pointer user_data) Sorts @queue using @compare_func.void
Unlinks @link_ so that it will no longer be part of @queue.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
-
Field Details
-
HEAD
a pointer to the first element of the queue- See Also:
-
TAIL
a pointer to the last element of the queue- See Also:
-
LENGTH
the number of elements in the queue- See Also:
-
-
Constructor Details
-
Queue
-
Queue
public Queue()
-
-
Method Details
-
getClassHandler
-
setFieldHead
a pointer to the first element of the queue -
getFieldHead
a pointer to the first element of the queue -
setFieldTail
a pointer to the last element of the queue -
getFieldTail
a pointer to the last element of the queue -
setFieldLength
public void setFieldLength(int length) the number of elements in the queue -
getFieldLength
public int getFieldLength()the number of elements in the queue -
clear
public void clear()Removes all the elements in @queue. If queue elements contain
dynamically-allocated memory, they should be freed first. -
clearFull
Convenience method, which frees all the memory used by a #GQueue,
and calls the provided @free_func on each item in the #GQueue.- Parameters:
free_func
- the function to be called to free memory allocated
-
copy
Copies a @queue. Note that is a shallow copy. If the elements in the
queue consist of pointers to data, the pointers are copied, but the
actual data is not.- Returns:
- a copy of @queue
-
deleteLink
Removes @link_ from @queue and frees it.
@link_ must be part of @queue.- Parameters:
link_
- a #GList link that must be part of @queue
-
find
Finds the first link in @queue which contains @data.- Parameters:
data
- data to find- Returns:
- the first link in @queue which contains @data
-
findCustom
Finds an element in a #GQueue, using a supplied function to find the
desired element. It iterates over the queue, calling the given function
which should return 0 when the desired element is found. The function
takes two gconstpointer arguments, the #GQueue element's data as the
first argument and the given user data as the second argument.- Parameters:
data
- user data passed to @funcfunc
- a #GCompareFunc to call for each element. It should return 0 when the desired element is found- Returns:
- the found link, or %NULL if it wasn't found
-
foreach
Calls @func for each element in the queue passing @user_data to the
function.
It is safe for @func to remove the element from @queue, but it must
not modify any part of the queue after that element.- Parameters:
func
- the function to call for each element's datauser_data
- user data to pass to @func
-
free
public void free()Frees the memory allocated for the #GQueue. Only call this function
if @queue was created with g_queue_new(). If queue elements contain
dynamically-allocated memory, they should be freed first.
If queue elements contain dynamically-allocated memory, you should
either use g_queue_free_full() or free them manually first. -
freeFull
Convenience method, which frees all the memory used by a #GQueue,
and calls the specified destroy function on every element's data.
@free_func should not modify the queue (eg, by removing the freed
element from it).- Parameters:
free_func
- the function to be called to free each element's data
-
getLength
public int getLength()Returns the number of items in @queue.- Returns:
- the number of items in @queue
-
index
Returns the position of the first element in @queue which contains @data.- Parameters:
data
- the data to find- Returns:
- the position of the first element in @queue which contains @data, or -1 if no element in @queue contains @data
-
init
public void init()A statically-allocated #GQueue must be initialized with this function
before it can be used. Alternatively you can initialize it with
%G_QUEUE_INIT. It is not necessary to initialize queues created with
g_queue_new(). -
insertAfter
Inserts @data into @queue after @sibling.
@sibling must be part of @queue. Since GLib 2.44 a %NULL sibling pushes the
data at the head of the queue.- Parameters:
sibling
- a #GList link that must be part of @queue, or %NULL to push at the head of the queue.data
- the data to insert
-
insertAfterLink
Inserts @link_ into @queue after @sibling.
@sibling must be part of @queue.- Parameters:
sibling
- a #GList link that must be part of @queue, or %NULL to push at the head of the queue.link_
- a #GList link to insert which must not be part of any other list.
-
insertBefore
Inserts @data into @queue before @sibling.
@sibling must be part of @queue. Since GLib 2.44 a %NULL sibling pushes the
data at the tail of the queue.- Parameters:
sibling
- a #GList link that must be part of @queue, or %NULL to push at the tail of the queue.data
- the data to insert
-
insertBeforeLink
Inserts @link_ into @queue before @sibling.
@sibling must be part of @queue.- Parameters:
sibling
- a #GList link that must be part of @queue, or %NULL to push at the tail of the queue.link_
- a #GList link to insert which must not be part of any other list.
-
insertSorted
public void insertSorted(@Nullable Pointer data, Queue.OnCompareDataFunc func, @Nullable Pointer user_data) Inserts @data into @queue using @func to determine the new position.- Parameters:
data
- the data to insertfunc
- the #GCompareDataFunc used to compare elements in the queue. It is called with two elements of the @queue and @user_data. It should return 0 if the elements are equal, a negative value if the first element comes before the second, and a positive value if the second element comes before the first.user_data
- user data passed to @func
-
isEmpty
public boolean isEmpty()Returns %TRUE if the queue is empty.- Returns:
- %TRUE if the queue is empty
-
linkIndex
Returns the position of @link_ in @queue.- Parameters:
link_
- a #GList link- Returns:
- the position of @link_, or -1 if the link is not part of @queue
-
peekHead
Returns the first element of the queue.- Returns:
- the data of the first element in the queue, or %NULL if the queue is empty
-
peekHeadLink
Returns the first link in @queue.- Returns:
- the first link in @queue, or %NULL if @queue is empty
-
peekNth
Returns the @n'th element of @queue.- Parameters:
n
- the position of the element- Returns:
- the data for the @n'th element of @queue, or %NULL if @n is off the end of @queue
-
peekNthLink
Returns the link at the given position- Parameters:
n
- the position of the link- Returns:
- the link at the @n'th position, or %NULL if @n is off the end of the list
-
peekTail
Returns the last element of the queue.- Returns:
- the data of the last element in the queue, or %NULL if the queue is empty
-
peekTailLink
Returns the last link in @queue.- Returns:
- the last link in @queue, or %NULL if @queue is empty
-
popHead
Removes the first element of the queue and returns its data.- Returns:
- the data of the first element in the queue, or %NULL if the queue is empty
-
popHeadLink
Removes and returns the first element of the queue.- Returns:
- the #GList element at the head of the queue, or %NULL if the queue is empty
-
popNth
Removes the @n'th element of @queue and returns its data.- Parameters:
n
- the position of the element- Returns:
- the element's data, or %NULL if @n is off the end of @queue
-
popNthLink
Removes and returns the link at the given position.- Parameters:
n
- the link's position- Returns:
- the @n'th link, or %NULL if @n is off the end of @queue
-
popTail
Removes the last element of the queue and returns its data.- Returns:
- the data of the last element in the queue, or %NULL if the queue is empty
-
popTailLink
Removes and returns the last element of the queue.- Returns:
- the #GList element at the tail of the queue, or %NULL if the queue is empty
-
pushHead
Adds a new element at the head of the queue.- Parameters:
data
- the data for the new element.
-
pushHeadLink
Adds a new element at the head of the queue.- Parameters:
link_
- a single #GList element, not a list with more than one element
-
pushNth
Inserts a new element into @queue at the given position.- Parameters:
data
- the data for the new elementn
- the position to insert the new element. If @n is negative or larger than the number of elements in the @queue, the element is added to the end of the queue.
-
pushNthLink
Inserts @link into @queue at the given position.- Parameters:
n
- the position to insert the link. If this is negative or larger than the number of elements in @queue, the link is added to the end of @queue.link_
- the link to add to @queue
-
pushTail
Adds a new element at the tail of the queue.- Parameters:
data
- the data for the new element
-
pushTailLink
Adds a new element at the tail of the queue.- Parameters:
link_
- a single #GList element, not a list with more than one element
-
remove
Removes the first element in @queue that contains @data.- Parameters:
data
- the data to remove- Returns:
- %TRUE if @data was found and removed from @queue
-
removeAll
Remove all elements whose data equals @data from @queue.- Parameters:
data
- the data to remove- Returns:
- the number of elements removed from @queue
-
reverse
public void reverse()Reverses the order of the items in @queue. -
sort
Sorts @queue using @compare_func.- Parameters:
compare_func
- the #GCompareDataFunc used to sort @queue. This function is passed two elements of the queue and should return 0 if they are equal, a negative value if the first comes before the second, and a positive value if the second comes before the first.user_data
- user data passed to @compare_func
-
unlink
Unlinks @link_ so that it will no longer be part of @queue.
The link is not freed.
@link_ must be part of @queue.- Parameters:
link_
- a #GList link that must be part of @queue
-
_new
Creates a new #GQueue.- Returns:
- a newly allocated #GQueue
-