Class (GI Struct)

GLib-2.0GLibQueue

Contains the public fields of a Queue.

Index

Constructors

Properties

head: any[]
length: number
tail: any[]
$gtype: GType<Queue>

Methods

  • Removes all the elements in queue. If queue elements contain dynamically-allocated memory, they should be freed first.

    Returns void

  • 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: Func

      the function to call for each element's data

    Returns void

  • Frees the memory allocated for the GLib.Queue. 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.

    Returns void

  • Convenience method, which frees all the memory used by a GLib.Queue, 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).

    Returns void

  • Returns the number of items in queue.

    Returns number

    the number of items in queue

  • Returns the position of the first element in queue which contains data.

    Parameters

    • Optionaldata: any

      the data to find

    Returns number

    the position of the first element in queue which contains data, or -1 if no element in queue contains data

  • A statically-allocated GLib.Queue 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().

    Returns void

  • Inserts data into queue using func to determine the new position.

    Parameters

    • data: any

      the data to insert

    • func: CompareDataFunc

      the GLib.CompareDataFunc 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.

    Returns void

  • Returns the first element of the queue.

    Returns any

    the data of the first element in the queue, or null if the queue is empty

  • Returns the n'th element of queue.

    Parameters

    • n: number

      the position of the element

    Returns any

    the data for the n'th element of queue, or null if n is off the end of queue

  • Returns the last element of the queue.

    Returns any

    the data of the last element in the queue, or null if the queue is empty

  • Removes the first element of the queue and returns its data.

    Returns any

    the data of the first element in the queue, or null if the queue is empty

  • Removes the n'th element of queue and returns its data.

    Parameters

    • n: number

      the position of the element

    Returns any

    the element's data, or null if n is off the end of queue

  • Removes the last element of the queue and returns its data.

    Returns any

    the data of the last element in the queue, or null if the queue is empty

  • Adds a new element at the head of the queue.

    Parameters

    • Optionaldata: any

      the data for the new element.

    Returns void

  • Inserts a new element into queue at the given position.

    Parameters

    • data: any

      the data for the new element

    • n: number

      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.

    Returns void

  • Adds a new element at the tail of the queue.

    Parameters

    • Optionaldata: any

      the data for the new element

    Returns void

  • Removes the first element in queue that contains data.

    Parameters

    • Optionaldata: any

      the data to remove

    Returns boolean

    true if data was found and removed from queue

  • Remove all elements whose data equals data from queue.

    Parameters

    • Optionaldata: any

      the data to remove

    Returns number

    the number of elements removed from queue

  • Sorts queue using compare_func.

    Parameters

    • compare_func: CompareDataFunc

      the GLib.CompareDataFunc 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.

    Returns void