com.threerings.opengl.util
Class GlUtil

java.lang.Object
  extended by com.threerings.opengl.util.GlUtil

public class GlUtil
extends Object

Various static methods of general utility.


Constructor Summary
GlUtil()
           
 
Method Summary
static
<T> void
divide(T[] a, Comparator<? super T> comp)
          Divides the provided array into two halves, so that the first half contains all of the elements less than the median, and the second half contains all of the elements equal to or greater than the median.
static int nextPowerOfTwo(int value)
          Returns the smallest power-of-two that is greater than or equal to the supplied (positive) value.
protected static
<T> int
partition(T[] a, int left, int right, int pivotIndex, Comparator<? super T> comp)
          Partitions the [left, right] sub-array about the element at the supplied pivot index.
protected static
<T> void
swap(T[] a, int idx1, int idx2)
          Swaps two elements in an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlUtil

public GlUtil()
Method Detail

nextPowerOfTwo

public static int nextPowerOfTwo(int value)
Returns the smallest power-of-two that is greater than or equal to the supplied (positive) value.


divide

public static <T> void divide(T[] a,
                              Comparator<? super T> comp)
Divides the provided array into two halves, so that the first half contains all of the elements less than the median, and the second half contains all of the elements equal to or greater than the median. This code is adapted from Wikipedia's page on Selection algorithms.


partition

protected static <T> int partition(T[] a,
                                   int left,
                                   int right,
                                   int pivotIndex,
                                   Comparator<? super T> comp)
Partitions the [left, right] sub-array about the element at the supplied pivot index.

Returns:
the new (final) location of the pivot.

swap

protected static <T> void swap(T[] a,
                               int idx1,
                               int idx2)
Swaps two elements in an array.