public class QuickSort extends Object
List
of objects.
This class differs from sorting algorithms provided by the Arrays
and the Collections
classes:
Note: because this class does not allocate any temporary arrays, it uses indexed access
to the specified List
. Therefore it is important that specified List
has
efficient implementations of indexed 'get' and 'set' operations.
Modifier and Type | Method and Description |
---|---|
static void |
sort(List list)
Sorts the specified list in ascending order according to the natural ordering of its elements.
|
static void |
sort(List list,
Comparator c)
Sorts the specified list according to the order induced by the specified comparator.
|
static void |
sort(List list,
int from_index,
int to_index)
Sorts the specified range of the specified list in ascending order according to the natural ordering of its elements.
|
static void |
sort(List list,
int from_index,
int to_index,
Comparator c)
Sorts the specified range of the specified list according to the order induced by the specified comparator.
|
static void |
sort(Object[] a)
Sorts the specified array in ascending order according to the natural ordering of its elements.
|
static void |
sort(Object[] a,
Comparator c)
Sorts the specified array according to the order induced by the specified comparator.
|
static void |
sort(Object[] a,
int from_index,
int to_index)
Sorts the specified range of the specified array in ascending order according to the natural ordering of its elements.
|
static void |
sort(Object[] a,
int from_index,
int to_index,
Comparator c)
Sorts the specified range of the specified array according to the order induced by the specified comparator.
|
public static void sort(Object[] a)
a
- the array to be sorted.public static void sort(Object[] a, Comparator c)
a
- the array to be sorted.c
- the comparator to determine the order of the array. The 'null' value indicates 'natural ordering'.public static void sort(Object[] a, int from_index, int to_index)
a
- the array to be sorted.from_index
- the index of the first element (inclusive) to be sorted.to_index
- the index of the last element (exclusive) to be sorted.public static void sort(Object[] a, int from_index, int to_index, Comparator c)
a
- the array to be sorted.from_index
- the index of the first element (inclusive) to be sorted.to_index
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array. The 'null' value indicates 'natural ordering'.public static void sort(List list)
list
- the list to be sorted.public static void sort(List list, Comparator c)
list
- the list to be sorted.c
- the comparator to determine the order of the list. The 'null' value indicates 'natural ordering'.public static void sort(List list, int from_index, int to_index)
list
- the list to be sorted.from_index
- the index of the first element (inclusive) to be sorted.to_index
- the index of the last element (exclusive) to be sorted.public static void sort(List list, int from_index, int to_index, Comparator c)
list
- the list to be sorted.from_index
- the index of the first element (inclusive) to be sorted.to_index
- the index of the last element (exclusive) to be sorted.c
- the comparator to determine the order of the array. The 'null' value indicates 'natural ordering'.Copyright © 2014 Devexperts. All Rights Reserved.