org.amino.alg.sort
Class DefaultSorter

java.lang.Object
  extended by org.amino.alg.sort.AbstractSorter
      extended by org.amino.alg.sort.DefaultSorter
All Implemented Interfaces:
Sorter
Direct Known Subclasses:
InsertionSorter, QuickSorter

public class DefaultSorter
extends AbstractSorter

This is the simple default sorter class. Lots of room for improving the implementation. Uses the array and list sorting routines. Provides functions to sort by ascending and descending orders.


Constructor Summary
DefaultSorter()
           
 
Method Summary
 void reverse(byte[] a, int from, int to)
          Sort array using reverse natural (descending) order.
 void reverse(char[] a, int from, int to)
          Sort array using reverse natural (descending) order.
 void reverse(double[] a, int from, int to)
          Sort array using reverse natural (descending) order.
 void reverse(float[] a, int from, int to)
          Sort array using reverse natural (descending) order.
 void reverse(int[] a, int from, int to)
          Sort array using reverse natural (descending) order.
<T extends java.lang.Comparable<T>>
void
reverse(java.util.List<T> a, int from, int to)
           
 void reverse(long[] a, int from, int to)
          Sort array using reverse natural (descending) order.
 void reverse(short[] a, int from, int to)
          Sort array using reverse natural (descending) order.
<T extends java.lang.Comparable<T>>
void
reverse(T[] a, int from, int to)
          Sort array using reverse natural (descending) order.
 void sort(byte[] a, int from, int to)
           
 void sort(char[] a, int from, int to)
           
 void sort(double[] a, int from, int to)
           
 void sort(float[] a, int from, int to)
           
 void sort(int[] a, int from, int to)
           
<T extends java.lang.Comparable<T>>
void
sort(java.util.List<T> a)
          
<T extends java.lang.Comparable<T>>
void
sort(java.util.List<T> a, java.util.Comparator<T> c)
          
<T extends java.lang.Comparable<T>>
void
sort(java.util.List<T> a, int from, int to)
           
<T extends java.lang.Comparable<T>>
void
sort(java.util.List<T> a, int from, int to, java.util.Comparator<T> c)
           
 void sort(long[] a, int from, int to)
           
 void sort(short[] a, int from, int to)
           
<T extends java.lang.Comparable<T>>
void
sort(T[] a, int from, int to)
           
<T extends java.lang.Comparable<T>>
void
sort(T[] a, int from, int to, java.util.Comparator<T> c)
           
 void sortp(int[] p, int[] a, int from, int to)
          Sort array and return a permuted index vector.
 
Methods inherited from class org.amino.alg.sort.AbstractSorter
reverse, reverse, reverse, reverse, reverse, reverse, reverse, reverse, reverse, sort, sort, sort, sort, sort, sort, sort, sort, sort, swap, swap, swap, swap, swap, swap, swap, swap, swapIfGreater, swapIfGreater, swapIfGreater, swapIfGreater, swapIfGreater, swapIfGreater, swapIfGreater, swapIfGreater, swapIfLess, swapIfLess, swapIfLess, swapIfLess, swapIfLess, swapIfLess, swapIfLess, swapIfLess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSorter

public DefaultSorter()
Method Detail

reverse

public void reverse(byte[] a,
                    int from,
                    int to)
Description copied from interface: Sorter
Sort array using reverse natural (descending) order.

Parameters:
a - is the byte array to be sorted in a descending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted

reverse

public void reverse(char[] a,
                    int from,
                    int to)
Description copied from interface: Sorter
Sort array using reverse natural (descending) order.

Parameters:
a - is the character array to be sorted in a descending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted

reverse

public void reverse(short[] a,
                    int from,
                    int to)
Description copied from interface: Sorter
Sort array using reverse natural (descending) order.

Parameters:
a - is the short array to be sorted in a descending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted

reverse

public void reverse(int[] a,
                    int from,
                    int to)
Description copied from interface: Sorter
Sort array using reverse natural (descending) order.

Parameters:
a - is the int array to be sorted in a descending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted

reverse

public void reverse(long[] a,
                    int from,
                    int to)
Description copied from interface: Sorter
Sort array using reverse natural (descending) order.

Parameters:
a - is the long array to be sorted in a descending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted

reverse

public void reverse(float[] a,
                    int from,
                    int to)
Description copied from interface: Sorter
Sort array using reverse natural (descending) order.

Parameters:
a - is the float array to be sorted in a descending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted

reverse

public void reverse(double[] a,
                    int from,
                    int to)
