java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.ContactSet
- All Implemented Interfaces:
ConstJoltPhysicsObject,AutoCloseable,Comparable<JoltPhysicsObject>
A variable-length array of contact keys. (native type:
Array<CharacterVirtual::ContactKey>)-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate an empty set.ContactSet(ContactSet original) Instantiate a copy of the specified set. -
Method Summary
Modifier and TypeMethodDescriptionintcapacity()Count how many keys the currently allocated storage can hold.booleanempty()Test whether the set contains one or more keys.voiderase(int elementIndex) Remove the key at the specified index.voiderase(int startIndex, int stopIndex) Remove all keys in the specified range of indices.intfind(ConstContactKey key) Find the element index of the first matching key, if any.get(int elementIndex) Copy the key at the specified index.voidpushBack(ConstContactKey key) Append a copy of the specified key to the end.voidresize(int numKeys) Extend or truncate the set.voidset(int elementIndex, ConstContactKey key) Store a copy of the specified key at the specified index.intsize()Count how many keys are in the set.toList()Copy all the keys (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
-
ContactSet
public ContactSet()Instantiate an empty set. -
ContactSet
Instantiate a copy of the specified set.- Parameters:
original- the set to copy (notnull, unaffected)
-
-
Method Details
-
capacity
public int capacity()Count how many keys the currently allocated storage can hold. The set is unaffected.- Returns:
- the number of keys (≥size)
-
empty
public boolean empty()Test whether the set contains one or more keys. The set is unaffected.- Returns:
trueif empty, otherwisefalse
-
erase
public void erase(int elementIndex) Remove the key at the specified index.- Parameters:
elementIndex- the element index of the key to remove (≥0)
-
erase
public void erase(int startIndex, int stopIndex) Remove all keys in the specified range of indices.- Parameters:
startIndex- the index of the first key to remove (≥0)stopIndex- one plus the index of the last key to remove (≥0)
-
find
Find the element index of the first matching key, if any.- Parameters:
key- the key to search for (notnull, unaffected)- Returns:
- the index of the first matching key, or -1 if not found
-
get
Copy the key at the specified index.- Parameters:
elementIndex- the index from which to copy the key (≥0)- Returns:
- a new object
-
pushBack
Append a copy of the specified key to the end.- Parameters:
key- the key to append (notnull, unaffected)
-
resize
public void resize(int numKeys) Extend or truncate the set.- Parameters:
numKeys- the desired size (number of keys, ≥0)
-
set
Store a copy of the specified key at the specified index.- Parameters:
elementIndex- the index at which to store the key (≥0)key- the key to store (notnull, unaffected)
-
size
public int size()Count how many keys are in the set. The set is unaffected.- Returns:
- the number of keys (≥0, ≤capacity)
-
toList
Copy all the keys (in order) to a Java list.- Returns:
- a new Java list
-