edu.stanford.math.plex
public abstract static class PlexSort.Comp extends java.lang.Object
Comp inner class are used as comparison
closures for the sorting routine comp_sort. In addition
to the obvious uses, such as sorting in decreasing order, using
closures allows us to sort arrays of points by increasing or
decreasing density (or any other real-valued function on the points).
There are also some slightly non-obvious applications, which we
probably won't use here, such a computing the inverse of a permutation
stored in an array p[]. If p is [1,2,0] -- that is, the permutation
mapping 0->1, 1->2, 2->0, then let x = [0,1,2], and sort the entries
of x[i] so that x[i] is less than x[j] iff p[x[i]] < p[x[j]]. Then the
sorted contents of x are [2,0,1]. This is the inverse of p[].| Constructor and Description |
|---|
PlexSort.Comp() |
| Modifier and Type | Method and Description |
|---|---|
abstract int |
fn(int i,
int j)
Compare two int arguments, and return an integer less than, equal
to, or greater than 0, depending on whether i is respectively less,
equivalent, or greater than, j.
|
public abstract int fn(int i,
int j)
i - The first argument.j - The second argument.