The Mozilla
Organization
Our Mission
Who We Are
Getting Involved
Community
Editorials
What's New
Development
Roadmap
Module Owners
Blue Sky
Projects
Status
Tools
Products
Source Code
Binaries
Documentation
License Terms
Bug Reports
Search
Feedback


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 The Mozilla Organization.