Class LongPtr

All Implemented Interfaces:
Addressable
Direct Known Subclasses:
LongPtr.Buffer

public sealed class LongPtr extends GroupType permits LongPtr.Buffer

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)
      Creates LongPtr with the given segment.
      Parameters:
      segment - the memory segment
  • Method Details

    • of

      public static LongPtr.Buffer 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.Buffer 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.Buffer 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
    • allocInit

      public static LongPtr allocInit(SegmentAllocator allocator, long value)
      Allocates a LongPtr with the given segment allocator and arguments like initializer list.
      Parameters:
      allocator - the segment allocator
      value - value
      Returns:
      the allocated LongPtr
    • copyFrom

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

      public LongPtr.Buffer asBuffer()
      Converts this instance to a buffer.
      Returns:
      the 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