com.lucene.util
Class Arrays

java.lang.Object
  |
  +--com.lucene.util.Arrays

public class Arrays
extends Object

This class contains various methods for manipulating arrays (such as sorting and searching). It also contains a static factory that allows arrays to be viewed as Lists.

Since:
JDK1.2
Version:
1.17 03/18/98
Author:
Josh Bloch

Constructor Summary
Arrays()
           
 
Method Summary
static void sort(String[] a)
          Sorts the specified array of objects into ascending order, according to the natural comparison method of its elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Arrays

public Arrays()
Method Detail

sort

public static void sort(String[] a)
Sorts the specified array of objects into ascending order, according to the natural comparison method of its elements. All elements in the array must implement the Comparable interface. Furthermore, all elements in the array must be mutually comparable (that is, e1.compareTo(e2) must not throw a typeMismatchException for any elements e1 and e2 in the array).

This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.

The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.

Parameters:
a - the array to be sorted.
Throws:
ClassCastException - array contains elements that are not mutually comparable (for example, Strings and Integers).
See Also:
Comparable