Record Class StructArray<T>

java.lang.Object
java.lang.Record
org.lwjgl.system.ffm.StructArray<T>
Record Components:
binder - the binder used to access the array elements
segment - the memory segment to wrap
All Implemented Interfaces:
Iterable<T>, GroupArray<StructLayout, T>, Pointer

public record StructArray<T>(StructBinder<T> binder, MemorySegment segment) extends Record implements GroupArray<StructLayout, T>
Can be used to create a MemorySegment view as an array of structs.
See Also:
  • Constructor Details

    • StructArray

      public StructArray(StructBinder<T> binder, MemorySegment segment)
      Creates an instance of a StructArray record class.
      Parameters:
      binder - the value for the binder record component
      segment - the value for the segment record component
  • Method Details

    • address

      public long address()
      Description copied from interface: GroupArray
      Returns the array memory address.

      This address will be equal to the wrapped MemorySegment address.

      Specified by:
      address in interface GroupArray<StructLayout, T>
      Specified by:
      address in interface Pointer
      Returns:
      the pointer address
    • get

      public T get(long index)
      Description copied from interface: GroupArray
      Returns the array element at the specified index.
      Specified by:
      get in interface GroupArray<StructLayout, T>
      Parameters:
      index - the array index
      Returns:
      the array element
    • set

      public StructArray<T> set(long index, T value)
      Description copied from interface: GroupArray
      Sets the array element at the specified index to the specified value.
      Specified by:
      set in interface GroupArray<StructLayout, T>
      Parameters:
      index - the array index
      value - the new value
      Returns:
      this array
    • copy

      public <GA extends GroupArray<StructLayout, T>> StructArray<T> copy(long thisIndex, GA other, long otherIndex, long length)
      Description copied from interface: GroupArray
      Copies elements from this array to another array.
      Specified by:
      copy in interface GroupArray<StructLayout, T>
      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

      public void clear(long fromIndex, long toIndex)
      Description copied from interface: GroupArray
      Clears the elements in the specified index range.
      Specified by:
      clear in interface GroupArray<StructLayout, T>
      Parameters:
      fromIndex - the starting index (inclusive)
      toIndex - the ending index (exclusive)
    • apply

      public StructArray<T> apply(long index, Consumer<T> consumer)
      Description copied from interface: GroupArray
      Applies the specified consumer to the element at the specified index.
      Specified by:
      apply in interface GroupArray<StructLayout, T>
      Parameters:
      index - the array index
      consumer - the consumer to apply
      Returns:
      this array
    • slice

      public StructArray<T> slice(long index)
      Description copied from interface: GroupArray
      Returns a new array that is a slice of this array starting at the specified index.
      Specified by:
      slice in interface GroupArray<StructLayout, T>
      Parameters:
      index - the starting index
      Returns:
      the sliced array
    • slice

      public StructArray<T> slice(long index, long elementCount)
      Description copied from interface: GroupArray
      Returns a new array that is a slice of this array starting at the specified index and containing the specified number of elements.
      Specified by:
      slice in interface GroupArray<StructLayout, T>
      Parameters:
      index - the starting index
      elementCount - the number of elements in the slice
      Returns:
      the sliced array
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • binder

      public StructBinder<T> binder()
      Returns the value of the binder record component.
      Specified by:
      binder in interface GroupArray<StructLayout, T>
      Returns:
      the value of the binder record component
    • segment

      public MemorySegment segment()
      Returns the value of the segment record component.
      Specified by:
      segment in interface GroupArray<StructLayout, T>
      Returns:
      the value of the segment record component