Package org.gnome.glib
Class Queue
java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.glib.Queue
-
Constructor Summary
ConstructorsConstructorDescriptionQueue()Allocate a new Queue.Allocate a new Queue.Queue(MemorySegment address) Create a Queue proxy instance for the provided memory address.Queue(List<MemorySegment> head, List<MemorySegment> tail, int length) Allocate a new Queue with the fields set to the provided values.Queue(List<MemorySegment> head, List<MemorySegment> tail, int length, Arena arena) Allocate a new Queue with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all the elements inqueue.If queue elements contain dynamically-allocated memory, they should be freed first.voidConvenience method, which frees all the memory used by aGQueue, and calls the providedfreeFuncon each item in theGQueue.copy()Copies aqueue.Note that is a shallow copy.voiddeleteLink(List<MemorySegment> link) Removeslinkfrom this Queue and frees it.find(@Nullable MemorySegment data) Finds the first link in this Queue which containsdata.findCustom(@Nullable MemorySegment data, @Nullable CompareFunc func) Finds an element in aGQueue, using a supplied function to find the desired element.voidCallsfuncfor each element in the queue passinguserDatato the function.voidfree()Frees the memory allocated for theGQueue.voidfreeFull()Convenience method, which frees all the memory used by aGQueue, and calls the specified destroy function on every element's data.intReturns the number of items inqueue.static MemoryLayoutThe memory layout of the native struct.intindex(@Nullable MemorySegment data) Returns the position of the first element in this Queue which containsdata.voidinit()A statically-allocatedGQueuemust be initialized with this function before it can be used.voidinsertAfter(@Nullable List<MemorySegment> sibling, @Nullable MemorySegment data) Insertsdatainto this Queue aftersibling.voidinsertAfterLink(@Nullable List<MemorySegment> sibling, List<MemorySegment> link) Insertslinkinto this Queue aftersibling.voidinsertBefore(@Nullable List<MemorySegment> sibling, @Nullable MemorySegment data) Insertsdatainto this Queue beforesibling.voidinsertBeforeLink(@Nullable List<MemorySegment> sibling, List<MemorySegment> link) Insertslinkinto this Queue beforesibling.voidinsertSorted(@Nullable MemorySegment data, @Nullable CompareDataFunc func) Insertsdatainto this Queue usingfuncto determine the new position.booleanisEmpty()Returnstrueif the queue is empty.intlinkIndex(List<MemorySegment> link) Returns the position oflinkinqueue.static Queuenew_()Creates a newGQueue.@Nullable MemorySegmentpeekHead()Returns the first element of the queue.Returns the first link inqueue.@Nullable MemorySegmentpeekNth(int n) Returns then'thelement ofqueue.peekNthLink(int n) Returns the link at the given position@Nullable MemorySegmentpeekTail()Returns the last element of the queue.Returns the last link inqueue.@Nullable MemorySegmentpopHead()Removes the first element of the queue and returns its data.Removes and returns the first element of the queue.@Nullable MemorySegmentpopNth(int n) Removes then'thelement of this Queue and returns its data.popNthLink(int n) Removes and returns the link at the given position.@Nullable MemorySegmentpopTail()Removes the last element of the queue and returns its data.Removes and returns the last element of the queue.voidpushHead(@Nullable MemorySegment data) Adds a new element at the head of the queue.voidpushHeadLink(List<MemorySegment> link) Adds a new element at the head of the queue.voidpushNth(@Nullable MemorySegment data, int n) Inserts a new element into this Queue at the given position.voidpushNthLink(int n, List<MemorySegment> link) Insertslinkinto this Queue at the given position.voidpushTail(@Nullable MemorySegment data) Adds a new element at the tail of the queue.voidpushTailLink(List<MemorySegment> link) Adds a new element at the tail of the queue.readHead()Read the value of the fieldhead.intRead the value of the fieldlength.readTail()Read the value of the fieldtail.booleanremove(@Nullable MemorySegment data) Removes the first element in this Queue that containsdata.intremoveAll(@Nullable MemorySegment data) Remove all elements whose data equalsdatafromqueue.voidreverse()Reverses the order of the items inqueue.voidsort(@Nullable CompareDataFunc compareFunc) Sorts this Queue usingcompareFunc.voidunlink(List<MemorySegment> link) Unlinkslinkso that it will no longer be part ofqueue.The link is not freed.voidwriteHead(List<MemorySegment> head) Write a value in the fieldhead.voidwriteLength(int length) Write a value in the fieldlength.voidwriteTail(List<MemorySegment> tail) Write a value in the fieldtail.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Queue
Create a Queue proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Queue
Allocate a new Queue.- Parameters:
arena- to control the memory allocation scope
-
Queue
public Queue()Allocate a new Queue. The memory is allocated withArena.ofAuto(). -
Queue
Allocate a new Queue with the fields set to the provided values.- Parameters:
head- value for the fieldheadtail- value for the fieldtaillength- value for the fieldlengtharena- to control the memory allocation scope
-
Queue
Allocate a new Queue with the fields set to the provided values. The memory is allocated withArena.ofAuto().- Parameters:
head- value for the fieldheadtail- value for the fieldtaillength- value for the fieldlength
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readHead
Read the value of the fieldhead.- Returns:
- The value of the field
head
-
writeHead
Write a value in the fieldhead.- Parameters:
head- The new value for the fieldhead
-
readTail
Read the value of the fieldtail.- Returns:
- The value of the field
tail
-
writeTail
Write a value in the fieldtail.- Parameters:
tail- The new value for the fieldtail
-
readLength
public int readLength()Read the value of the fieldlength.- Returns:
- The value of the field
length
-
writeLength
public void writeLength(int length) Write a value in the fieldlength.- Parameters:
length- The new value for the fieldlength
-
new_
-
clear
public void clear()Removes all the elements inqueue.If queue elements contain dynamically-allocated memory, they should be freed first.- Since:
- 2.14
-
clearFull
public void clearFull()Convenience method, which frees all the memory used by aGQueue, and calls the providedfreeFuncon each item in theGQueue.- Since:
- 2.60
-
copy
Copies aqueue.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 this Queue
- Since:
- 2.4
-
deleteLink
Removeslinkfrom this Queue and frees it.linkmust be part ofqueue.- Parameters:
link- aGListlink that must be part of this Queue- Since:
- 2.4
-
find
Finds the first link in this Queue which containsdata.- Parameters:
data- data to find- Returns:
- the first link in this Queue which contains
data - Since:
- 2.4
-
findCustom
Finds an element in aGQueue, 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, theGQueueelement's data as the first argument and the given user data as the second argument.- Parameters:
data- user data passed tofuncfunc- aGCompareFuncto call for each element. It should return 0 when the desired element is found- Returns:
- the found link, or
nullif it wasn't found - Since:
- 2.4
-
foreach
Callsfuncfor each element in the queue passinguserDatato the function.It is safe for
functo remove the element fromqueue,but it must not modify any part of the queue after that element.- Parameters:
func- the function to call for each element's data- Since:
- 2.4
-
free
public void free()Frees the memory allocated for theGQueue. Only call this function if this 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
public void freeFull()Convenience method, which frees all the memory used by aGQueue, and calls the specified destroy function on every element's data.freeFuncshould not modify the queue (eg, by removing the freed element from it).- Since:
- 2.32
-
getLength
public int getLength()Returns the number of items inqueue.- Returns:
- the number of items in this Queue
- Since:
- 2.4
-
index
Returns the position of the first element in this Queue which containsdata.- Parameters:
data- the data to find- Returns:
- the position of the first element in this Queue which
contains
data,or -1 if no element in this Queue containsdata - Since:
- 2.4
-
init
public void init()A statically-allocatedGQueuemust be initialized with this function before it can be used. Alternatively you can initialize it withG_QUEUE_INIT. It is not necessary to initialize queues created with g_queue_new().- Since:
- 2.14
-
insertAfter
Insertsdatainto this Queue aftersibling.siblingmust be part ofqueue.Since GLib 2.44 anullsibling pushes the data at the head of the queue.- Parameters:
sibling- aGListlink that must be part ofqueue,ornullto push at the head of the queue.data- the data to insert- Since:
- 2.4
-
insertAfterLink
Insertslinkinto this Queue aftersibling.siblingmust be part ofqueue.- Parameters:
sibling- aGListlink that must be part ofqueue,ornullto push at the head of the queue.link- aGListlink to insert which must not be part of any other list.- Since:
- 2.62
-
insertBefore
Insertsdatainto this Queue beforesibling.siblingmust be part ofqueue.Since GLib 2.44 anullsibling pushes the data at the tail of the queue.- Parameters:
sibling- aGListlink that must be part ofqueue,ornullto push at the tail of the queue.data- the data to insert- Since:
- 2.4
-
insertBeforeLink
Insertslinkinto this Queue beforesibling.siblingmust be part ofqueue.- Parameters:
sibling- aGListlink that must be part ofqueue,ornullto push at the tail of the queue.link- aGListlink to insert which must not be part of any other list.- Since:
- 2.62
-
insertSorted
Insertsdatainto this Queue usingfuncto determine the new position.- Parameters:
data- the data to insertfunc- theGCompareDataFuncused to compare elements in the queue. It is called with two elements of the this Queue anduserData.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.- Since:
- 2.4
-
isEmpty
public boolean isEmpty()Returnstrueif the queue is empty.- Returns:
trueif the queue is empty
-
linkIndex
Returns the position oflinkinqueue.- Parameters:
link- aGListlink- Returns:
- the position of
link,or -1 if the link is not part of this Queue - Since:
- 2.4
-
peekHead
Returns the first element of the queue.- Returns:
- the data of the first element in the queue, or
nullif the queue is empty
-
peekHeadLink
Returns the first link inqueue.- Returns:
- the first link in
queue,ornullif this Queue is empty - Since:
- 2.4
-
peekNth
Returns then'thelement ofqueue.- Parameters:
n- the position of the element- Returns:
- the data for the
n'thelement ofqueue,ornullifnis off the end of this Queue - Since:
- 2.4
-
peekNthLink
Returns the link at the given position- Parameters:
n- the position of the link- Returns:
- the link at the
n'thposition, ornullifnis off the end of the list - Since:
- 2.4
-
peekTail
Returns the last element of the queue.- Returns:
- the data of the last element in the queue, or
nullif the queue is empty
-
peekTailLink
Returns the last link inqueue.- Returns:
- the last link in
queue,ornullif this Queue is empty - Since:
- 2.4
-
popHead
Removes the first element of the queue and returns its data.- Returns:
- the data of the first element in the queue, or
nullif the queue is empty
-
popHeadLink
Removes and returns the first element of the queue.- Returns:
- the
GListelement at the head of the queue, ornullif the queue is empty
-
popNth
Removes then'thelement of this Queue and returns its data.- Parameters:
n- the position of the element- Returns:
- the element's data, or
nullifnis off the end of this Queue - Since:
- 2.4
-
popNthLink
Removes and returns the link at the given position.- Parameters:
n- the link's position- Returns:
- the
n'thlink, ornullifnis off the end of this Queue - Since:
- 2.4
-
popTail
Removes the last element of the queue and returns its data.- Returns:
- the data of the last element in the queue, or
nullif the queue is empty
-
popTailLink
Removes and returns the last element of the queue.- Returns:
- the
GListelement at the tail of the queue, ornullif 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 singleGListelement, not a list with more than one element
-
pushNth
Inserts a new element into this Queue at the given position.- Parameters:
data- the data for the new elementn- the position to insert the new element. Ifnis negative or larger than the number of elements in thequeue,the element is added to the end of the queue.- Since:
- 2.4
-
pushNthLink
Insertslinkinto this Queue at the given position.- Parameters:
n- the position to insert the link. If this is negative or larger than the number of elements inqueue,the link is added to the end ofqueue.link- the link to add to this Queue- Since:
- 2.4
-
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 singleGListelement, not a list with more than one element
-
remove
Removes the first element in this Queue that containsdata.- Parameters:
data- the data to remove- Returns:
trueifdatawas found and removed from this Queue- Since:
- 2.4
-
removeAll
Remove all elements whose data equalsdatafromqueue.- Parameters:
data- the data to remove- Returns:
- the number of elements removed from this Queue
- Since:
- 2.4
-
reverse
public void reverse()Reverses the order of the items inqueue.- Since:
- 2.4
-
sort
Sorts this Queue usingcompareFunc.- Parameters:
compareFunc- theGCompareDataFuncused to sortqueue.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.- Since:
- 2.4
-
unlink
Unlinkslinkso that it will no longer be part ofqueue.The link is not freed.linkmust be part ofqueue.- Parameters:
link- aGListlink that must be part of this Queue- Since:
- 2.4
-