eaLib API Docs
Last Modified : January 7 2002

mss.ea.core
Class ArraySort

java.lang.Object
  |
  +--mss.ea.core.ArraySort

public class ArraySort
extends java.lang.Object

Implementation of various sort algorithms for arrays. In the array must be exclusively elements, which implment the interface Comparable. The original code was written by Laurentiu Christofor. Therefor the license agreement of Christorfor is given here.

Copyright (c) 1999 Laurentiu Cristofor

Permission to use, copy, modify, and distribute this software and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and without fee is hereby granted provided that this copyright notice appears in all copies.

I MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. I SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.

Since:
0.1
Version:
0.1 (09-07-00)
Author:
Andreas Rummler / Laurentiu Christofor

Field Summary
protected static int assignCount
          Number of assignments made.
protected static int compareCount
          Number of comparisons done.
 
Constructor Summary
ArraySort()
           
 
Method Summary
static void bubbleSort(java.lang.Object[] list)
          Bubble Sort.
static void bubbleSort(java.lang.Object[] list, boolean reverse)
          Bubble Sort.
static void bubbleSort2(java.lang.Object[] list)
          Bubble Sort according to Sedgewick.
static void bubbleSort2(java.lang.Object[] list, boolean reverse)
          Bubble Sort according to Sedgewick.
protected static void deltaInsertionSort(java.lang.Object[] list, int left, int right, int delta)
          Helper for Shell Sort.
protected static void exchange(java.lang.Object[] list, int indexA, int indexB)
          Exchanges two elements in an array.
static void heapSort(java.lang.Object[] list)
          Heap Sort.
static void heapSort(java.lang.Object[] list, boolean reverse)
          Heap Sort.
static void insertionSort(java.lang.Object[] list)
          Insertion Sort.
static void insertionSort(java.lang.Object[] list, boolean reverse)
          Insertion Sort.
static void resetCounter()
          Sets both counters to 0.
static void result()
          Prints both counters states to System.out.
protected static void reverse(java.lang.Object[] list)
          Reverses an array.
static void selectionSort(java.lang.Object[] list)
          Selection Sort.
static void selectionSort(java.lang.Object[] list, boolean reverse)
          Selection Sort.
static void shellSort(java.lang.Object[] list)
          Shell Sort.
static void shellSort(java.lang.Object[] list, boolean reverse)
          Shell Sort.
protected static void siftDown(java.lang.Object[] list, int i, int n)
          Helper for Heap Sort.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

assignCount

protected static int assignCount
Number of assignments made.

compareCount

protected static int compareCount
Number of comparisons done.
Constructor Detail

ArraySort

public ArraySort()
Method Detail

bubbleSort

public static void bubbleSort(java.lang.Object[] list)
Bubble Sort.
Parameters:
list - array to be sorted.

bubbleSort

public static void bubbleSort(java.lang.Object[] list,
                              boolean reverse)
Bubble Sort.
Parameters:
list - array to be sorted.
reverse - if true, the list will be reversed afterwards

bubbleSort2

public static void bubbleSort2(java.lang.Object[] list)
Bubble Sort according to Sedgewick.
Parameters:
list - array to be sorted.

bubbleSort2

public static void bubbleSort2(java.lang.Object[] list,
                               boolean reverse)
Bubble Sort according to Sedgewick.
Parameters:
list - array to be sorted.
reverse - if true, the list will be reversed afterwards

heapSort

public static void heapSort(java.lang.Object[] list)
Heap Sort.
Parameters:
list - array to be sorted.

heapSort

public static void heapSort(java.lang.Object[] list,
                            boolean reverse)
Heap Sort.
Parameters:
list - array to be sorted.
reverse - if true, the list will be reversed afterwards

siftDown

protected static void siftDown(java.lang.Object[] list,
                               int i,
                               int n)
Helper for Heap Sort.
Parameters:
list -  
i -  
n -  

insertionSort

public static void insertionSort(java.lang.Object[] list)
Insertion Sort.
Parameters:
list - array to be sorted.

insertionSort

public static void insertionSort(java.lang.Object[] list,
                                 boolean reverse)
Insertion Sort.
Parameters:
list - array to be sorted.
reverse - if true, the list will be reversed afterwards

selectionSort

public static void selectionSort(java.lang.Object[] list)
Selection Sort.
Parameters:
list - array to be sorted.

selectionSort

public static void selectionSort(java.lang.Object[] list,
                                 boolean reverse)
Selection Sort.
Parameters:
list - array to be sorted.
reverse - if true, the list will be reversed afterwards

shellSort

public static void shellSort(java.lang.Object[] list)
Shell Sort.
Parameters:
list - array to be sorted.

shellSort

public static void shellSort(java.lang.Object[] list,
                             boolean reverse)
Shell Sort.
Parameters:
list - array to be sorted.
reverse - if true, the list will be reversed afterwards

deltaInsertionSort

protected static void deltaInsertionSort(java.lang.Object[] list,
                                         int left,
                                         int right,
                                         int delta)
Helper for Shell Sort.
Parameters:
list -  
left -  
right -  
delta -  

resetCounter

public static void resetCounter()
Sets both counters to 0.

exchange

protected static void exchange(java.lang.Object[] list,
                               int indexA,
                               int indexB)
Exchanges two elements in an array.
Parameters:
list - array
indexA - index of first element
indexB - index of second element

reverse

protected static void reverse(java.lang.Object[] list)
Reverses an array.
Parameters:
list - array to be reversed

result

public static void result()
Prints both counters states to System.out. This method will probably print incorrect results because the counters are not used consequently.

eaLib API Docs
Last Modified : January 7 2002

Copyright © 2000-2001 Technical University of Ilmenau, Department ESS