Class TrashStack

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") @Deprecated public class TrashStack extends ProxyInstance
Deprecated.
GTrashStack is deprecated without replacement

A GTrashStack is an efficient way to keep a stack of unused allocated memory chunks. Each memory chunk is required to be large enough to hold a gpointer. This allows the stack to be maintained without any space overhead, since the stack pointers can be stored inside the memory chunks.

There is no function to create a GTrashStack. A NULL GTrashStack* is a perfectly valid empty stack.

Each piece of memory that is pushed onto the stack is cast to a GTrashStack*.

There is no longer any good reason to use GTrashStack. If you have extra pieces of memory, free() them and allocate them again later.

  • Constructor Details

    • TrashStack

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

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

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

      public TrashStack(TrashStack next, Arena arena)
      Deprecated.
      Allocate a new TrashStack with the fields set to the provided values.
      Parameters:
      next - value for the field next
      arena - to control the memory allocation scope
    • TrashStack

      public TrashStack(TrashStack next)
      Deprecated.
      Allocate a new TrashStack with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      next - value for the field next
  • Method Details

    • getMemoryLayout

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

      public TrashStack readNext()
      Deprecated.
      Read the value of the field next.
      Returns:
      The value of the field next
    • writeNext

      public void writeNext(TrashStack next)
      Deprecated.
      Write a value in the field next.
      Parameters:
      next - The new value for the field next
    • height

      @Deprecated public int height()
      Deprecated.

      Returns the height of a GTrashStack.

      Note that execution of this function is of O(N) complexity where N denotes the number of items on the stack.

      Returns:
      the height of the stack
    • peek

      @Deprecated public @Nullable MemorySegment peek()
      Deprecated.
      Returns the element at the top of a GTrashStack which may be null.
      Returns:
      the element at the top of the stack
    • pop

      @Deprecated public @Nullable MemorySegment pop()
      Deprecated.
      Pops a piece of memory off a GTrashStack.
      Returns:
      the element at the top of the stack
    • push

      @Deprecated public void push(MemorySegment dataP)
      Deprecated.
      Pushes a piece of memory onto a GTrashStack.
      Parameters:
      dataP - the piece of memory to push on the stack