org.erights.e.elib.tables
Class IndirectCompFunc

java.lang.Object
  |
  +--org.erights.e.elib.tables.IndirectCompFunc
All Implemented Interfaces:
CompFunc

class IndirectCompFunc
extends Object
implements CompFunc

Created with knowledge of an underlying array that must remain stable during the sort (or whatever), and of a comparison function to be applied to elements of that array. Compares two ints according the the comparison of the array elements at those indices.


Field Summary
private  Object myArray
           
private  CompFunc mySubFunc
           
 
Constructor Summary
private IndirectCompFunc(CompFunc subFunc, Object array)
           
 
Method Summary
static Number[] indirectSort(Object array)
          Returns an array of indices sorted according to the elements of array they index into.
static Number[] indirectSort(Object array, CompFunc func)
          Returns an array of indices sorted according to the elements of array they index into.
 double run(Object a, Object b)
          Returns subFunc(array[a], array[b])
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mySubFunc

private final CompFunc mySubFunc

myArray

private final Object myArray
Constructor Detail

IndirectCompFunc

private IndirectCompFunc(CompFunc subFunc,
                         Object array)
Method Detail

run

public double run(Object a,
                  Object b)
Returns subFunc(array[a], array[b])

Specified by:
run in interface CompFunc

indirectSort

public static Number[] indirectSort(Object array)
Returns an array of indices sorted according to the elements of array they index into. This is a permutation. The original array is unchanged.


indirectSort

public static Number[] indirectSort(Object array,
                                    CompFunc func)
Returns an array of indices sorted according to the elements of array they index into. This is a permutation. The original array is unchanged.



comments?