# Uses of Interface
java.lang.foreign.ValueLayout.OfShort

Packages that use ValueLayout.OfShort
Package
Description
java.lang.foreign
Provides low-level access to memory and functions outside the Java runtime.

## Uses of ValueLayout.OfShort in java.lang.foreign

Fields in java.lang.foreign declared as ValueLayout.OfShort
Modifier and Type
Field
Description
`static final ValueLayout.OfShort`
ValueLayout.`JAVA_SHORT`
A value layout constant whose size is the same as that of a Java `short`, byte alignment set to 2, and byte order set to `ByteOrder.nativeOrder()`.
`static final ValueLayout.OfShort`
ValueLayout.`JAVA_SHORT_UNALIGNED`
An unaligned value layout constant whose size is the same as that of a Java `short` and byte order set to `ByteOrder.nativeOrder()`.
Methods in java.lang.foreign that return ValueLayout.OfShort
Modifier and Type
Method
Description
`ValueLayout.OfShort`
ValueLayout.OfShort.`withByteAlignment(long byteAlignment)`
Returns a memory layout with the same characteristics as this layout, but with the given alignment constraint (in bytes).
`ValueLayout.OfShort`
ValueLayout.OfShort.`withName(String name)`
Returns a memory layout with the same characteristics as this layout, but with the given name.
`ValueLayout.OfShort`
ValueLayout.OfShort.`withOrder(ByteOrder order)`
Returns a value layout with the same characteristics as this layout, but with the given byte order.
`ValueLayout.OfShort`
ValueLayout.OfShort.`withoutName()`
Returns a memory layout with the same characteristics as this layout, but with no name.
Methods in java.lang.foreign with parameters of type ValueLayout.OfShort
Modifier and Type
Method
Description
`default MemorySegment`
SegmentAllocator.`allocateFrom(ValueLayout.OfShort layout, short value)`
Returns a new memory segment initialized with the provided short value.
`default MemorySegment`
SegmentAllocator.`allocateFrom(ValueLayout.OfShort elementLayout, short... elements)`
Returns a new memory segment initialized with the elements in the provided short array.
`short`
MemorySegment.`get(ValueLayout.OfShort layout, long offset)`
Reads a short from this segment at the given offset, with the given layout.
`short`
MemorySegment.`getAtIndex(ValueLayout.OfShort layout, long index)`
Reads a short from this segment at the given index, scaled by the given layout size.
`void`
MemorySegment.`set(ValueLayout.OfShort layout, long offset, short value)`
Writes a short into this segment at the given offset, with the given layout.
`void`
MemorySegment.`setAtIndex(ValueLayout.OfShort layout, long index, short value)`
Writes a short into this segment at the given index, scaled by the given layout size.
`short[]`
MemorySegment.`toArray(ValueLayout.OfShort elementLayout)`
Copy the contents of this memory segment into a new short array.