com.bulletphysics.collision.dispatch
Class UnionFind
java.lang.Object
com.bulletphysics.collision.dispatch.UnionFind
public class UnionFind
- extends java.lang.Object
UnionFind calculates connected subsets.
Implements weighted Quick Union with path compression.
Optimization: could use short ints instead of ints (halving memory, would limit the number of rigid bodies to 64k, sounds reasonable).
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UnionFind
public UnionFind()
sortIslands
public void sortIslands()
- This is a special operation, destroying the content of UnionFind.
It sorts the elements, based on island id, in order to make it easy to iterate over islands.
reset
public void reset(int N)
getNumElements
public int getNumElements()
isRoot
public boolean isRoot(int x)
getElement
public UnionFind.Element getElement(int index)
allocate
public void allocate(int N)
free
public void free()
find
public int find(int p,
int q)
unite
public void unite(int p,
int q)
find
public int find(int x)