jdsl.core.algo.sorts
Class ArrayMergeSort

java.lang.Object
  |
  +--jdsl.core.algo.sorts.ArrayMergeSort

public class ArrayMergeSort
extends java.lang.Object
implements SortObject


Constructor Summary
ArrayMergeSort()
           
 
Method Summary
 void sort(Sequence S, Comparator c)
          Performs a merge-sort, assuming the Sequence is vector-based.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayMergeSort

public ArrayMergeSort()
Method Detail

sort

public void sort(Sequence S,
                 Comparator c)
Performs a merge-sort, assuming the Sequence is vector-based.

The design of mergesort is somewhat more complex than that of the other sorts: first, there's the main function, mergeSort(.); this is a convenience function that just calls mergeSortHelper(.) with default parameters (a common tactic in recursive algorithms). mergeSortHelper(.) recursively calls itself twice, sorting the first and second halves of the sequence. The two sub-arrays are then merged, yielding a sorted sequence.

Specified by:
sort in interface SortObject
Parameters:
S -  
c -