Interface GroupArray<L extends GroupLayout, T>
- All Known Implementing Classes:
StructArray, UnionArray
public sealed interface GroupArray<L extends GroupLayout, T>
extends Pointer, Iterable<T>
permits StructArray<T>, UnionArray<T>
Can be used to create a
MemorySegment view as an array of structs or unions.
Instances of group arrays may be created with StructBinder.array(MemorySegment) or UnionBinder.array(MemorySegment).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Pointer
Pointer.Default -
Field Summary
Fields inherited from interface Pointer
BITS32, BITS64, CLONG_SHIFT, CLONG_SIZE, POINTER_SHIFT, POINTER_SIZE -
Method Summary
Modifier and TypeMethodDescriptionlongaddress()Returns the array memory address.default longalignof()Returns the alignment in bytes of the array.GroupArray<L, T> Applies the specified consumer to the element at the specified index.binder()Returns the binder used to access the array elements.default voidclear()Clears all elements in this array.voidclear(long fromIndex, long toIndex) Clears the elements in the specified index range.<GA extends GroupArray<L,T>>
GroupArray<L, T> copy(long thisIndex, GA other, long otherIndex, long length) Copies elements from this array to another array.default <GA extends GroupArray<L,T>>
GroupArray<L, T> copy(GA dst) Copies all elements from this array to the specified destination array.default <GA extends GroupArray<L,T>>
GroupArray<L, T> copy(GA dst, long length) Copies the specified number of elements from this array to the specified destination array.default voidget(long index) Returns the array element at the specified index.iterator()default longlength()Returns the number of elements in this array.Returns a parallelStreamwith this array as its source.segment()Returns the wrapped memory segment.GroupArray<L, T> Sets the array element at the specified index to the specified value.default longsizeof()Returns the size in bytes of the array.GroupArray<L, T> slice(long index) Returns a new array that is a slice of this array starting at the specified index.GroupArray<L, T> slice(long index, long elementCount) Returns a new array that is a slice of this array starting at the specified index and containing the specified number of elements.default Spliterator<T> stream()Returns a sequentialStreamwith this array as its source.
-
Method Details
-
address
-
binder
GroupBinder<L,T> binder()Returns the binder used to access the array elements.- Returns:
- the group binder
-
segment
-
get
Returns the array element at the specified index.- Parameters:
index- the array index- Returns:
- the array element
-
set
Sets the array element at the specified index to the specified value.- Parameters:
index- the array indexvalue- the new value- Returns:
- this array
-
copy
<GA extends GroupArray<L,T>> GroupArray<L,T> copy(long thisIndex, GA other, long otherIndex, long length) Copies elements from this array to another array.- Parameters:
thisIndex- the starting index in this arrayother- the destination arrayotherIndex- the starting index in the destination arraylength- the number of elements to copy- Returns:
- this array
-
clear
void clear(long fromIndex, long toIndex) Clears the elements in the specified index range.- Parameters:
fromIndex- the starting index (inclusive)toIndex- the ending index (exclusive)
-
apply
Applies the specified consumer to the element at the specified index.- Parameters:
index- the array indexconsumer- the consumer to apply- Returns:
- this array
-
slice
Returns a new array that is a slice of this array starting at the specified index.- Parameters:
index- the starting index- Returns:
- the sliced array
-
slice
Returns a new array that is a slice of this array starting at the specified index and containing the specified number of elements.- Parameters:
index- the starting indexelementCount- the number of elements in the slice- Returns:
- the sliced array
-
length
default long length()Returns the number of elements in this array.- Returns:
- the number of elements
-
copy
Copies all elements from this array to the specified destination array.- Parameters:
dst- the destination array- Returns:
- this array
-
copy
Copies the specified number of elements from this array to the specified destination array.- Parameters:
dst- the destination arraylength- the number of elements to copy- Returns:
- this array
-
clear
default void clear()Clears all elements in this array. -
sizeof
default long sizeof()Returns the size in bytes of the array.- Returns:
- the size in bytes
-
alignof
default long alignof()Returns the alignment in bytes of the array.- Returns:
- the alignment in bytes
-
forEach
-
iterator
-
spliterator
- Specified by:
spliteratorin interfaceIterable<L extends GroupLayout>
-
stream
-
parallelStream
-