Class VecDeque

java.lang.Object
org.javagi.base.ProxyInstance
org.freedesktop.gstreamer.gst.VecDeque
All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class VecDeque extends ProxyInstance
GstVecDeque is an object that provides standard double-ended queue (deque) functionality based on an array instead of linked lists. This reduces the overhead caused by memory management by a large factor.
Since:
1.26
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a VecDeque proxy instance for the provided memory address.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears queue this VecDeque and frees all memory associated to it.
    @Nullable MemorySegment
    dropElement(long idx)
    Drops the queue element at position idx from queue array.
    boolean
    dropStruct(long idx, @Nullable MemorySegment pStruct)
    Drops the queue element at position idx from queue this VecDeque and copies the data of the element or structure that was removed into pStruct if pStruct is set (not NULL).
    long
    find(@Nullable CompareFunc func)
    Finds an element in the queue array, either by comparing every element with func or by looking up data if no compare function func is provided, and returning the index of the found element.
    void
    Frees queue this VecDeque and all memory associated to it.
    long
    Returns the length of the queue this VecDeque
    The memory layout of the native struct.
    boolean
    Checks if the queue this VecDeque is empty.
    static VecDeque
    new_(long initialSize)
    Allocates a new GstVecDeque object with an initial queue size of initialSize.
    static VecDeque
    newForStruct(long structSize, long initialSize)
    Allocates a new GstVecDeque object for elements (e.g. structures) of size structSize, with an initial queue size of initialSize.
    @Nullable MemorySegment
    Returns the head of the queue this VecDeque and does not remove it from the queue.
    @Nullable MemorySegment
    Returns the head of the queue this VecDeque without removing it from the queue.
    @Nullable MemorySegment
    peekNth(long idx)
    Returns the item at idx in array, but does not remove it from the queue.
    @Nullable MemorySegment
    peekNthStruct(long idx)
    Returns the item at idx in array, but does not remove it from the queue.
    @Nullable MemorySegment
    Returns the tail of the queue array, but does not remove it from the queue.
    @Nullable MemorySegment
    Returns the tail of the queue array, but does not remove it from the queue.
    @Nullable MemorySegment
    Returns and head of the queue this VecDeque and removes it from the queue.
    @Nullable MemorySegment
    Returns the head of the queue this VecDeque and removes it from the queue.
    @Nullable MemorySegment
    Returns the tail of the queue this VecDeque and removes it from the queue.
    @Nullable MemorySegment
    Returns the tail of the queue this VecDeque and removes it from the queue.
    void
    pushSorted(@Nullable MemorySegment data, @Nullable CompareDataFunc func)
    Pushes data to the queue array, finding the correct position by comparing data with each array element using func.
    void
    pushSortedStruct(@Nullable MemorySegment pStruct, @Nullable CompareDataFunc func)
    Pushes the element at address pStruct into the queue this VecDeque (copying the contents of a structure of the struct_size specified when creating the queue into the array), finding the correct position by comparing the element at pStruct with each element in the array using func.
    void
    pushTail(@Nullable MemorySegment data)
    Pushes data to the tail of the queue array.
    void
    pushTailStruct(@Nullable MemorySegment pStruct)
    Pushes the element at address pStruct to the tail of the queue this VecDeque (Copies the contents of a structure of the struct_size specified when creating the queue into the array).
    void
    Sets a function to clear an element of array.
    void
    sort(@Nullable CompareDataFunc compareFunc)
    Sorts the queue this VecDeque by comparing elements against each other using the provided compareFunc.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VecDeque

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

    • getMemoryLayout

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

      public static VecDeque new_(long initialSize)
      Allocates a new GstVecDeque object with an initial queue size of initialSize.
      Parameters:
      initialSize - Initial size of the new queue
      Returns:
      a new GstVecDeque object
      Since:
      1.26
    • newForStruct

      public static VecDeque newForStruct(long structSize, long initialSize)
      Allocates a new GstVecDeque object for elements (e.g. structures) of size structSize, with an initial queue size of initialSize.
      Parameters:
      structSize - Size of each element (e.g. structure) in the array
      initialSize - Initial size of the new queue
      Returns:
      a new GstVecDeque object
      Since:
      1.26
    • clear

      public void clear()
      Clears queue this VecDeque and frees all memory associated to it.
      Since:
      1.26
    • dropElement

      public @Nullable MemorySegment dropElement(long idx)
      Drops the queue element at position idx from queue array.
      Parameters:
      idx - index to drop
      Returns:
      the dropped element
      Since:
      1.26
    • dropStruct

      public boolean dropStruct(long idx, @Nullable MemorySegment pStruct)
      Drops the queue element at position idx from queue this VecDeque and copies the data of the element or structure that was removed into pStruct if pStruct is set (not NULL).
      Parameters:
      idx - index to drop
      pStruct - address into which to store the data of the dropped structure, or NULL
      Returns:
      TRUE on success, or FALSE on error
      Since:
      1.26
    • find

      public long find(@Nullable CompareFunc func)
      Finds an element in the queue array, either by comparing every element with func or by looking up data if no compare function func is provided, and returning the index of the found element.
      Parameters:
      func - comparison function, or null to find data by value
      Returns:
      Index of the found element or -1 if nothing was found.
      Since:
      1.26
    • free

      public void free()
      Frees queue this VecDeque and all memory associated to it.
      Since:
      1.26
    • getLength

      public long getLength()
      Returns the length of the queue this VecDeque
      Returns:
      the length of the queue array.
      Since:
      1.26
    • isEmpty

      public boolean isEmpty()
      Checks if the queue this VecDeque is empty.
      Returns:
      true if the queue this VecDeque is empty
      Since:
      1.26
    • peekHead

      public @Nullable MemorySegment peekHead()
      Returns the head of the queue this VecDeque and does not remove it from the queue.
      Returns:
      The head of the queue
      Since:
      1.26
    • peekHeadStruct

      public @Nullable MemorySegment peekHeadStruct()
      Returns the head of the queue this VecDeque without removing it from the queue.
      Returns:
      pointer to element or struct, or NULL if this VecDeque was empty. The data pointed to by the returned pointer stays valid only as long as the queue array is not modified further!
      Since:
      1.26
    • peekNth

      public @Nullable MemorySegment peekNth(long idx)
      Returns the item at idx in array, but does not remove it from the queue.
      Returns:
      The item, or null if idx was out of bounds
      Since:
      1.26
    • peekNthStruct

      public @Nullable MemorySegment peekNthStruct(long idx)
      Returns the item at idx in array, but does not remove it from the queue.
      Returns:
      The item, or null if idx was out of bounds
      Since:
      1.26
    • peekTail

      public @Nullable MemorySegment peekTail()
      Returns the tail of the queue array, but does not remove it from the queue.
      Returns:
      The tail of the queue
      Since:
      1.26
    • peekTailStruct

      public @Nullable MemorySegment peekTailStruct()
      Returns the tail of the queue array, but does not remove it from the queue.
      Returns:
      The tail of the queue
      Since:
      1.26
    • popHead

      public @Nullable MemorySegment popHead()
      Returns and head of the queue this VecDeque and removes it from the queue.
      Returns:
      The head of the queue
      Since:
      1.26
    • popHeadStruct

      public @Nullable MemorySegment popHeadStruct()
      Returns the head of the queue this VecDeque and removes it from the queue.
      Returns:
      pointer to element or struct, or NULL if this VecDeque was empty. The data pointed to by the returned pointer stays valid only as long as the queue array is not modified further!
      Since:
      1.26
    • popTail

      public @Nullable MemorySegment popTail()
      Returns the tail of the queue this VecDeque and removes it from the queue.
      Returns:
      The tail of the queue
      Since:
      1.26
    • popTailStruct

      public @Nullable MemorySegment popTailStruct()
      Returns the tail of the queue this VecDeque and removes it from the queue.
      Returns:
      The tail of the queue
      Since:
      1.26
    • pushSorted

      public void pushSorted(@Nullable MemorySegment data, @Nullable CompareDataFunc func)

      Pushes data to the queue array, finding the correct position by comparing data with each array element using func.

      This has a time complexity of O(n), so depending on the size of the queue and expected access patterns, a different data structure might be better.

      Assumes that the array is already sorted. If it is not, make sure to call gst_vec_deque_sort() first.

      Parameters:
      data - object to push
      func - comparison function
      Since:
      1.26
    • pushSortedStruct

      public void pushSortedStruct(@Nullable MemorySegment pStruct, @Nullable CompareDataFunc func)

      Pushes the element at address pStruct into the queue this VecDeque (copying the contents of a structure of the struct_size specified when creating the queue into the array), finding the correct position by comparing the element at pStruct with each element in the array using func.

      This has a time complexity of O(n), so depending on the size of the queue and expected access patterns, a different data structure might be better.

      Assumes that the array is already sorted. If it is not, make sure to call gst_vec_deque_sort() first.

      Parameters:
      pStruct - address of element or structure to push into the queue
      func - comparison function
      Since:
      1.26
    • pushTail

      public void pushTail(@Nullable MemorySegment data)
      Pushes data to the tail of the queue array.
      Parameters:
      data - object to push
      Since:
      1.26
    • pushTailStruct

      public void pushTailStruct(@Nullable MemorySegment pStruct)
      Pushes the element at address pStruct to the tail of the queue this VecDeque (Copies the contents of a structure of the struct_size specified when creating the queue into the array).
      Parameters:
      pStruct - address of element or structure to push to the tail of the queue
      Since:
      1.26
    • setClearFunc

      public void setClearFunc()

      Sets a function to clear an element of array.

      The clearFunc will be called when an element in the array data segment is removed and when the array is freed and data segment is deallocated as well. clearFunc will be passed a pointer to the element to clear, rather than the element itself.

      Note that in contrast with other uses of GDestroyNotify functions, clearFunc is expected to clear the contents of the array element it is given, but not free the element itself.

      Since:
      1.26
    • sort

      public void sort(@Nullable CompareDataFunc compareFunc)
      Sorts the queue this VecDeque by comparing elements against each other using the provided compareFunc.
      Parameters:
      compareFunc - comparison function
      Since:
      1.26