Interface GroupArray<L extends GroupLayout, T>

All Superinterfaces:
Iterable<T>, Pointer
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 Type
    Method
    Description
    long
    Returns the array memory address.
    default long
    Returns the alignment in bytes of the array.
    apply(long index, Consumer<T> consumer)
    Applies the specified consumer to the element at the specified index.
    Returns the binder used to access the array elements.
    default void
    Clears all elements in this array.
    void
    clear(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 void
    forEach(Consumer<? super T> action)
     
    get(long index)
    Returns the array element at the specified index.
    default Iterator<T>
     
    default long
    Returns the number of elements in this array.
    default Stream<T>
    Returns a parallel Stream with this array as its source.
    Returns the wrapped memory segment.
    set(long index, T value)
    Sets the array element at the specified index to the specified value.
    default long
    Returns the size in bytes of the array.
    slice(long index)
    Returns a new array that is a slice of this array starting at the specified index.
    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>
     
    default Stream<T>
    Returns a sequential Stream with this array as its source.
  • Method Details

    • address

      long address()
      Returns the array memory address.

      This address will be equal to the wrapped MemorySegment address.

      Specified by:
      address in interface Pointer
      Returns:
      the pointer address
    • binder

      GroupBinder<L,T> binder()
      Returns the binder used to access the array elements.
      Returns:
      the group binder
    • segment

      MemorySegment segment()
      Returns the wrapped memory segment.
      Returns:
      the memory segment
    • get

      T get(long index)
      Returns the array element at the specified index.
      Parameters:
      index - the array index
      Returns:
      the array element
    • set

      GroupArray<L,T> set(long index, T value)
      Sets the array element at the specified index to the specified value.
      Parameters:
      index - the array index
      value - 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 array
      other - the destination array
      otherIndex - the starting index in the destination array
      length - 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

      GroupArray<L,T> apply(long index, Consumer<T> consumer)
      Applies the specified consumer to the element at the specified index.
      Parameters:
      index - the array index
      consumer - the consumer to apply
      Returns:
      this array
    • slice

      GroupArray<L,T> slice(long index)
      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

      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.
      Parameters:
      index - the starting index
      elementCount - 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

      default <GA extends GroupArray<L,T>> GroupArray<L,T> copy(GA dst)
      Copies all elements from this array to the specified destination array.
      Parameters:
      dst - the destination array
      Returns:
      this array
    • copy

      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.
      Parameters:
      dst - the destination array
      length - 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

      default void forEach(Consumer<? super T> action)
      Specified by:
      forEach in interface Iterable<L extends GroupLayout>
    • iterator

      default Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<L extends GroupLayout>
    • spliterator

      default Spliterator<T> spliterator()
      Specified by:
      spliterator in interface Iterable<L extends GroupLayout>
    • stream

      default Stream<T> stream()
      Returns a sequential Stream with this array as its source.
      Returns:
      the new stream
    • parallelStream

      default Stream<T> parallelStream()
      Returns a parallel Stream with this array as its source.
      Returns:
      the new stream