Class Array<T extends JoltPhysicsObject>
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
A variable-length array of elements.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedArray()Instantiate an array with no native object assigned. -
Method Summary
Modifier and TypeMethodDescriptionabstract intcapacity()Count how many elements the currently allocated storage can hold.voidclear()Destroy all elements and set the size to zero.booleanempty()Test whether the array contains any elements.abstract Tget(int elementIndex) Access or copy the element at the specified index.voidAppend the specified object to the end.abstract voidresize(int numElements) Expand or truncate the array.abstract voidPut or duplicate the specified object at the specified index.abstract intsize()Count how many elements are in the array.toList()Copy all the elements (in order) to a Java list.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, startCleaner, toString, va
-
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
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
Append the specified object to the end.- Parameters:
object- the object to append (not null)
-
set
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
Copy all the elements (in order) to a Java list.- Returns:
- a new Java list
-