Class LongPtr

All Implemented Interfaces:
Addressable

public final class LongPtr extends GroupType

Layout

struct LongPtr {
    jlong value;
};
  • Field Details

    • LAYOUT

      public static final GroupLayout LAYOUT
      The struct layout of LongPtr.
    • OFFSET_value

      public static final long OFFSET_value
      The byte offset of value.
    • LAYOUT_value

      public static final MemoryLayout LAYOUT_value
      The memory layout of value.
    • VH_value

      public static final VarHandle VH_value
      The VarHandle of value of type (MemorySegment base, long baseOffset, long index)MemorySegment.
  • Constructor Details

    • LongPtr

      public LongPtr(MemorySegment segment, long elementCount)
      Creates LongPtr with the given segment.
      Parameters:
      segment - the memory segment
      elementCount - the element count of this struct buffer
  • Method Details

    • of

      public static LongPtr of(MemorySegment segment)
      Creates LongPtr with the given segment.
      Parameters:
      segment - the memory segment
      Returns:
      the created instance or null if the segment is NULL
    • ofNative

      public static LongPtr ofNative(MemorySegment segment)

      Creates LongPtr with the given segment.

      Reinterprets the segment if zero-length.

      Parameters:
      segment - the memory segment
      Returns:
      the created instance or null if the segment is NULL
    • ofNative

      public static LongPtr ofNative(MemorySegment segment, long count)

      Creates LongPtr with the given segment.

      Reinterprets the segment if zero-length.

      Parameters:
      segment - the memory segment
      count - the count of the buffer
      Returns:
      the created instance or null if the segment is NULL
    • alloc

      public static LongPtr alloc(SegmentAllocator allocator)
      Allocates a LongPtr with the given segment allocator.
      Parameters:
      allocator - the segment allocator
      Returns:
      the allocated LongPtr
    • alloc

      public static LongPtr alloc(SegmentAllocator allocator, long count)
      Allocates a LongPtr with the given segment allocator and count.
      Parameters:
      allocator - the segment allocator
      count - the count
      Returns:
      the allocated LongPtr
    • copyFrom

      public LongPtr copyFrom(LongPtr src)
      Copies from the given source.
      Parameters:
      src - the source
      Returns:
      this
    • reinterpret

      public LongPtr reinterpret(long count)
      Reinterprets this buffer with the given count.
      Parameters:
      count - the new count
      Returns:
      the reinterpreted buffer
    • value

      public static long value(MemorySegment segment, long index)
      Returns value at the given index.
      Parameters:
      segment - the segment of the struct
      index - the index of the struct buffer
      Returns:
      value at the given index
    • value

      public long value()
      Returns value.
      Returns:
      value
    • value

      public static void value(MemorySegment segment, long index, long value)
      Sets value with the given value at the given index.
      Parameters:
      segment - the segment of the struct
      index - the index of the struct buffer
      value - the value
    • value

      public LongPtr value(long value)
      Sets value with the given value.
      Parameters:
      value - the value
      Returns:
      this
    • asSlice

      public LongPtr asSlice(long index)
      Creates a slice of LongPtr.
      Parameters:
      index - the index of the struct buffer
      Returns:
      the slice of LongPtr
    • asSlice

      public LongPtr asSlice(long index, long count)
      Creates a slice of LongPtr.
      Parameters:
      index - the index of the struct buffer
      count - the count
      Returns:
      the slice of LongPtr
    • at

      public LongPtr at(long index, Consumer<LongPtr> func)
      Visits LongPtr buffer at the given index.
      Parameters:
      index - the index of this buffer
      func - the function to run with the slice of this buffer
      Returns:
      this
    • valueAt

      public long valueAt(long index)
      Returns value at the given index.
      Parameters:
      index - the index of the struct buffer
      Returns:
      value at the given index
    • valueAt

      public LongPtr valueAt(long index, long value)
      Sets value with the given value at the given index.
      Parameters:
      index - the index of the struct buffer
      value - the value
      Returns:
      this