Interface PositionalSegment
- All Superinterfaces:
Positional
Defines the API for relative positional access to a MemorySegment.
- Author:
- Lee Rhodes
-
Method Summary
Modifier and TypeMethodDescriptionasSlice()Returns a slice of this PositionalSegment at the current position.booleanGets the boolean value at the current position.booleangetBoolean(long offsetBytes) Gets the boolean value at the given offset.bytegetByte()Gets the byte value at the current position.bytegetByte(long offsetBytes) Gets the byte value at the given offset.voidgetByteArray(byte[] dstArray, int dstOffsetBytes, int lengthBytes) Gets the byte array at the current position.chargetChar()Gets the char value at the current position.chargetChar(long offsetBytes) Gets the char value at the given offset.voidgetCharArray(char[] dstArray, int dstOffsetChars, int lengthChars) Gets the char array at the current position.doubleGets the double value at the current position.doublegetDouble(long offsetBytes) Gets the double value at the given offset.voidgetDoubleArray(double[] dstArray, int dstOffsetDoubles, int lengthDoubles) Gets the double array at the current position.floatgetFloat()Gets the float value at the current position.floatgetFloat(long offsetBytes) Gets the float value at the given offset.voidgetFloatArray(float[] dstArray, int dstOffsetFloats, int lengthFloats) Gets the float array at the current position.intgetInt()Gets the int value at the current position.intgetInt(long offsetBytes) Gets the int value at the given offset.voidgetIntArray(int[] dstArray, int dstOffsetInts, int lengthInts) Gets the int array at the current position.longgetLong()Gets the long value at the current position.longgetLong(long offsetBytes) Gets the long value at the given offset.voidgetLongArray(long[] dstArray, int dstOffsetLongs, int lengthLongs) Gets the long array at the current position.Returns the underlying MemorySegment.shortgetShort()Gets the short value at the current position.shortgetShort(long offsetBytes) Gets the short value at the given offset.voidgetShortArray(short[] dstArray, int dstOffsetShorts, int lengthShorts) Gets the short array at the current position.voidsetBoolean(boolean value) Sets the boolean value at the current position.voidsetBoolean(long offsetBytes, boolean value) Sets the boolean value at the given offset.voidsetByte(byte value) Sets the byte value at the current position.voidsetByte(long offsetBytes, byte value) Sets the byte value at the given offset.voidsetByteArray(byte[] srcArray, int srcOffsetBytes, int lengthBytes) Sets the byte array at the current position.voidsetChar(char value) Sets the char value at the current position.voidsetChar(long offsetBytes, char value) Sets the char value at the given offset.voidsetCharArray(char[] srcArray, int srcOffsetChars, int lengthChars) Sets the char array at the current position.voidsetDouble(double value) Sets the double value at the current position.voidsetDouble(long offsetBytes, double value) Sets the double value at the given offset.voidsetDoubleArray(double[] srcArray, int srcOffsetDoubles, int lengthDoubles) Sets the double array at the current position.voidsetFloat(float value) Sets the float value at the current position.voidsetFloat(long offsetBytes, float value) Sets the float value at the given offset.voidsetFloatArray(float[] srcArray, int srcOffsetFloats, int lengthFloats) Sets the float array at the current position.voidsetInt(int value) Sets the int value at the current position.voidsetInt(long offsetBytes, int value) Sets the int value at the given offset.voidsetIntArray(int[] srcArray, int srcOffsetInts, int lengthInts) Sets the int array at the current position.voidsetLong(long value) Sets the long value at the current position.voidsetLong(long offsetBytes, long value) Sets the long value at the given offset.voidsetLongArray(long[] srcArray, int srcOffsetLongs, int lengthLongs) Sets the long array at the current position.voidsetShort(long offsetBytes, short value) Sets the short value at the given offset.voidsetShort(short value) Sets the short value at the current position.voidsetShortArray(short[] srcArray, int srcOffsetShorts, int lengthShorts) Sets the short array at the current position.static PositionalSegmentwrap(MemorySegment seg) Gets an instance of this PositionalSegment.Methods inherited from interface Positional
getEnd, getPosition, getRemaining, getStart, hasRemaining, incrementPosition, resetPosition, setPosition, setStartPositionEnd
-
Method Details
-
wrap
Gets an instance of this PositionalSegment.- Parameters:
seg- the given MemorySegment to create the PositionalSegment from.- Returns:
- a new PositionalSegment.
-
asSlice
PositionalSegment asSlice()Returns a slice of this PositionalSegment at the current position. The end of the slice is the end of the underlying segment.- Returns:
- a slice of this PositionalSegment at the current position.
-
getMemorySegment
MemorySegment getMemorySegment()Returns the underlying MemorySegment. The current start, position and end are ignored.- Returns:
- the underlying MemorySegment
-
getBoolean
boolean getBoolean()Gets the boolean value at the current position. Increments the position by Byte.BYTES.- Returns:
- the boolean at the current position
-
getBoolean
boolean getBoolean(long offsetBytes) Gets the boolean value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment start- Returns:
- the boolean at the given offset
-
getByte
byte getByte()Gets the byte value at the current position. Increments the position by Byte.BYTES.- Returns:
- the byte at the current position
-
getByte
byte getByte(long offsetBytes) Gets the byte value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment start- Returns:
- the byte at the given offset
-
getByteArray
void getByteArray(byte[] dstArray, int dstOffsetBytes, int lengthBytes) Gets the byte array at the current position. Increments the position by Byte.BYTES * (lengthBytes - dstOffsetBytes).- Parameters:
dstArray- The preallocated destination array.dstOffsetBytes- offset in array unitslengthBytes- number of array units to transfer
-
getChar
char getChar()Gets the char value at the current position. Increments the position by Character.BYTES.- Returns:
- the char at the current position
-
getChar
char getChar(long offsetBytes) Gets the char value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment start- Returns:
- the char at the given offset
-
getCharArray
void getCharArray(char[] dstArray, int dstOffsetChars, int lengthChars) Gets the char array at the current position. Increments the position by Character.BYTES * (lengthChars - dstOffsetChars).- Parameters:
dstArray- The preallocated destination array.dstOffsetChars- offset in array unitslengthChars- number of array units to transfer
-
getDouble
double getDouble()Gets the double value at the current position. Increments the position by Double.BYTES.- Returns:
- the double at the current position
-
getDouble
double getDouble(long offsetBytes) Gets the double value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment start- Returns:
- the double at the given offset
-
getDoubleArray
void getDoubleArray(double[] dstArray, int dstOffsetDoubles, int lengthDoubles) Gets the double array at the current position. Increments the position by Double.BYTES * (lengthDoubles - dstOffsetDoubles).- Parameters:
dstArray- The preallocated destination array.dstOffsetDoubles- offset in array unitslengthDoubles- number of array units to transfer
-
getFloat
float getFloat()Gets the float value at the current position. Increments the position by Float.BYTES.- Returns:
- the float at the current position
-
getFloat
float getFloat(long offsetBytes) Gets the float value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment start- Returns:
- the float at the given offset
-
getFloatArray
void getFloatArray(float[] dstArray, int dstOffsetFloats, int lengthFloats) Gets the float array at the current position. Increments the position by Float.BYTES * (lengthFloats - dstOffsetFloats).- Parameters:
dstArray- The preallocated destination array.dstOffsetFloats- offset in array unitslengthFloats- number of array units to transfer
-
getInt
int getInt()Gets the int value at the current position. Increments the position by Integer.BYTES.- Returns:
- the int at the current position
-
getInt
int getInt(long offsetBytes) Gets the int value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment start- Returns:
- the int at the given offset
-
getIntArray
void getIntArray(int[] dstArray, int dstOffsetInts, int lengthInts) Gets the int array at the current position. Increments the position by Integer.BYTES * (lengthInts - dstOffsetInts).- Parameters:
dstArray- The preallocated destination array.dstOffsetInts- offset in array unitslengthInts- number of array units to transfer
-
getLong
long getLong()Gets the long value at the current position. Increments the position by Long.BYTES.- Returns:
- the long at the current position
-
getLong
long getLong(long offsetBytes) Gets the long value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment start- Returns:
- the long at the given offset
-
getLongArray
void getLongArray(long[] dstArray, int dstOffsetLongs, int lengthLongs) Gets the long array at the current position. Increments the position by Long.BYTES * (lengthLongs - dstOffsetLongs).- Parameters:
dstArray- The preallocated destination array.dstOffsetLongs- offset in array unitslengthLongs- number of array units to transfer
-
getShort
short getShort()Gets the short value at the current position. Increments the position by Short.BYTES.- Returns:
- the short at the current position
-
getShort
short getShort(long offsetBytes) Gets the short value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment start- Returns:
- the short at the given offset
-
getShortArray
void getShortArray(short[] dstArray, int dstOffsetShorts, int lengthShorts) Gets the short array at the current position. Increments the position by Short.BYTES * (lengthShorts - dstOffsetShorts).- Parameters:
dstArray- The preallocated destination array.dstOffsetShorts- offset in array unitslengthShorts- number of array units to transfer
-
setBoolean
void setBoolean(boolean value) Sets the boolean value at the current position. Increments the position by Byte.BYTES.- Parameters:
value- the value to put
-
setBoolean
void setBoolean(long offsetBytes, boolean value) Sets the boolean value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment start.value- the value to put
-
setByte
void setByte(byte value) Sets the byte value at the current position. Increments the position by Byte.BYTES.- Parameters:
value- the value to put
-
setByte
void setByte(long offsetBytes, byte value) Sets the byte value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment startvalue- the value to put
-
setByteArray
void setByteArray(byte[] srcArray, int srcOffsetBytes, int lengthBytes) Sets the byte array at the current position. Increments the position by Byte.BYTES * (lengthBytes - srcOffsetBytes).- Parameters:
srcArray- The source array.srcOffsetBytes- offset in array unitslengthBytes- number of array units to transfer
-
setChar
void setChar(char value) Sets the char value at the current position. Increments the position by Character.BYTES.- Parameters:
value- the value to put
-
setChar
void setChar(long offsetBytes, char value) Sets the char value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment startvalue- the value to put
-
setCharArray
void setCharArray(char[] srcArray, int srcOffsetChars, int lengthChars) Sets the char array at the current position. Increments the position by Character.BYTES * (lengthChars - srcOffsetChars).- Parameters:
srcArray- The source array.srcOffsetChars- offset in array unitslengthChars- number of array units to transfer
-
setDouble
void setDouble(double value) Sets the double value at the current position. Increments the position by Double.BYTES.- Parameters:
value- the value to put
-
setDouble
void setDouble(long offsetBytes, double value) Sets the double value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment startvalue- the value to put
-
setDoubleArray
void setDoubleArray(double[] srcArray, int srcOffsetDoubles, int lengthDoubles) Sets the double array at the current position. Increments the position by Double.BYTES * (lengthDoubles - srcOffsetDoubles).- Parameters:
srcArray- The source array.srcOffsetDoubles- offset in array unitslengthDoubles- number of array units to transfer
-
setFloat
void setFloat(float value) Sets the float value at the current position. Increments the position by Float.BYTES.- Parameters:
value- the value to put
-
setFloat
void setFloat(long offsetBytes, float value) Sets the float value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment startvalue- the value to put
-
setFloatArray
void setFloatArray(float[] srcArray, int srcOffsetFloats, int lengthFloats) Sets the float array at the current position. Increments the position by Float.BYTES * (lengthFloats - srcOffsetFloats).- Parameters:
srcArray- The source array.srcOffsetFloats- offset in array unitslengthFloats- number of array units to transfer
-
setInt
void setInt(int value) Sets the int value at the current position. Increments the position by Integer.BYTES.- Parameters:
value- the value to put
-
setInt
void setInt(long offsetBytes, int value) Sets the int value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment startvalue- the value to put
-
setIntArray
void setIntArray(int[] srcArray, int srcOffsetInts, int lengthInts) Sets the int array at the current position. Increments the position by Integer.BYTES * (lengthInts - srcOffsetInts).- Parameters:
srcArray- The source array.srcOffsetInts- offset in array unitslengthInts- number of array units to transfer
-
setLong
void setLong(long value) Sets the long value at the current position. Increments the position by Long.BYTES.- Parameters:
value- the value to put
-
setLong
void setLong(long offsetBytes, long value) Sets the long value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment startvalue- the value to put
-
setLongArray
void setLongArray(long[] srcArray, int srcOffsetLongs, int lengthLongs) Sets the long array at the current position. Increments the position by Long.BYTES * (lengthLongs - srcOffsetLongs).- Parameters:
srcArray- The source array.srcOffsetLongs- offset in array unitslengthLongs- number of array units to transfer
-
setShort
void setShort(short value) Sets the short value at the current position. Increments the position by Short.BYTES.- Parameters:
value- the value to put
-
setShort
void setShort(long offsetBytes, short value) Sets the short value at the given offset. This does not change the position.- Parameters:
offsetBytes- offset bytes relative to this MemorySegment startvalue- the value to put
-
setShortArray
void setShortArray(short[] srcArray, int srcOffsetShorts, int lengthShorts) Sets the short array at the current position. Increments the position by Short.BYTES * (lengthShorts - srcOffsetShorts).- Parameters:
srcArray- The source array.srcOffsetShorts- offset in array unitslengthShorts- number of array units to transfer
-