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<JoltPhysicsObject>
Direct Known Subclasses:
BodyVector, Constraints, ContactList, IndexedTriangleList, PhysicsMaterialList, ShapeList

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.
    protected
    Array(JoltPhysicsObject container, long virtualAddress)
    Instantiate with the specified container and native object.
  • 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 one or more elements.
    void
    erase(int elementIndex)
    Remove the specified element.
    abstract void
    erase(int startIndex, int stopIndex)
    Remove all elements in the specified range of indices.
    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.
    • Array

      protected Array(JoltPhysicsObject container, long virtualAddress)
      Instantiate with the specified container and native object.
      Parameters:
      container - the containing object, or null if none
      virtualAddress - the virtual address of the native object to assign (not zero)
  • 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 one or more elements. The array is unaffected.
      Returns:
      true if empty, otherwise false
    • erase

      public void erase(int elementIndex)
      Remove the specified element.
      Parameters:
      elementIndex - the index of the element to remove (≥0)
    • erase

      public abstract void erase(int startIndex, int stopIndex)
      Remove all elements in the specified range of indices.
      Parameters:
      startIndex - the index of the first element to remove (≥0)
      stopIndex - one plus the index of the last element to remove (≥0)
    • 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 element (≥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