# Interface PositionalSegment

All Superinterfaces:
  `Positional`

public interface PositionalSegment extends Positional
Defines the API for relative positional access to a MemorySegment.

Author:
  Lee Rhodes

## Method Summary

Modifier and Type
Method
Description
`PositionalSegment`
`asSlice()`
Returns a slice of this PositionalSegment at the current position.
`boolean`
`getBoolean()`
Gets the boolean value at the current position.
`boolean`
`getBoolean(long offsetBytes)`
Gets the boolean value at the given offset.
`byte`
`getByte()`
Gets the byte value at the current position.
`byte`
`getByte(long offsetBytes)`
Gets the byte value at the given offset.
`void`
`getByteArray(byte[] dstArray, int dstOffsetBytes, int lengthBytes)`
Gets the byte array at the current position.
`char`
`getChar()`
Gets the char value at the current position.
`char`
`getChar(long offsetBytes)`
Gets the char value at the given offset.
`void`
`getCharArray(char[] dstArray, int dstOffsetChars, int lengthChars)`
Gets the char array at the current position.
`double`
`getDouble()`
Gets the double value at the current position.
`double`
`getDouble(long offsetBytes)`
Gets the double value at the given offset.
`void`
`getDoubleArray(double[] dstArray, int dstOffsetDoubles, int lengthDoubles)`
Gets the double array at the current position.
`float`
`getFloat()`
Gets the float value at the current position.
`float`
`getFloat(long offsetBytes)`
Gets the float value at the given offset.
`void`
`getFloatArray(float[] dstArray, int dstOffsetFloats, int lengthFloats)`
Gets the float array at the current position.
`int`
`getInt()`
Gets the int value at the current position.
`int`
`getInt(long offsetBytes)`
Gets the int value at the given offset.
`void`
`getIntArray(int[] dstArray, int dstOffsetInts, int lengthInts)`
Gets the int array at the current position.
`long`
`getLong()`
Gets the long value at the current position.
`long`
`getLong(long offsetBytes)`
Gets the long value at the given offset.
`void`
`getLongArray(long[] dstArray, int dstOffsetLongs, int lengthLongs)`
Gets the long array at the current position.
`MemorySegment`
`getMemorySegment()`
Returns the underlying MemorySegment.
`short`
`getShort()`
Gets the short value at the current position.
`short`
`getShort(long offsetBytes)`
Gets the short value at the given offset.
`void`
`getShortArray(short[] dstArray, int dstOffsetShorts, int lengthShorts)`
Gets the short array at the current position.
`void`
`setBoolean(boolean value)`
Sets the boolean value at the current position.
`void`
`setBoolean(long offsetBytes, boolean value)`
Sets the boolean value at the given offset.
`void`
`setByte(byte value)`
Sets the byte value at the current position.
`void`
`setByte(long offsetBytes, byte value)`
Sets the byte value at the given offset.
`void`
`setByteArray(byte[] srcArray, int srcOffsetBytes, int lengthBytes)`
Sets the byte array at the current position.
`void`
`setChar(char value)`
Sets the char value at the current position.
`void`
`setChar(long offsetBytes, char value)`
Sets the char value at the given offset.
`void`
`setCharArray(char[] srcArray, int srcOffsetChars, int lengthChars)`
Sets the char array at the current position.
`void`
`setDouble(double value)`
Sets the double value at the current position.
`void`
`setDouble(long offsetBytes, double value)`
Sets the double value at the given offset.
`void`
`setDoubleArray(double[] srcArray, int srcOffsetDoubles, int lengthDoubles)`
Sets the double array at the current position.
`void`
`setFloat(float value)`
Sets the float value at the current position.
`void`
`setFloat(long offsetBytes, float value)`
Sets the float value at the given offset.
`void`
`setFloatArray(float[] srcArray, int srcOffsetFloats, int lengthFloats)`
Sets the float array at the current position.
`void`
`setInt(int value)`
Sets the int value at the current position.
`void`
`setInt(long offsetBytes, int value)`
Sets the int value at the given offset.
`void`
`setIntArray(int[] srcArray, int srcOffsetInts, int lengthInts)`
Sets the int array at the current position.
`void`
`setLong(long value)`
Sets the long value at the current position.
`void`
`setLong(long offsetBytes, long value)`
Sets the long value at the given offset.
`void`
`setLongArray(long[] srcArray, int srcOffsetLongs, int lengthLongs)`
Sets the long array at the current position.
`void`
`setShort(long offsetBytes, short value)`
Sets the short value at the given offset.
`void`
`setShort(short value)`
Sets the short value at the current position.
`void`
`setShortArray(short[] srcArray, int srcOffsetShorts, int lengthShorts)`
Sets the short array at the current position.
`static PositionalSegment`
`wrap(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

static PositionalSegment wrap(MemorySegment seg)
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 units
  `lengthBytes` - 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 units
  `lengthChars` - 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 units
  `lengthDoubles` - 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 units
  `lengthFloats` - 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 units
  `lengthInts` - 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 units
  `lengthLongs` - 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 units
  `lengthShorts` - 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 start
  `value` - 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 units
  `lengthBytes` - 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 start
  `value` - 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 units
  `lengthChars` - 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 start
  `value` - 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 units
  `lengthDoubles` - 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 start
  `value` - 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 units
  `lengthFloats` - 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 start
  `value` - 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 units
  `lengthInts` - 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 start
  `value` - 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 units
  `lengthLongs` - 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 start
  `value` - 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 units
  `lengthShorts` - number of array units to transfer