APIdia Launch Partner
Top Fields Constructors Methods
jdk.internal.foreign.layout

public final Class SequenceLayoutImpl

extends AbstractLayout<SequenceLayoutImpl>
implements SequenceLayout
Class Inheritance
All Implemented Interfaces
java.lang.foreign.SequenceLayout, java.lang.foreign.MemoryLayout
Annotations
@ValueBased
Imports
jdk.internal.ValueBased, jdk.internal.foreign.Utils, java.lang.foreign.MemoryLayout, .SequenceLayout, java.util.Objects, .Optional

Field Summary

Modifier and TypeField and Description
private final long
private final MemoryLayout

Constructor Summary

AccessConstructor and Description
private
SequenceLayoutImpl(long elemCount, MemoryLayout elementLayout)

private
SequenceLayoutImpl(long elemCount, MemoryLayout elementLayout, long byteAlignment, Optional<String> name)

Method Summary

Modifier and TypeMethod and Description
pack-priv SequenceLayoutImpl
dup(long byteAlignment, Optional<String> name)

Implements abstract jdk.internal.foreign.layout.AbstractLayout.dup.

public long

Returns:

the element count of this sequence layout
elementCount
()

Implements java.lang.foreign.SequenceLayout.elementCount.

Returns the element count of this sequence layout.

public MemoryLayout

Returns:

the element layout associated with this sequence layout
elementLayout
()

Implements java.lang.foreign.SequenceLayout.elementLayout.

Returns the element layout associated with this sequence layout.

public boolean
equals(Object other)

Overrides jdk.internal.foreign.layout.AbstractLayout.equals.

Implements java.lang.foreign.MemoryLayout.equals.

Compares the specified object with this layout for equality.

public SequenceLayout

Returns:

a sequence layout with the same size as this layout (but, possibly, with different element count), whose element layout is not a sequence layout.
flatten
()

Implements java.lang.foreign.SequenceLayout.flatten.

Returns a flattened sequence layout.

public int
hashCode()

Overrides jdk.internal.foreign.layout.AbstractLayout.hashCode.

Implements java.lang.foreign.MemoryLayout.hashCode.

Returns the hash code value for this layout.

public boolean
public static SequenceLayout
of(long elementCount, MemoryLayout elementLayout)

public SequenceLayout

Returns:

a sequence layout where element layouts in the flattened projection of this sequence layout (see flatten()) are re-arranged into one or more nested sequence layouts.
reshape
(long...
an array of element counts, of which at most one can be -1.
elementCounts
)

Implements java.lang.foreign.SequenceLayout.reshape.

Re-arrange the elements in this sequence layout into a multi-dimensional sequence layout.

public String
toString()

Implements abstract jdk.internal.foreign.layout.AbstractLayout.toString.

Implements java.lang.foreign.MemoryLayout.toString.

Returns the string representation of this layout.

public SequenceLayoutImpl
withByteAlignment(long byteAlignment)

Overrides jdk.internal.foreign.layout.AbstractLayout.withByteAlignment.

Implements java.lang.foreign.SequenceLayout.withByteAlignment.

Returns a memory layout with the same characteristics as this layout, but with the given alignment constraint (in bytes).

public SequenceLayout

Returns:

a sequence layout with the given element count.
withElementCount
(long
the new element count.
elementCount
)

Implements java.lang.foreign.SequenceLayout.withElementCount.

Returns a sequence layout with the same element layout, alignment constraints and name as this sequence layout, but with the specified element count.

Inherited from jdk.internal.foreign.layout.AbstractLayout:
arrayElementVarHandlebyteAlignmentbyteOffsetbyteOffsetHandlebyteSizedecorateLayoutStringnamescalescaleHandleselectsliceHandlevarHandlevarHandleInternalwithNamewithoutName

Field Detail

elemCountback to summary
private final long elemCount
elementLayoutback to summary
private final MemoryLayout elementLayout

Constructor Detail

SequenceLayoutImplback to summary
private SequenceLayoutImpl(long elemCount, MemoryLayout elementLayout)
SequenceLayoutImplback to summary
private SequenceLayoutImpl(long elemCount, MemoryLayout elementLayout, long byteAlignment, Optional<String> name)

Method Detail

dupback to summary
pack-priv SequenceLayoutImpl dup(long byteAlignment, Optional<String> name)

Implements abstract jdk.internal.foreign.layout.AbstractLayout.dup.

Annotations
@Override
elementCountback to summary
public long elementCount()

Implements java.lang.foreign.SequenceLayout.elementCount.

Returns the element count of this sequence layout.

Returns:long

the element count of this sequence layout

elementLayoutback to summary
public MemoryLayout elementLayout()

Implements java.lang.foreign.SequenceLayout.elementLayout.

Returns the element layout associated with this sequence layout.

Returns:MemoryLayout

the element layout associated with this sequence layout

equalsback to summary
public boolean equals(Object other)

Overrides jdk.internal.foreign.layout.AbstractLayout.equals.

Implements java.lang.foreign.MemoryLayout.equals.

Doc from java.lang.foreign.MemoryLayout.equals.

Compares the specified object with this layout for equality. Returns true if and only if the specified object is also a layout, and it is equal to this layout. Two layouts are considered equal if they are of the same kind, have the same size, name and alignment constraint. Furthermore, depending on the layout kind, additional conditions must be satisfied:

