edu.colorado.cs.ns2.util
Class SortTimeLine

java.lang.Object
  extended by edu.colorado.cs.ns2.util.SortTimeLine

public class SortTimeLine
extends java.lang.Object

This class implements the Quicksort algorithm for sorting the discrete event timeline.

Author:
Kevin Bauer, Pushkar Sambhoos.

Constructor Summary
SortTimeLine()
           
 
Method Summary
private static int partition(java.util.Vector<TimeLine> timeLine, int l, int r)
          The quicksort partition method.
static void quicksort(java.util.Vector<TimeLine> timeLine)
          Quick sort helper method.
private static void quicksort(java.util.Vector<TimeLine> timeLine, int l, int r)
          Recursive quicksort routine uses divide and conquer approach to quickly sort two halves of the Vector.
private static void swap(java.util.Vector<TimeLine> timeLine, int element1, int element2)
          Swap two elements of the vector, timeLine[e1] & timeLine[e2].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortTimeLine

public SortTimeLine()
Method Detail

swap

private static void swap(java.util.Vector<TimeLine> timeLine,
                         int element1,
                         int element2)
Swap two elements of the vector, timeLine[e1] & timeLine[e2].

Parameters:
timeLine - The timeline.
element1 - The index of element 1.
element2 - The index of element 2.

quicksort

public static void quicksort(java.util.Vector<TimeLine> timeLine)
Quick sort helper method.

Parameters:
timeLine -

quicksort

private static void quicksort(java.util.Vector<TimeLine> timeLine,
                              int l,
                              int r)
Recursive quicksort routine uses divide and conquer approach to quickly sort two halves of the Vector.

Parameters:
timeLine - The timeline Vector.
l - The left index.
r - The right index.

partition

private static int partition(java.util.Vector<TimeLine> timeLine,
                             int l,
                             int r)
The quicksort partition method.

Parameters:
timeLine - The timeline Vector.
l - The left index.
r - The right index.
Returns:
The partition index.