java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.BodyIdVector
All Implemented Interfaces:
ConstJoltPhysicsObject, AutoCloseable, Comparable<JoltPhysicsObject>

public class BodyIdVector extends JoltPhysicsObject
A variable-length vector (array) of body IDs. (native type: Array<BodyID>)
  • Constructor Details

    • BodyIdVector

      public BodyIdVector()
      Instantiate an empty vector.
  • Method Details

    • capacity

      public int capacity()
      Count how many IDs the currently allocated storage can hold. The vector is unaffected.
      Returns:
      the number of IDs (≥size)
    • 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 void erase(int startIndex, int stopIndex)
      Remove all IDs 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)
    • find

      public int find(int id)
      Find the element index of the matching ID, if any.
      Parameters:
      id - the ID to search for
      Returns:
      the index of the matching element, or -1 if not found
    • get

      public int get(int elementIndex)
      Return the ID at the specified index.
      Parameters:
      elementIndex - the index from which to copy the ID (≥0)
      Returns:
      the BodyID value
    • pushBack

      public void pushBack(int bodyId)
      Append the specified object to the end.
      Parameters:
      bodyId - the ID to append
    • resize

      public void resize(int numIds)
      Expand or truncate the vector.
      Parameters:
      numIds - the desired size (number of IDs, ≥0)
    • set

      public void set(int elementIndex, int bodyId)
      Store the specified ID at the specified index.
      Parameters:
      elementIndex - the index at which to store the ID (≥0)
      bodyId - the ID to store
    • size

      public int size()
      Count how many IDs are in the vector. The vector is unaffected.
      Returns:
      the number of IDs (≥0, ≤capacity)
    • sort

      public void sort()
      Arrange the IDs in ascending order.
    • toList

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