com.bulletphysics.linearmath
Class MiscUtil

java.lang.Object
  extended by com.bulletphysics.linearmath.MiscUtil

public class MiscUtil
extends Object

Miscellaneous utility functions.


Constructor Summary
MiscUtil()
           
 
Method Summary
static
<T> void
ensureIndex(ObjectArrayList<T> list, int index, T value)
          Ensures valid index in provided list by filling list with provided values until the index is valid.
static float GEN_clamped(float a, float lb, float ub)
           
static int getListCapacityForHash(int size)
           
static int getListCapacityForHash(ObjectArrayList<?> list)
           
static
<T> void
heapSort(ObjectArrayList<T> list, Comparator<T> comparator)
          Sorts list using heap sort.
static
<T> int
indexOf(T[] array, T obj)
          Searches object in array.
static
<T> void
quickSort(ObjectArrayList<T> list, Comparator<T> comparator)
          Sorts list using quick sort.
static void resize(FloatArrayList list, int size, float value)
          Resizes list to exact size, filling with given value when expanding.
static void resize(IntArrayList list, int size, int value)
          Resizes list to exact size, filling with given value when expanding.
static
<T> void
resize(ObjectArrayList<T> list, int size, Class<T> valueCls)
          Resizes list to exact size, filling with new instances of given class type when expanding.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MiscUtil

public MiscUtil()
Method Detail

getListCapacityForHash

public static int getListCapacityForHash(ObjectArrayList<?> list)

getListCapacityForHash

public static int getListCapacityForHash(int size)

ensureIndex

public static <T> void ensureIndex(ObjectArrayList<T> list,
                                   int index,
                                   T value)
Ensures valid index in provided list by filling list with provided values until the index is valid.


resize

public static void resize(IntArrayList list,
                          int size,
                          int value)
Resizes list to exact size, filling with given value when expanding.


resize

public static void resize(FloatArrayList list,
                          int size,
                          float value)
Resizes list to exact size, filling with given value when expanding.


resize

public static <T> void resize(ObjectArrayList<T> list,
                              int size,
                              Class<T> valueCls)
Resizes list to exact size, filling with new instances of given class type when expanding.


indexOf

public static <T> int indexOf(T[] array,
                              T obj)
Searches object in array.

Returns:
first index of match, or -1 when not found

GEN_clamped

public static float GEN_clamped(float a,
                                float lb,
                                float ub)

heapSort

public static <T> void heapSort(ObjectArrayList<T> list,
                                Comparator<T> comparator)
Sorts list using heap sort.

Implementation from: http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Heap/


quickSort

public static <T> void quickSort(ObjectArrayList<T> list,
                                 Comparator<T> comparator)
Sorts list using quick sort.