public class InplaceSort extends Object
ints
| Modifier and Type | Class and Description |
|---|---|
static interface |
InplaceSort.Accessor
The sort uses an implementation of this interface to access an array-like
structure.
|
static interface |
InplaceSort.IntComparator
Implementations of this class compare two primitive
ints,
returning the same values as java.util.Comparator. |
| Constructor and Description |
|---|
InplaceSort() |
| Modifier and Type | Method and Description |
|---|---|
static void |
sort(InplaceSort.Accessor acc)
Sorts a collection encapsulated by the provided
InplaceSort.Accessor. |
static void |
sort(int[] array,
InplaceSort.IntComparator comparator)
Sorts a primitive integer array using an external comparator.
|
static void |
sort(int[] array,
int fromIndex,
int toIndex,
InplaceSort.IntComparator comparator)
Sorts a portion of a primitive integer array using an external comparator.
|
static <T extends Comparable<T>> |
sort(List<T> list)
Sorts a list using natural ordering.
|
static <T> void |
sort(List<T> list,
Comparator<T> comparator)
Sorts a list using the provided comparator.
|
static <T extends Comparable<T>> |
sort(List<T> list,
int fromIndex,
int toIndex)
Sorts a portion of a list using natural ordering.
|
static <T> void |
sort(List<T> list,
int fromIndex,
int toIndex,
Comparator<T> comparator)
Sorts a portion of a list using natural ordering.
|
static <T extends Comparable<T>> |
sort(T[] array)
Sorts an object array using natural ordering.
|
static <T> void |
sort(T[] array,
Comparator<T> comparator)
Sorts an object array using the provided comparator.
|
static <T extends Comparable<T>> |
sort(T[] array,
int fromIndex,
int toIndex)
Sorts a portion of an object array using natural ordering.
|
static <T> void |
sort(T[] array,
int fromIndex,
int toIndex,
Comparator<T> comparator)
Sorts a portion of an object array using the provided comparator.
|
public static void sort(int[] array,
InplaceSort.IntComparator comparator)
This functionality is not provided by the JDK.
array - The array to be sortedcomparator - Used to order array elementspublic static void sort(int[] array,
int fromIndex,
int toIndex,
InplaceSort.IntComparator comparator)
This functionality is not provided by the JDK.
array - The array to be sortedfromIndex - The minimum bound of the search (inclusive)toIndex - The maximum bound of the search (exclusive, following
similar usage in the JDK; to sort the end of the array,
pass array.length)comparator - Used to order array elementspublic static <T extends Comparable<T>> void sort(T[] array)
You would use this method in a constrained-memory situation, to avoid creating
the working array used by the JDK's Arrays.sort() (a cost of 4 or
8 bytes per element, depending on JVM).
array - The array to be sortedpublic static <T extends Comparable<T>> void sort(T[] array, int fromIndex, int toIndex)
You would use this method in a constrained-memory situation, to avoid creating
the working array used by the JDK's Arrays.sort() (a cost of 4 or
8 bytes per element, depending on JVM).
array - The array to be sortedfromIndex - The minimum bound of the search (inclusive)toIndex - The maximum bound of the search (exclusive, following
similar usage in the JDK; to sort the end of the array,
pass array.length)public static <T> void sort(T[] array,
Comparator<T> comparator)
You would use this method in a constrained-memory situation, to avoid creating
the working array used by the JDK's Arrays.sort() (a cost of 4 or
8 bytes per element, depending on JVM).
array - The array to be sortedcomparator - Used to order array elementspublic static <T> void sort(T[] array,
int fromIndex,
int toIndex,
Comparator<T> comparator)
You would use this method in a constrained-memory situation, to avoid creating
the working array used by the JDK's Arrays.sort() (a cost of 4 or
8 bytes per element, depending on JVM).
array - The array to be sortedfromIndex - The minimum bound of the search (inclusive)toIndex - The maximum bound of the search (exclusive, following
similar usage in the JDK; to sort the end of the array,
pass array.length)comparator - Used to order array elementspublic static <T extends Comparable<T>> void sort(List<T> list)
You would use this method in a constrained-memory situation, to avoid
creating the working array used by the JDK's Collections.sort()
(a cost of 8 or 16 bytes per element, depending on JVM).
list - The list to be sortedpublic static <T extends Comparable<T>> void sort(List<T> list, int fromIndex, int toIndex)
This method does not have an equivalent in the JDK.
list - The list to be sortedfromIndex - The minimum bound of the search (inclusive)toIndex - The maximum bound of the search (exclusive, following
similar usage in the JDK; to sort the end of the list,
pass list.size())public static <T> void sort(List<T> list, Comparator<T> comparator)
You would use this method in a constrained-memory situation, to avoid
creating the working array used by the JDK's Collections.sort()
(a cost of 8 or 16 bytes per element, depending on JVM).
list - The list to be sortedcomparator - Used to order list elementspublic static <T> void sort(List<T> list, int fromIndex, int toIndex, Comparator<T> comparator)
This method does not have an equivalent in the JDK.
list - The list to be sortedfromIndex - The minimum bound of the search (inclusive)toIndex - The maximum bound of the search (exclusive, following
similar usage in the JDK; to sort the end of the list,
pass list.size())comparator - Used to order list elementspublic static void sort(InplaceSort.Accessor acc)
InplaceSort.Accessor.
This is used to physically sort a collection that is not backed by an array
(eg, a memory-mapped file).
Since the Accessor includes both range and comparator, this
is the only variant of this method.