Class Queue

All Implemented Interfaces:
PointerInterface

public class Queue extends Record
Contains the public fields of a
[Queue][glib-Double-ended-Queues].

https://docs.gtk.org/glib/struct.Queue.html

  • Field Details

  • Constructor Details

  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • setFieldHead

      public void setFieldHead(List head)
      a pointer to the first element of the queue
    • getFieldHead

      public List getFieldHead()
      a pointer to the first element of the queue
    • setFieldTail

      public void setFieldTail(List tail)
      a pointer to the last element of the queue
    • getFieldTail

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

      public 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.
      Parameters:
      free_func - the function to be called to free memory allocated
    • 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 @queue
    • deleteLink

      public void deleteLink(@Nonnull List link_)
      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

      public List find(@Nullable Pointer data)
      Finds the first link in @queue which contains @data.
      Parameters:
      data - data to find
      Returns:
      the first link in @queue which contains @data
    • findCustom

      public List findCustom(@Nullable Pointer data, Queue.OnCompareFunc 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
    • foreach

      public void foreach(Queue.OnFunc func, @Nullable Pointer user_data)
      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 data
      user_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

      public 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.

      @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

      public int index(@Nullable Pointer data)
      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

      public void insertAfter(@Nullable List sibling, @Nullable Pointer data)
      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

      public void insertAfterLink(@Nullable List sibling, @Nonnull List link_)
      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

      public void insertBefore(@Nullable List sibling, @Nullable Pointer data)
      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

      public void insertBeforeLink(@Nullable List sibling, @Nonnull List link_)
      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 insert
      func - 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

      public int linkIndex(@Nonnull List 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 @queue
    • peekHead

      public Pointer 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 peekHeadLink()
      Returns the first link in @queue.
      Returns:
      the first link in @queue, or %NULL if @queue is empty
    • peekNth

      public Pointer 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 @queue
    • peekNthLink

      public List 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
    • peekTail

      public Pointer 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 peekTailLink()
      Returns the last link in @queue.
      Returns:
      the last link in @queue, or %NULL if @queue is empty
    • popHead

      public Pointer 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 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 Pointer popNth(int n)
      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

      public List 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 @queue
    • popTail

      public Pointer 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 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 Pointer data)
      Adds a new element at the head of the queue.
      Parameters:
      data - the data for the new element.
    • pushHeadLink

      public void pushHeadLink(@Nonnull List 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 Pointer data, int n)
      Inserts a new element into @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.
    • pushNthLink

      public void pushNthLink(int n, @Nonnull List link_)
      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

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

      public void pushTailLink(@Nonnull List 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 Pointer data)
      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

      public int removeAll(@Nullable Pointer data)
      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

      public void sort(Queue.OnCompareDataFunc compare_func, @Nullable Pointer user_data)
      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

      public void unlink(@Nonnull List 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 @queue
    • _new

      public static Queue _new()
      Creates a new #GQueue.
      Returns:
      a newly allocated #GQueue