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<JoltPhysicsObject>
- Direct Known Subclasses:
BodyVector,Constraints,IndexedTriangleList,PhysicsMaterialList,ShapeList
A variable-length array of elements.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedArray()Instantiate an array with no native object assigned.protectedArray(JoltPhysicsObject container, long virtualAddress) Instantiate with the specified container and native object. -
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 one or more elements.voiderase(int elementIndex) Remove the specified element.abstract voiderase(int startIndex, int stopIndex) Remove all elements in the specified range of indices.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, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
-
Constructor Details
-
Array
protected Array()Instantiate an array with no native object assigned. -
Array
Instantiate with the specified container and native object.- Parameters:
container- the containing object, ornullif nonevirtualAddress- 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:
trueif empty, otherwisefalse
-
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
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
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
-