eaLib API Docs
Last Modified : January 7 2002

mss.ea.core
Class ListSort

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

public class ListSort
extends java.lang.Object

Implementation of various sort algorithms. The algorithms should work with all data structures implmenting the list interface. The list must contain only elements that implement the comparable interface. The user has to assure this constraint or else a ClassCastException is thrown.
The original code is written by Laurentiu Christofor and was extended for lists. That is the reason the license conditions of Laurentiu are printed 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
Author:
Andreas Rummler / Laurentiu Christofor

Field Summary
protected static int assignCount
          Number of assignments made.
protected static int compareCount
          Number of comparisons made.
 
Constructor Summary
ListSort()
           
 
Method Summary
static void bubbleSort(java.util.List list)
          Bubble sort.
static void bubbleSort2(java.util.List list)
          Bubble sort according to Sedgewick.
protected static void deltaInsertionSort(java.util.List list, int left, int right, int delta)
          Helper for Shell Sort.
protected static void exchange(java.util.List list, int indexA, int indexB)
          Exchanges two list elements.
static void heapSort(java.util.List list)
          Heap Sort.
static void insertionSort(java.util.List list)
          Insertion Sort.
static void printresult()
          Prints both counters to System.out.
static void resetCounter()
          Set both internal counter to zero.
static void selectionSort(java.util.List list)
          Selection Sort.
static void shellSort(java.util.List list)
          Shell Sort.
protected static void siftDown(java.util.List 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 made.
Constructor Detail

ListSort

public ListSort()
Method Detail

bubbleSort

public static void bubbleSort(java.util.List list)
Bubble sort.
Parameters:
list - list to be sorted

bubbleSort2

public static void bubbleSort2(java.util.List list)
Bubble sort according to Sedgewick.
Parameters:
list - list to be sorted

heapSort

public static void heapSort(java.util.List list)
Heap Sort.
Parameters:
list - list to be sorted

siftDown

protected static void siftDown(java.util.List list,
                               int i,
                               int n)
Helper for Heap Sort.
Parameters:
list -  
i -  
n -  

insertionSort

public static void insertionSort(java.util.List list)
Insertion Sort.
Parameters:
list - list to be sorted

selectionSort

public static void selectionSort(java.util.List list)
Selection Sort.
Parameters:
list - list to be sorted

shellSort

public static void shellSort(java.util.List list)
Shell Sort.
Parameters:
list - list to be sorted

deltaInsertionSort

protected static void deltaInsertionSort(java.util.List list,
                                         int left,
                                         int right,
                                         int delta)
Helper for Shell Sort.
Parameters:
list -  
left -  
right -  
delta -  

resetCounter

public static void resetCounter()
Set both internal counter to zero.

exchange

protected static void exchange(java.util.List list,
                               int indexA,
                               int indexB)
Exchanges two list elements.
Parameters:
list - list with elements to be exchanged
indexA - index of the first element
indexB - index of the second element

printresult

public static void printresult()
Prints both counters to System.out.

eaLib API Docs
Last Modified : January 7 2002

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