java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.template.Array<T>
Type Parameters:
T - the specific type of element
All Implemented Interfaces:
ConstJoltPhysicsObject, AutoCloseable, Comparable<ConstJoltPhysicsObject>
Direct Known Subclasses:
BodyIdVector, BodyVector, Constraints, ContactList, IndexedTriangleList, PhysicsMaterialList

public abstract class Array<T extends JoltPhysicsObject> extends JoltPhysicsObject
A variable-length array of elements.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Instantiate an array with no native object assigned.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract int
    Count how many elements the currently allocated storage can hold.
    void
    Destroy all elements and set the size to zero.
    boolean
    Test whether the array contains any elements.
    abstract T
    get(int elementIndex)
    Access or copy the element at the specified index.
    void
    pushBack(T object)
    Append the specified object to the end.
    abstract void
    resize(int numElements)
    Expand or truncate the array.
    abstract void
    set(int elementIndex, T object)
    Put or duplicate the specified object at the specified index.
    abstract int
    Count how many elements are in the array.
    Copy all the elements (in order) to a Java list.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Array

      protected Array()
      Instantiate an array with no native object assigned.
  • Method Details

    • capacity

      public abstract int capacity()
      Count how many elements the currently allocated storage can hold. The array is unaffected.
      Returns:
      the number of elements (≥size)
    • clear

      public void clear()
      Destroy all elements and set the size to zero.
    • empty

      public boolean empty()
      Test whether the array contains any elements. The array is unaffected.
      Returns:
      true if empty, otherwise false
    • get

      public abstract T get(int elementIndex)
      Access or copy the element at the specified index.
      Parameters:
      elementIndex - the index from which to get the array (≥0)
      Returns:
      a new JVM object
    • resize

      public abstract void resize(int numElements)
      Expand or truncate the array.
      Parameters:
      numElements - the desired size (number of elements, ≥0)
    • pushBack

      public void pushBack(T object)
      Append the specified object to the end.
      Parameters:
      object - the object to append (not null)
    • set

      public abstract void set(int elementIndex, T object)
      Put or duplicate the specified object at the specified index.
      Parameters:
      elementIndex - the index at which to put the object (≥0)
      object - the object to put or duplicate (not null)
    • size

      public abstract int size()
      Count how many elements are in the array. The array is unaffected.
      Returns:
      the number of elements (≥0, ≤capacity)
    • toList

      public List<T> toList()
      Copy all the elements (in order) to a Java list.
      Returns:
      a new Java list