The Mozilla
Organization
At A Glance
Feedback
Get Involved
Newsgroups
License Terms
Newsbot
Developer Docs
Roadmap
Projects
Ports
Module Owners
Hacking
Get the Source
Build It
Testing
Download
Bugzilla
Bug Writing
Tools
View Source
Tree Status
New Checkins
Submit A Bug
FAQ
Search
Class calypso.util.QSort
All Packages  This Package  Class Hierarchy  Class Search  Index

Class calypso.util.QSort

java.lang.Object
   |
   +----calypso.util.QSort

Implements QuickSort, on an array of objects. An implementor of `Comparer' is passed in to compare two objects.


public class  QSort
     extends java.lang.Object
{
          // Fields 1
     private Comparer comp;

          // Constructors 1
     public QSort(Comparer);

          // Methods 4
     private int partition(Object[], int, int);
     private void quicksort(Object[], int, int);
     public void sort(Object[]);
     public void sort(Object[], int, int);
}



Fields


comp

   private Comparer comp



Constructors


QSort

   public QSort(Comparer c) 

Create a QSort object. One way to use this would with dynamic class creation:

      QSort sorter = new QSort(new Comparer() {
                                 public int compare(Object a, Object b) {
                                   if (a.key == b.key) return 0;
                                   else if (a.key < b.key) return -1;
                                   else return 1;
                                 }
                               });
      sorter.sort(array);
      




Methods


sort

   public void sort(Object[] list) 

Sorts the array, according to the Comparer.



sort

   public void sort(Object[] list, 
                    int start, 
                    int end) 

Sorts a subsequence of the array, according to the Comparer.



quicksort

   private void quicksort(Object[] list, 
                          int p, 
                          int r) 


partition

   private int partition(Object[] list, 
                         int p, 
                         int r) 


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.4
Copyright © 1998-1999 The Mozilla Organization.
Last modified December 25, 1998.