com.devexperts.util
Class QuickSort

java.lang.Object
  extended by com.devexperts.util.QuickSort

public class QuickSort
extends Object

This class performs Quick Sort algorithm for an array or a 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.


Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sort

public static void sort(Object[] a)
Sorts the specified array in ascending order according to the natural ordering of its elements.

Parameters:
a - the array to be sorted.

sort

public static void sort(Object[] a,
                        Comparator c)
Sorts the specified array according to the order induced by the specified comparator.

Parameters:
a - the array to be sorted.
c - the comparator to determine the order of the array. The 'null' value indicates 'natural ordering'.

sort

public 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. The range to be sorted extends from index from_index, inclusive, to index to_index, exclusive.

Parameters:
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.

sort

public 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. The range to be sorted extends from index from_index, inclusive, to index to_index, exclusive.

Parameters:
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'.

sort

public static void sort(List list)
Sorts the specified list in ascending order according to the natural ordering of its elements.

Parameters:
list - the list to be sorted.

sort

public static void sort(List list,
                        Comparator c)
Sorts the specified list according to the order induced by the specified comparator.

Parameters:
list - the list to be sorted.
c - the comparator to determine the order of the list. The 'null' value indicates 'natural ordering'.

sort

public 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. The range to be sorted extends from index from_index, inclusive, to index to_index, exclusive.

Parameters:
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.

sort

public 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. The range to be sorted extends from index from_index, inclusive, to index to_index, exclusive.

Parameters:
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 © 2013 Devexperts. All Rights Reserved.