Annotations
@Override
flattenback to summary
public SequenceLayout flatten()

Implements java.lang.foreign.SequenceLayout.flatten.

Returns a flattened sequence layout. The element layout of the returned sequence layout is the first non-sequence element layout found by recursively traversing the element layouts of this sequence layout. This transformation preserves the layout size; nested sequence layout in this sequence layout will be dropped and their element counts will be incorporated into that of the returned sequence layout. For instance, given a sequence layout of the kind:

var seq = MemoryLayout.sequenceLayout(4, MemoryLayout.sequenceLayout(3, ValueLayout.JAVA_INT));
var seq = MemoryLayout.sequenceLayout(4, MemoryLayout.sequenceLayout(3, ValueLayout.JAVA_INT));
calling seq.flatten() will yield the following sequence layout:
var flattenedSeq = MemoryLayout.sequenceLayout(12, ValueLayout.JAVA_INT);
var flattenedSeq = MemoryLayout.sequenceLayout(12, ValueLayout.JAVA_INT);
Returns:SequenceLayout

a sequence layout with the same size as this layout (but, possibly, with different element count), whose element layout is not a sequence layout.

hashCodeback to summary
public int hashCode()

Overrides jdk.internal.foreign.layout.AbstractLayout.hashCode.

Implements java.lang.foreign.MemoryLayout.hashCode.

Doc from java.lang.foreign.MemoryLayout.hashCode.

Returns the hash code value for this layout.

Annotations
@Override
hasNaturalAlignmentback to summary
public boolean hasNaturalAlignment()

Overrides jdk.internal.foreign.layout.AbstractLayout.hasNaturalAlignment.

Annotations
@Override
ofback to summary
public static SequenceLayout of(long elementCount, MemoryLayout elementLayout)
reshapeback to summary
public SequenceLayout reshape(long... elementCounts)

Implements java.lang.foreign.SequenceLayout.reshape.

Re-arrange the elements in this sequence layout into a multi-dimensional sequence layout. The resulting layout is a sequence layout where element layouts in the flattened projection of this sequence layout (see flatten()) are re-arranged into one or more nested sequence layouts according to the provided element counts. This transformation preserves the layout size; that is, multiplying the provided element counts must yield the same element count as the flattened projection of this sequence layout.

For instance, given a sequence layout of the kind:

var seq = MemoryLayout.sequenceLayout(4, MemoryLayout.sequenceLayout(3, ValueLayout.JAVA_INT));
var seq = MemoryLayout.sequenceLayout(4, MemoryLayout.sequenceLayout(3, ValueLayout.JAVA_INT));
calling seq.reshape(2, 6) will yield the following sequence layout:
var reshapeSeq = MemoryLayout.sequenceLayout(2, MemoryLayout.sequenceLayout(6, ValueLayout.JAVA_INT));
var reshapeSeq = MemoryLayout.sequenceLayout(2, MemoryLayout.sequenceLayout(6, ValueLayout.JAVA_INT));

If one of the provided element count is the special value -1, then the element count in that position will be inferred from the remaining element counts and the element count of the flattened projection of this layout. For instance, a layout equivalent to the above reshapeSeq can also be computed in the following ways:

var reshapeSeqImplicit1 = seq.reshape(-1, 6); var reshapeSeqImplicit2 = seq.reshape(2, -1);
var reshapeSeqImplicit1 = seq.reshape(-1, 6);
var reshapeSeqImplicit2 = seq.reshape(2, -1);
Parameters
elementCounts:long[]

an array of element counts, of which at most one can be -1.

Returns:SequenceLayout

a sequence layout where element layouts in the flattened projection of this sequence layout (see flatten()) are re-arranged into one or more nested sequence layouts.

Exceptions
IllegalArgumentException:
if two or more element counts are set to -1, or if one or more element count is <= 0 (but other than -1) or, if, after any required inference, multiplying the element counts does not yield the same element count as the flattened projection of this sequence layout.
toStringback to summary
public String toString()

Implements abstract jdk.internal.foreign.layout.AbstractLayout.toString.

Implements java.lang.foreign.MemoryLayout.toString.

Doc from java.lang.foreign.MemoryLayout.toString.

Returns the string representation of this layout.

Annotations
@Override
withByteAlignmentback to summary
public SequenceLayoutImpl withByteAlignment(long byteAlignment)

Overrides jdk.internal.foreign.layout.AbstractLayout.withByteAlignment.

Implements java.lang.foreign.SequenceLayout.withByteAlignment.

Doc from java.lang.foreign.SequenceLayout.withByteAlignment.

Returns a memory layout with the same characteristics as this layout, but with the given alignment constraint (in bytes).

Annotations
@Override
withElementCountback to summary
public SequenceLayout withElementCount(long elementCount)

Implements java.lang.foreign.SequenceLayout.withElementCount.

Returns a sequence layout with the same element layout, alignment constraints and name as this sequence layout, but with the specified element count.

Parameters
elementCount:long

the new element count.

Returns:SequenceLayout

a sequence layout with the given element count.

Exceptions
IllegalArgumentException:
if elementCount < 0.