Description copied from interface: Sorter
Sort array using reverse natural (descending) order.

Parameters:
a - is the double array to be sorted in a descending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted

reverse

public <T extends java.lang.Comparable<T>> void reverse(T[] a,
                                                        int from,
                                                        int to)
Description copied from interface: Sorter
Sort array using reverse natural (descending) order.

Type Parameters:
T - data type
Parameters:
a - is the array of Comparable objects to be sorted in a descending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted

reverse

public <T extends java.lang.Comparable<T>> void reverse(java.util.List<T> a,
                                                        int from,
                                                        int to)
Type Parameters:
T - data type
Parameters:
a - is the List of Comparable objects to be sorted in a descending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted

sort

public void sort(byte[] a,
                 int from,
                 int to)
Parameters:
a - is the byte array to be sorted in an ascending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted
See Also:
Arrays.sort(byte[], int, int)

sort

public void sort(char[] a,
                 int from,
                 int to)
Parameters:
a - is the character array to be sorted in an ascending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted
See Also:
Arrays.sort(byte[], int, int)

sort

public void sort(short[] a,
                 int from,
                 int to)
Parameters:
a - is the short array to be sorted in an ascending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted
See Also:
Arrays.sort(short[], int, int)

sort

public void sort(int[] a,
                 int from,
                 int to)
Parameters:
a - is the int array to be sorted in an ascending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted
See Also:
Arrays.sort(short[], int, int)

sort

public void sort(long[] a,
                 int from,
                 int to)
Parameters:
a - is the long array to be sorted in an ascending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted
See Also:
Arrays.sort(short[], int, int)

sort

public void sort(float[] a,
                 int from,
                 int to)
Parameters:
a - is the float array to be sorted in an ascending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted
See Also:
Arrays.sort(short[], int, int)

sort

public void sort(double[] a,
                 int from,
                 int to)
Parameters:
a - is the double array to be sorted in an ascending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted
See Also:
Arrays.sort(short[], int, int)

sort

public <T extends java.lang.Comparable<T>> void sort(T[] a,
                                                     int from,
                                                     int to)
Type Parameters:
T - data type
Parameters:
a - is an array of Comparable objects to be sorted in an ascending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted
See Also:
Arrays.sort(Object[], int, int)

sort

public <T extends java.lang.Comparable<T>> void sort(T[] a,
                                                     int from,
                                                     int to,
                                                     java.util.Comparator<T> c)
Type Parameters:
T - data type
Parameters:
a - is an array of Comparable objects to be sorted
c - is the Comparator
from - is the start index of array to be sorted
to - is the end index of array to be sorted
See Also:
Arrays.sort(Object[], int, int, Comparator)

sort

public <T extends java.lang.Comparable<T>> void sort(java.util.List<T> a,
                                                     int from,
                                                     int to)
Type Parameters:
T - data type
Parameters:
a - is a List of Comparable objects to be sorted in an ascending order
from - is the start index of array to be sorted
to - is the end index of array to be sorted
See Also:
Collections.sort(List)

sort

public <T extends java.lang.Comparable<T>> void sort(java.util.List<T> a,
                                                     int from,
                                                     int to,
                                                     java.util.Comparator<T> c)
Type Parameters:
T - data type
Parameters:
a - is a List of Comparable objects to be sorted
c - is the Comparator
from - is the start index of array to be sorted
to - is the end index of array to be sorted
See Also:
Collections.sort(List, Comparator)

sort

public <T extends java.lang.Comparable<T>> void sort(java.util.List<T> a)
Description copied from class: AbstractSorter

Specified by:
sort in interface Sorter
Overrides:
sort in class AbstractSorter
Type Parameters:
T - data type
Parameters:
a - is a List of Comparable objects to be sorted in an ascending order
See Also:
Collections.sort(List)

sort

public <T extends java.lang.Comparable<T>> void sort(java.util.List<T> a,
                                                     java.util.Comparator<T> c)
Description copied from class: AbstractSorter

Specified by:
sort in interface Sorter
Overrides:
sort in class AbstractSorter
Type Parameters:
T - data type
Parameters:
a - is a List of Comparable objects to be sorted
c - is the Comparator
See Also:
Collections.sort(List, Comparator)

sortp

public void sortp(int[] p,
                  int[] a,
                  int from,
                  int to)
Description copied from interface: Sorter
Sort array and return a permuted index vector.

Parameters:
p - is the returned permuted index vector
a - is the array to be sorted, based on which the permuted index vector is generated
from - is the start index
to - is the end index


Copyright © 2008. All Rights Reserved.