The most primitive accessors (see getIntAtOffset(MemorySegment, long, ByteOrder)
) take a segment, an offset
(expressed in bytes) and a byte order. The final address at which the dereference will occur will be computed by offsetting
the base address by the specified offset, as if by calling MemoryAddress.addOffset(long)
on the specified base address.
In cases where no offset is required, overloads are provided (see getInt(MemorySegment, ByteOrder)
) so that
clients can omit the offset coordinate.
To help dereferencing in array-like use cases (e.g. where the layout of a given memory segment is a sequence
layout of given size an element count), higher-level overloads are also provided (see getIntAtIndex(MemorySegment, long, ByteOrder)
),
which take a segment and a logical element index. The formula to obtain the byte offset O
from an
index I
is given by O = I * S
where S
is the size (expressed in bytes) of the element to
be dereferenced.
In cases where native byte order is preferred, overloads are provided (see getIntAtOffset(MemorySegment, long)
)
so that clients can omit the byte order parameter.
Unless otherwise specified, passing a null
argument, or an array argument containing one or more null
elements to a method in this class causes a NullPointerException
to be thrown.
-
Method Summary
Modifier and TypeMethodDescriptionstatic MemoryAddress
getAddress
(MemorySegment segment) Reads a memory address from given segment, with byte order set toByteOrder.nativeOrder()
.static MemoryAddress
getAddressAtIndex
(MemorySegment segment, long index) Reads a memory address from given segment and element index, with byte order set toByteOrder.nativeOrder()
.static MemoryAddress
getAddressAtOffset
(MemorySegment segment, long offset) Reads a memory address from given segment and offset, with byte order set toByteOrder.nativeOrder()
.static byte
getByte
(MemorySegment segment) Reads a byte from given segment.static byte
getByteAtOffset
(MemorySegment segment, long offset) Reads a byte from given segment and offset.static char
getChar
(MemorySegment segment) Reads a char from given segment, with byte order set toByteOrder.nativeOrder()
.static char
getChar
(MemorySegment segment, ByteOrder order) Reads a char from given segment, with given byte order.static char
getCharAtIndex
(MemorySegment segment, long index) Reads a char from given segment and element index, with byte order set toByteOrder.nativeOrder()
.static char
getCharAtIndex
(MemorySegment segment, long index, ByteOrder order) Reads a char from given segment and element index, with given byte order.static char
getCharAtOffset
(MemorySegment segment, long offset) Reads a char from given segment and offset, with byte order set toByteOrder.nativeOrder()
.static char
getCharAtOffset
(MemorySegment segment, long offset, ByteOrder order) Reads a char from given segment and offset with given byte order.static double
getDouble
(MemorySegment segment) Reads a double from given segment, with byte order set toByteOrder.nativeOrder()
.static double
getDouble
(MemorySegment segment, ByteOrder order) Reads a double from given segment, with given byte order.static double
getDoubleAtIndex
(MemorySegment segment, long index) Reads a double from given segment and element index, with byte order set toByteOrder.nativeOrder()
.static double
getDoubleAtIndex
(MemorySegment segment, long index, ByteOrder order) Reads a double from given segment and element index, with given byte order.static double
getDoubleAtOffset
(MemorySegment segment, long offset) Reads a double from given segment and offset, with byte order set toByteOrder.nativeOrder()
.static double
getDoubleAtOffset
(MemorySegment segment, long offset, ByteOrder order) Reads a double from given segment and offset with given byte order.static float
getFloat
(MemorySegment segment) Reads a float from given segment, with byte order set toByteOrder.nativeOrder()
.static float
getFloat
(MemorySegment segment, ByteOrder order) Reads a float from given segment, with given byte order.static float
getFloatAtIndex
(MemorySegment segment, long index) Reads a float from given segment and element index, with byte order set toByteOrder.nativeOrder()
.static float
getFloatAtIndex
(MemorySegment segment, long index, ByteOrder order) Reads a float from given segment and element index, with given byte order.static float
getFloatAtOffset
(MemorySegment segment, long offset) Reads a float from given segment and offset, with byte order set toByteOrder.nativeOrder()
.static float
getFloatAtOffset
(MemorySegment segment, long offset, ByteOrder order) Reads a float from given segment and offset with given byte order.static int
getInt
(MemorySegment segment) Reads an int from given segment, with byte order set toByteOrder.nativeOrder()
.static int
getInt
(MemorySegment segment, ByteOrder order) Reads an int from given segment, with given byte order.static int
getIntAtIndex
(MemorySegment segment, long index) Reads an int from given segment and element index, with byte order set toByteOrder.nativeOrder()
.static int
getIntAtIndex
(MemorySegment segment, long index, ByteOrder order) Reads an int from given segment and element index, with given byte order.static int
getIntAtOffset
(MemorySegment segment, long offset) Reads an int from given segment and offset, with byte order set toByteOrder.nativeOrder()
.static int
getIntAtOffset
(MemorySegment segment, long offset, ByteOrder order) Reads an int from given segment and offset with given byte order.static long
getLong
(MemorySegment segment) Reads a long from given segment, with byte order set toByteOrder.nativeOrder()
.static long
getLong
(MemorySegment segment, ByteOrder order) Reads a long from given segment, with given byte order.static long
getLongAtIndex
(MemorySegment segment, long index) Reads a long from given segment and element index, with byte order set toByteOrder.nativeOrder()
.static long
getLongAtIndex
(MemorySegment segment, long index, ByteOrder order) Reads a long from given segment and element index, with given byte order.static long
getLongAtOffset
(MemorySegment segment, long offset) Reads a long from given segment and offset, with byte order set toByteOrder.nativeOrder()
.static long
getLongAtOffset
(MemorySegment segment, long offset, ByteOrder order) Reads a long from given segment and offset with given byte order.static short
getShort
(MemorySegment segment) Reads a short from given segment, with byte order set toByteOrder.nativeOrder()
.static short
getShort
(MemorySegment segment, ByteOrder order) Reads a short from given segment, with given byte order.static short
getShortAtIndex
(MemorySegment segment, long index) Reads a short from given segment and element index, with byte order set toByteOrder.nativeOrder()
.static short
getShortAtIndex
(MemorySegment segment, long index, ByteOrder order) Reads a short from given segment and element index, with given byte order.static short
getShortAtOffset
(MemorySegment segment, long offset) Reads a short from given segment and offset, with byte order set toByteOrder.nativeOrder()
.static short
getShortAtOffset
(MemorySegment segment, long offset, ByteOrder order) Reads a short from given segment and offset with given byte order.static void
setAddress
(MemorySegment segment, Addressable value) Writes a memory address at given segment, with byte order set toByteOrder.nativeOrder()
.static void
setAddressAtIndex
(MemorySegment segment, long index, Addressable value) Writes a memory address at given segment and element index, with byte order set toByteOrder.nativeOrder()
.static void
setAddressAtOffset
(MemorySegment segment, long offset, Addressable value) Writes a memory address at given segment and offset, with byte order set toByteOrder.nativeOrder()
.static void
setByte
(MemorySegment segment, byte value) Writes a byte at given segment.static void
setByteAtOffset
(MemorySegment segment, long offset, byte value) Writes a byte at given segment and offset.static void
setChar
(MemorySegment segment, char value) Writes a char at given segment, with byte order set toByteOrder.nativeOrder()
.static void
setChar
(MemorySegment segment, ByteOrder order, char value) Writes a char at given segment, with given byte order.static void
setCharAtIndex
(MemorySegment segment, long index, char value) Writes a char at given segment and element index, with byte order set toByteOrder.nativeOrder()
.static void
setCharAtIndex
(MemorySegment segment, long index, ByteOrder order, char value) Writes a char at given segment and element index, with given byte order.static void
setCharAtOffset
(MemorySegment segment, long offset, char value) Writes a char at given segment and offset, with byte order set toByteOrder.nativeOrder()
.static void
setCharAtOffset
(MemorySegment segment, long offset, ByteOrder order, char value) Writes a char at given segment and offset with given byte order.static void
setDouble
(MemorySegment segment, double value) Writes a double at given segment, with byte order set toByteOrder.nativeOrder()
.static void
setDouble
(MemorySegment segment, ByteOrder order, double value) Writes a double at given segment, with given byte order.static void
setDoubleAtIndex
(MemorySegment segment, long index, double value) Writes a double at given segment and element index, with byte order set toByteOrder.nativeOrder()
.static void
setDoubleAtIndex
(MemorySegment segment, long index, ByteOrder order, double value) Writes a double at given segment and element index, with given byte order.static void
setDoubleAtOffset
(MemorySegment segment, long offset, double value) Writes a double at given segment and offset, with byte order set toByteOrder.nativeOrder()
.static void
setDoubleAtOffset
(MemorySegment segment, long offset, ByteOrder order, double value) Writes a double at given segment and offset with given byte order.static void
setFloat
(MemorySegment segment, float value) Writes a float at given segment, with byte order set toByteOrder.nativeOrder()
.static void
setFloat
(MemorySegment segment, ByteOrder order, float value) Writes a float at given segment, with given byte order.static void
setFloatAtIndex
(MemorySegment segment, long index, float value) Writes a float at given segment and element index, with byte order set toByteOrder.nativeOrder()
.static void
setFloatAtIndex
(MemorySegment segment, long index, ByteOrder order, float value) Writes a float at given segment and element index, with given byte order.static void
setFloatAtOffset
(MemorySegment segment, long offset, float value) Writes a float at given segment and offset, with byte order set toByteOrder.nativeOrder()
.static void
setFloatAtOffset
(MemorySegment segment, long offset, ByteOrder order, float value) Writes a float at given segment and offset with given byte order.static void
setInt
(MemorySegment segment, int value) Writes an int at given segment, with byte order set toByteOrder.nativeOrder()
.static void
setInt
(MemorySegment segment, ByteOrder order, int value) Writes an int at given segment, with given byte order.static void
setIntAtIndex
(MemorySegment segment, long index, int value) Writes an int at given segment and element index, with byte order set toByteOrder.nativeOrder()
.static void
setIntAtIndex
(MemorySegment segment, long index, ByteOrder order, int value) Writes an int at given segment and element index, with given byte order.static void
setIntAtOffset
(MemorySegment segment, long offset, int value) Writes an int at given segment and offset, with byte order set toByteOrder.nativeOrder()
.static void
setIntAtOffset
(MemorySegment segment, long offset, ByteOrder order, int value) Writes an int at given segment and offset with given byte order.static void
setLong
(MemorySegment segment, long value) Writes a long at given segment, with byte order set toByteOrder.nativeOrder()
.static void
setLong
(MemorySegment segment, ByteOrder order, long value) Writes a long at given segment, with given byte order.static void
setLongAtIndex
(MemorySegment segment, long index, long value) Writes a long at given segment and element index, with byte order set toByteOrder.nativeOrder()
.static void
setLongAtIndex
(MemorySegment segment, long index, ByteOrder order, long value) Writes a long at given segment and element index, with given byte order.static void
setLongAtOffset
(MemorySegment segment, long offset, long value) Writes a long at given segment and offset, with byte order set toByteOrder.nativeOrder()
.static void
setLongAtOffset
(MemorySegment segment, long offset, ByteOrder order, long value) Writes a long at given segment and offset with given byte order.static void
setShort
(MemorySegment segment, short value) Writes a short at given segment, with byte order set toByteOrder.nativeOrder()
.static void
setShort
(MemorySegment segment, ByteOrder order, short value) Writes a short at given segment, with given byte order.static void
setShortAtIndex
(MemorySegment segment, long index, short value) Writes a short at given segment and element index, with byte order set toByteOrder.nativeOrder()
.static void
setShortAtIndex
(MemorySegment segment, long index, ByteOrder order, short value) Writes a short at given segment and element index, with given byte order.static void
setShortAtOffset
(MemorySegment segment, long offset, short value) Writes a short at given segment and offset, with byte order set toByteOrder.nativeOrder()
.static void
setShortAtOffset
(MemorySegment segment, long offset, ByteOrder order, short value) Writes a short at given segment and offset with given byte order.
-
Method Details
-
getByteAtOffset
Reads a byte from given segment and offset.- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.- Returns:
- a byte value read from
segment
.
-
setByteAtOffset
Writes a byte at given segment and offset.- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.value
- the byte value to be written.
-
getCharAtOffset
Reads a char from given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
getCharAtOffset(segment, offset, ByteOrder.nativeOrder());
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.- Returns:
- a char value read from
segment
.
-
setCharAtOffset
Writes a char at given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setCharAtOffset(segment, offset, ByteOrder.nativeOrder(), value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.value
- the char value to be written.
-
getShortAtOffset
Reads a short from given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
getShortAtOffset(segment, offset, ByteOrder.nativeOrder());
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.- Returns:
- a short value read from
segment
.
-
setShortAtOffset
Writes a short at given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setShortAtOffset(segment, offset, ByteOrder.nativeOrder(), value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.value
- the short value to be written.
-
getIntAtOffset
Reads an int from given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
getIntAtOffset(segment, offset, ByteOrder.nativeOrder());
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.- Returns:
- an int value read from
segment
.
-
setIntAtOffset
Writes an int at given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setIntAtOffset(segment, offset, ByteOrder.nativeOrder(), value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.value
- the int value to be written.
-
getFloatAtOffset
Reads a float from given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
getFloatAtOffset(segment, offset, ByteOrder.nativeOrder());
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.- Returns:
- a float value read from
segment
.
-
setFloatAtOffset
Writes a float at given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setFloatAtOffset(segment, offset, ByteOrder.nativeOrder(), value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.value
- the float value to be written.
-
getLongAtOffset
Reads a long from given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
getLongAtOffset(segment, offset, ByteOrder.nativeOrder());
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.- Returns:
- a long value read from
segment
.
-
setLongAtOffset
Writes a long at given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setLongAtOffset(segment, offset, ByteOrder.nativeOrder(), value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.value
- the long value to be written.
-
getDoubleAtOffset
Reads a double from given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
getDoubleAtOffset(segment, offset, ByteOrder.nativeOrder());
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.- Returns:
- a double value read from
segment
.
-
setDoubleAtOffset
Writes a double at given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setDoubleAtOffset(segment, offset, ByteOrder.nativeOrder(), value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.value
- the double value to be written.
-
getAddressAtOffset
Reads a memory address from given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent (e.g. on a 64-bit platform) to the following code:
VarHandle handle = MemoryHandles.asAddressHandle(MemoryHandles.varHandle(long.class, ByteOrder.nativeOrder())); MemoryAddress value = (MemoryAddress)handle.get(segment, offset);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.- Returns:
- a memory address read from
segment
.
-
setAddressAtOffset
Writes a memory address at given segment and offset, with byte order set toByteOrder.nativeOrder()
.This is equivalent (e.g. on a 64-bit platform) to the following code:
VarHandle handle = MemoryHandles.asAddressHandle(MemoryHandles.varHandle(long.class, ByteOrder.nativeOrder())); handle.set(segment, offset, value.address());
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.value
- the memory address to be written (expressed as anAddressable
instance).
-
getCharAtOffset
Reads a char from given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(char.class, 1, order); char value = (char)handle.get(segment, offset);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.- Returns:
- a char value read from
segment
.
-
setCharAtOffset
Writes a char at given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(char.class, 1, order); handle.set(segment, offset, value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.value
- the char value to be written.
-
getShortAtOffset
Reads a short from given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(short.class, 1, order); short value = (short)handle.get(segment, offset);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.- Returns:
- a short value read from
segment
.
-
setShortAtOffset
public static void setShortAtOffset(MemorySegment segment, long offset, ByteOrder order, short value) Writes a short at given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(short.class, 1, order); handle.set(segment, offset, value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.value
- the short value to be written.
-
getIntAtOffset
Reads an int from given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(int.class, 1, order); int value = (int)handle.get(segment, offset);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.- Returns:
- an int value read from
segment
.
-
setIntAtOffset
Writes an int at given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(int.class, 1, order); handle.set(segment, offset, value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.value
- the int value to be written.
-
getFloatAtOffset
Reads a float from given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(float.class, 1, order); float value = (float)handle.get(segment, offset);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.- Returns:
- a float value read from
segment
.
-
setFloatAtOffset
public static void setFloatAtOffset(MemorySegment segment, long offset, ByteOrder order, float value) Writes a float at given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(float.class, 1, order); handle.set(segment, offset, value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.value
- the float value to be written.
-
getLongAtOffset
Reads a long from given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(long.class, 1, order); long value = (long)handle.get(segment, offset);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.- Returns:
- a long value read from
segment
.
-
setLongAtOffset
Writes a long at given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(long.class, 1, order); handle.set(segment, offset, value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.value
- the long value to be written.
-
getDoubleAtOffset
Reads a double from given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(double.class, 1, order); double value = (double)handle.get(segment, offset);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.- Returns:
- a double value read from
segment
.
-
setDoubleAtOffset
public static void setDoubleAtOffset(MemorySegment segment, long offset, ByteOrder order, double value) Writes a double at given segment and offset with given byte order.This is equivalent to the following code:
VarHandle handle = MemoryHandles.varHandle(double.class, 1, order); handle.set(segment, offset, value);
- Parameters:
segment
- the segment to be dereferenced.offset
- offset in bytes (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(offset)
.order
- the specified byte order.value
- the double value to be written.
-
getByte
Reads a byte from given segment.This is equivalent to the following code:
byte value = getByteAtOffset(segment, 0L);
- Parameters:
segment
- the segment to be dereferenced.- Returns:
- a byte value read from
segment
.
-
setByte
Writes a byte at given segment.This is equivalent to the following code:
setByteAtOffset(segment, 0L, value);
- Parameters:
segment
- the segment to be dereferenced.value
- the byte value to be written.
-
getChar
Reads a char from given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
char value = getCharAtOffset(segment, 0L);
- Parameters:
segment
- the segment to be dereferenced.- Returns:
- a char value read from
segment
.
-
setChar
Writes a char at given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setCharAtOffset(segment, 0L, value);
- Parameters:
segment
- the segment to be dereferenced.value
- the char value to be written.
-
getShort
Reads a short from given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
short value = getShortAtOffset(segment, 0L);
- Parameters:
segment
- the segment to be dereferenced.- Returns:
- a short value read from
segment
.
-
setShort
Writes a short at given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setShortAtOffset(segment, 0L, value);
- Parameters:
segment
- the segment to be dereferenced.value
- the short value to be written.
-
getInt
Reads an int from given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
int value = getIntAtOffset(segment, 0L);
- Parameters:
segment
- the segment to be dereferenced.- Returns:
- an int value read from
segment
.
-
setInt
Writes an int at given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setIntAtOffset(segment, 0L, value);
- Parameters:
segment
- the segment to be dereferenced.value
- the int value to be written.
-
getFloat
Reads a float from given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
float value = getFloatAtOffset(segment, 0L);
- Parameters:
segment
- the segment to be dereferenced.- Returns:
- a float value read from
segment
.
-
setFloat
Writes a float at given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setFloatAtOffset(segment, 0L, value);
- Parameters:
segment
- the segment to be dereferenced.value
- the float value to be written.
-
getLong
Reads a long from given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
long value = getLongAtOffset(segment, 0L);
- Parameters:
segment
- the segment to be dereferenced.- Returns:
- a long value read from
segment
.
-
setLong
Writes a long at given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setLongAtOffset(segment, 0L, value);
- Parameters:
segment
- the segment to be dereferenced.value
- the long value to be written.
-
getDouble
Reads a double from given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
double value = getDoubleAtOffset(segment, 0L);
- Parameters:
segment
- the segment to be dereferenced.- Returns:
- a double value read from
segment
.
-
setDouble
Writes a double at given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setDoubleAtOffset(segment, 0L, value);
- Parameters:
segment
- the segment to be dereferenced.value
- the double value to be written.
-
getAddress
Reads a memory address from given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
MemoryAddress value = getAddressAtOffset(segment, 0L);
- Parameters:
segment
- the segment to be dereferenced.- Returns:
- a memory address read from
segment
.
-
setAddress
Writes a memory address at given segment, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setAddressAtOffset(segment, 0L, value);
- Parameters:
segment
- the segment to be dereferenced.value
- the memory address to be written (expressed as anAddressable
instance).
-
getChar
Reads a char from given segment, with given byte order.This is equivalent to the following code:
char value = getCharAtOffset(segment, 0L, order);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.- Returns:
- a char value read from
segment
.
-
setChar
Writes a char at given segment, with given byte order.This is equivalent to the following code:
setCharAtOffset(segment, 0L, order, value);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.value
- the char value to be written.
-
getShort
Reads a short from given segment, with given byte order.This is equivalent to the following code:
short value = getShortAtOffset(segment, 0L, order);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.- Returns:
- a short value read from
segment
.
-
setShort
Writes a short at given segment, with given byte order.This is equivalent to the following code:
setShortAtOffset(segment, 0L, order, value);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.value
- the short value to be written.
-
getInt
Reads an int from given segment, with given byte order.This is equivalent to the following code:
int value = getIntAtOffset(segment, 0L, order);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.- Returns:
- an int value read from
segment
.
-
setInt
Writes an int at given segment, with given byte order.This is equivalent to the following code:
setIntAtOffset(segment, 0L, order, value);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.value
- the int value to be written.
-
getFloat
Reads a float from given segment, with given byte order.This is equivalent to the following code:
float value = getFloatAtOffset(segment, 0L, order);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.- Returns:
- a float value read from
segment
.
-
setFloat
Writes a float at given segment, with given byte order.This is equivalent to the following code:
setFloatAtOffset(segment, 0L, order, value);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.value
- the float value to be written.
-
getLong
Reads a long from given segment, with given byte order.This is equivalent to the following code:
long value = getLongAtOffset(segment, 0L, order);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.- Returns:
- a long value read from
segment
.
-
setLong
Writes a long at given segment, with given byte order.This is equivalent to the following code:
setLongAtOffset(segment, 0L, order, value);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.value
- the long value to be written.
-
getDouble
Reads a double from given segment, with given byte order.This is equivalent to the following code:
double value = getDoubleAtOffset(segment, 0L, order);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.- Returns:
- a double value read from
segment
.
-
setDouble
Writes a double at given segment, with given byte order.This is equivalent to the following code:
setDoubleAtOffset(segment, 0L, order, value);
- Parameters:
segment
- the segment to be dereferenced.order
- the specified byte order.value
- the double value to be written.
-
getCharAtIndex
Reads a char from given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
char value = getCharAtOffset(segment, 2 * index);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 2)
.- Returns:
- a char value read from
segment
at the element index specified byindex
.
-
setCharAtIndex
Writes a char at given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setCharAtOffset(segment, 2 * index, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 2)
.value
- the char value to be written.
-
getShortAtIndex
Reads a short from given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
short value = getShortAtOffset(segment, 2 * index);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 2)
.- Returns:
- a short value read from
segment
at the element index specified byindex
.
-
setShortAtIndex
Writes a short at given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setShortAtOffset(segment, 2 * index, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 2)
.value
- the short value to be written.
-
getIntAtIndex
Reads an int from given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
int value = getIntAtOffset(segment, 4 * index);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 4)
.- Returns:
- an int value read from
segment
at the element index specified byindex
.
-
setIntAtIndex
Writes an int at given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setIntAtOffset(segment, 4 * index, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 4)
.value
- the int value to be written.
-
getFloatAtIndex
Reads a float from given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
float value = getFloatAtOffset(segment, 4 * index);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 4)
.- Returns:
- a float value read from
segment
at the element index specified byindex
.
-
setFloatAtIndex
Writes a float at given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setFloatAtOffset(segment, 4 * index, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 4)
.value
- the float value to be written.
-
getLongAtIndex
Reads a long from given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
return getLongAtOffset(segment, 8 * index);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 8)
.- Returns:
- a long value read from
segment
at the element index specified byindex
.
-
setLongAtIndex
Writes a long at given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setLongAtOffset(segment, 8 * index, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 8)
.value
- the long value to be written.
-
getDoubleAtIndex
Reads a double from given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
return getDoubleAtOffset(segment, 8 * index);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 8)
.- Returns:
- a double value read from
segment
at the element index specified byindex
.
-
setDoubleAtIndex
Writes a double at given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setDoubleAtOffset(segment, 8 * index, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 8)
.value
- the double value to be written.
-
getAddressAtIndex
Reads a memory address from given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
return getAddressAtOffset(segment, index * MemoryLayouts.ADDRESS.byteSize());
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 8)
.- Returns:
- a memory address read from
segment
at the element index specified byindex
.
-
setAddressAtIndex
Writes a memory address at given segment and element index, with byte order set toByteOrder.nativeOrder()
.This is equivalent to the following code:
setAddressAtOffset(segment, index * MemoryLayouts.ADDRESS.byteSize(), value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 8)
.value
- the memory address to be written (expressed as anAddressable
instance).
-
getCharAtIndex
Reads a char from given segment and element index, with given byte order.This is equivalent to the following code:
char value = getCharAtOffset(segment, 2 * index, order);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 2)
.order
- the specified byte order.- Returns:
- a char value read from
segment
at the element index specified byindex
.
-
setCharAtIndex
Writes a char at given segment and element index, with given byte order.This is equivalent to the following code:
setCharAtOffset(segment, 2 * index, order, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 2)
.order
- the specified byte order.value
- the char value to be written.
-
getShortAtIndex
Reads a short from given segment and element index, with given byte order.This is equivalent to the following code:
short value = getShortAtOffset(segment, 2 * index, order);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 2)
.order
- the specified byte order.- Returns:
- a short value read from
segment
at the element index specified byindex
.
-
setShortAtIndex
Writes a short at given segment and element index, with given byte order.This is equivalent to the following code:
setShortAtOffset(segment, 2 * index, order, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 2)
.order
- the specified byte order.value
- the short value to be written.
-
getIntAtIndex
Reads an int from given segment and element index, with given byte order.This is equivalent to the following code:
int value = getIntAtOffset(segment, 4 * index, order);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 4)
.order
- the specified byte order.- Returns:
- an int value read from
segment
at the element index specified byindex
.
-
setIntAtIndex
Writes an int at given segment and element index, with given byte order.This is equivalent to the following code:
setIntAtOffset(segment, 4 * index, order, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 4)
.order
- the specified byte order.value
- the int value to be written.
-
getFloatAtIndex
Reads a float from given segment and element index, with given byte order.This is equivalent to the following code:
float value = getFloatAtOffset(segment, 4 * index, order);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 4)
.order
- the specified byte order.- Returns:
- a float value read from
segment
at the element index specified byindex
.
-
setFloatAtIndex
Writes a float at given segment and element index, with given byte order.This is equivalent to the following code:
setFloatAtOffset(segment, 4 * index, order, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 4)
.order
- the specified byte order.value
- the float value to be written.
-
getLongAtIndex
Reads a long from given segment and element index, with given byte order.This is equivalent to the following code:
return getLongAtOffset(segment, 8 * index, order);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 8)
.order
- the specified byte order.- Returns:
- a long value read from
segment
at the element index specified byindex
.
-
setLongAtIndex
Writes a long at given segment and element index, with given byte order.This is equivalent to the following code:
setLongAtOffset(segment, 8 * index, order, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 8)
.order
- the specified byte order.value
- the long value to be written.
-
getDoubleAtIndex
Reads a double from given segment and element index, with given byte order.This is equivalent to the following code:
return getDoubleAtOffset(segment, 8 * index, order);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 8)
.order
- the specified byte order.- Returns:
- a double value read from
segment
at the element index specified byindex
.
-
setDoubleAtIndex
public static void setDoubleAtIndex(MemorySegment segment, long index, ByteOrder order, double value) Writes a double at given segment and element index, with given byte order.This is equivalent to the following code:
setDoubleAtOffset(segment, 8 * index, order, value);
- Parameters:
segment
- the segment to be dereferenced.index
- element index (relative tosegment
). The final address of this read operation can be expressed assegment.address().addOffset(index * 8)
.order
- the specified byte order.value
- the double value to be written.
-