Class Queue

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Queue extends ProxyInstance
Contains the public fields of a Queue.
  • Constructor Details

    • Queue

      public Queue(MemorySegment address)
      Create a Queue proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Queue

      public Queue(Arena arena)
      Allocate a new Queue.
      Parameters:
      arena - to control the memory allocation scope
    • Queue

      public Queue()
      Allocate a new Queue. The memory is allocated with Arena.ofAuto().
    • Queue

      public Queue(List<MemorySegment> head, List<MemorySegment> tail, int length, Arena arena)
      Allocate a new Queue with the fields set to the provided values.
      Parameters:
      head - value for the field head
      tail - value for the field tail
      length - value for the field length
      arena - to control the memory allocation scope
    • Queue

      public Queue(List<MemorySegment> head, List<MemorySegment> tail, int length)
      Allocate a new Queue with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      head - value for the field head
      tail - value for the field tail
      length - value for the field length
  • Method Details

    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readHead

      public List<MemorySegment> readHead()
      Read the value of the field head.
      Returns:
      The value of the field head
    • writeHead

      public void writeHead(List<MemorySegment> head)
      Write a value in the field head.
      Parameters:
      head - The new value for the field head
    • readTail

      public List<MemorySegment> readTail()
      Read the value of the field tail.
      Returns:
      The value of the field tail
    • writeTail

      public void writeTail(List<MemorySegment> tail)
      Write a value in the field tail.
      Parameters:
      tail - The new value for the field tail
    • readLength

      public int readLength()
      Read the value of the field length.
      Returns:
      The value of the field length
    • writeLength

      public void writeLength(int length)
      Write a value in the field length.
      Parameters:
      length - The new value for the field length
    • new_

      public static Queue new_()
      Creates a new GQueue.
      Returns:
      a newly allocated GQueue
    • clear

      public void clear()
      Removes all the elements in queue. 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 a GQueue, and calls the provided freeFunc on each item in the GQueue.
      Since:
      2.60
    • copy

      public Queue 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 this Queue
      Since:
      2.4
    • deleteLink

      public void deleteLink(List<MemorySegment> link)

      Removes link from this Queue and frees it.

      link must be part of queue.

      Parameters:
      link - a GList link that must be part of this Queue
      Since:
      2.4
    • find

      public List<MemorySegment> find(@Nullable MemorySegment data)
      Finds the first link in this Queue which contains data.
      Parameters:
      data - data to find
      Returns:
      the first link in this Queue which contains data
      Since:
      2.4
    • findCustom

      public List<MemorySegment> findCustom(@Nullable MemorySegment data, @Nullable CompareFunc func)
      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 func
      func - 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
      Since:
      2.4
    • foreach

      public void foreach(@Nullable Func func)

      Calls func for each element in the queue passing userData 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 data
      Since:
      2.4
    • free

      public void free()

      Frees the memory allocated for the GQueue. 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 a GQueue, and calls the specified destroy function on every element's data.

      freeFunc should not modify the queue (eg, by removing the freed element from it).

      Since:
      2.32
    • getLength

      public int getLength()
      Returns the number of items in queue.
      Returns:
      the number of items in this Queue
      Since:
      2.4
    • index

      public int index(@Nullable MemorySegment data)
      Returns the position of the first element in this Queue which contains data.
      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 contains data
      Since:
      2.4
    • 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().
      Since:
      2.14
    • insertAfter

      public void insertAfter(@Nullable List<MemorySegment> sibling, @Nullable MemorySegment data)

      Inserts data into this 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
      Since:
      2.4
    • insertAfterLink

      public void insertAfterLink(@Nullable List<MemorySegment> sibling, List<MemorySegment> link)

      Inserts link into this 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.
      Since:
      2.62
    • insertBefore

      public void insertBefore(@Nullable List<MemorySegment> sibling, @Nullable MemorySegment data)

      Inserts data into this 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
      Since:
      2.4
    • insertBeforeLink

      public void insertBeforeLink(@Nullable List<MemorySegment> sibling, List<MemorySegment> link)

      Inserts link into this 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.
      Since:
      2.62
    • insertSorted

      public void insertSorted(@Nullable MemorySegment data, @Nullable CompareDataFunc func)
      Inserts data into this Queue using func to determine the new position.
      Parameters:
      data - the data to insert
      func - the GCompareDataFunc used to compare elements in the queue. It is called with two elements of the this Queue and userData. 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()
      Returns true if the queue is empty.
      Returns:
      true if the queue is empty
    • linkIndex

      public int linkIndex(List<MemorySegment> link)
      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 this Queue
      Since:
      2.4
    • peekHead

      public @Nullable MemorySegment 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

      public List<MemorySegment> peekHeadLink()
      Returns the first link in queue.
      Returns:
      the first link in queue, or null if this Queue is empty
      Since:
      2.4
    • peekNth

      public @Nullable MemorySegment peekNth(int n)
      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 this Queue
      Since:
      2.4
    • peekNthLink

      public List<MemorySegment> peekNthLink(int n)
      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
      Since:
      2.4
    • peekTail

      public @Nullable MemorySegment 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

      public List<MemorySegment> peekTailLink()
      Returns the last link in queue.
      Returns:
      the last link in queue, or null if this Queue is empty
      Since:
      2.4
    • popHead

      public @Nullable MemorySegment 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

      public List<MemorySegment> 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

      public @Nullable MemorySegment popNth(int n)
      Removes the n'th element of this 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 this Queue
      Since:
      2.4
    • popNthLink

      public List<MemorySegment> popNthLink(int n)
      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 this Queue
      Since:
      2.4
    • popTail

      public @Nullable MemorySegment 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

      public List<MemorySegment> 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

      public void pushHead(@Nullable MemorySegment data)
      Adds a new element at the head of the queue.
      Parameters:
      data - the data for the new element.
    • pushHeadLink

      public void pushHeadLink(List<MemorySegment> link)
      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

      public void pushNth(@Nullable MemorySegment data, int n)
      Inserts a new element into this Queue at the given position.
      Parameters:
      data - the data for the new element
      n - 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.
      Since:
      2.4
    • pushNthLink

      public void pushNthLink(int n, List<MemorySegment> link)
      Inserts link into 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 in queue, the link is added to the end of queue.
      link - the link to add to this Queue
      Since:
      2.4
    • pushTail

      public void pushTail(@Nullable MemorySegment data)
      Adds a new element at the tail of the queue.
      Parameters:
      data - the data for the new element
    • pushTailLink

      public void pushTailLink(List<MemorySegment> link)
      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

      public boolean remove(@Nullable MemorySegment data)
      Removes the first element in this Queue that contains data.
      Parameters:
      data - the data to remove
      Returns:
      true if data was found and removed from this Queue
      Since:
      2.4
    • removeAll

      public int removeAll(@Nullable MemorySegment data)
      Remove all elements whose data equals data from queue.
      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 in queue.
      Since:
      2.4
    • sort

      public void sort(@Nullable CompareDataFunc compareFunc)
      Sorts this Queue using compareFunc.
      Parameters:
      compareFunc - 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.
      Since:
      2.4
    • unlink

      public void unlink(List<MemorySegment> link)

      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 this Queue
      Since:
      2.4