Save This Page
Home » mahout-collections-1.0-src » org.apache.mahout.math » [javadoc | source]
org.apache.mahout.math
public final class: Sorting [javadoc | source]
java.lang.Object
   org.apache.mahout.math.Sorting
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Field Summary
static final  int SMALL     
Method from org.apache.mahout.math.Sorting Summary:
binarySearchFromTo,   binarySearchFromTo,   binarySearchFromTo,   binarySearchFromTo,   binarySearchFromTo,   binarySearchFromTo,   binarySearchFromTo,   binarySearchFromTo,   binarySearchFromTo,   inplace_merge,   lower_bound,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   mergeSort,   quickSort,   quickSort,   quickSort,   quickSort,   quickSort,   quickSort,   quickSort,   quickSort,   quickSort,   quickSort,   upper_bound
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.mahout.math.Sorting Detail:
 public static int binarySearchFromTo(byte[] array,
    byte value,
    int from,
    int to) 
    Performs a binary search for the specified element in the specified ascending sorted array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.
 public static int binarySearchFromTo(char[] array,
    char value,
    int from,
    int to) 
    Performs a binary search for the specified element in the specified ascending sorted array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.
 public static int binarySearchFromTo(double[] array,
    double value,
    int from,
    int to) 
    Performs a binary search for the specified element in the specified ascending sorted array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.
 public static int binarySearchFromTo(float[] array,
    float value,
    int from,
    int to) 
    Performs a binary search for the specified element in the specified ascending sorted array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.
 public static int binarySearchFromTo(int[] array,
    int value,
    int from,
    int to) 
    Performs a binary search for the specified element in the specified ascending sorted array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.
 public static int binarySearchFromTo(long[] array,
    long value,
    int from,
    int to) 
    Performs a binary search for the specified element in the specified ascending sorted array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.
 public static int binarySearchFromTo(T[] array,
    T object,
    int from,
    int to) 
    Performs a binary search for the specified element in the specified ascending sorted array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.
 public static int binarySearchFromTo(short[] array,
    short value,
    int from,
    int to) 
    Performs a binary search for the specified element in the specified ascending sorted array. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.
 public static int binarySearchFromTo(T[] array,
    T object,
    int from,
    int to,
    Comparator<? super T> comparator) 
    Performs a binary search for the specified element in the specified ascending sorted array using the {@code Comparator} to compare elements. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.
 static  void inplace_merge(int first,
    int middle,
    int last,
    IntComparator comp,
    Swapper swapper) 
    Transforms two consecutive sorted ranges into a single sorted range. The initial ranges are [first, middle) and [middle, last), and the resulting range is [first, last). Elements in the first input range will precede equal elements in the second.
 static int lower_bound(int first,
    int last,
    int x,
    IntComparator comp) 
    Performs a binary search on an already-sorted range: finds the first position where an element can be inserted without violating the ordering. Sorting is by a user-supplied comparison function.
 public static  void mergeSort(T[] array,
    int start,
    int end) 
    Perform a merge sort of the specific range of an array of objects that implement Comparable.
 public static  void mergeSort(byte[] array,
    int start,
    int end) 
    Perform a merge sort on a range of a byte array, using numerical order.
 public static  void mergeSort(char[] array,
    int start,
    int end) 
    Perform a merge sort on a range of a char array, using numerical order.
 public static  void mergeSort(short[] array,
    int start,
    int end) 
    Perform a merge sort on a range of a short array, using numerical order.
 public static  void mergeSort(int[] array,
    int start,
    int end) 
 public static  void mergeSort(long[] array,
    int start,
    int end) 
    Perform a merge sort on a range of a long array using numerical order.
 public static  void mergeSort(float[] array,
    int start,
    int end) 
    Perform a merge sort on a range of a float array using Float.compare for an ordering.
 public static  void mergeSort(double[] array,
    int start,
    int end) 
    Perform a merge sort on a range of a double array using a Double.compare as an ordering.
 public static  void mergeSort(T[] array,
    int start,
    int end,
    Comparator<T> comp) 
    Perform a merge sort on the specified range of an array.
 public static  void mergeSort(byte[] array,
    int start,
    int end,
    ByteComparator comp) 
    Perform a merge sort on a range of a byte array using a specified ordering.
 public static  void mergeSort(char[] array,
    int start,
    int end,
    CharComparator comp) 
    Perform a merge sort on a range of a char array using a specified ordering.
 public static  void mergeSort(short[] array,
    int start,
    int end,
    ShortComparator comp) 
 public static  void mergeSort(int[] array,
    int start,
    int end,
    IntComparator comp) 
    Perform a merge sort on a range of a int array using numerical order.
 public static  void mergeSort(long[] array,
    int start,
    int end,
    LongComparator comp) 
    Perform a merge sort on a range of a long array using a specified ordering.
 public static  void mergeSort(float[] array,
    int start,
    int end,
    FloatComparator comp) 
    Perform a merge sort on a range of a float array using a specified ordering.
 public static  void mergeSort(double[] array,
    int start,
    int end,
    DoubleComparator comp) 
    Perform a merge sort on a range of a double array using a specified ordering.
 public static  void mergeSort(int fromIndex,
    int toIndex,
    IntComparator c,
    Swapper swapper) 
    Sorts the specified range of elements according to the order induced by the specified comparator. All elements in the range must be mutually comparable by the specified comparator (that is, c.compare(a, b) must not throw an exception for any indexes a and b in the range).

    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.

 public static  void quickSort(T[] array,
    int start,
    int end) 
    Sort the specified range of an array of object that implement the Comparable interface.
 public static  void quickSort(byte[] array,
    int start,
    int end,
    ByteComparator comp) 
    Sorts the specified range in the array in a specified order.
 public static  void quickSort(int start,
    int end,
    IntComparator comp,
    Swapper swap) 
    Sorts some external data with QuickSort.
 public static  void quickSort(char[] array,
    int start,
    int end,
    CharComparator comp) 
    Sorts the specified range in the array in a specified order.
 public static  void quickSort(double[] array,
    int start,
    int end,
    DoubleComparator comp) 
    Sorts the specified range in the array in a specified order.
 public static  void quickSort(float[] array,
    int start,
    int end,
    FloatComparator comp) 
    Sorts the specified range in the array in a specified order.
 public static  void quickSort(int[] array,
    int start,
    int end,
    IntComparator comp) 
    Sorts the specified range in the array in a specified order.
 public static  void quickSort(long[] array,
    int start,
    int end,
    LongComparator comp) 
    Sorts the specified range in the array in a specified order.
 public static  void quickSort(T[] array,
    int start,
    int end,
    Comparator<T> comp) 
    Sorts the specified range in the array in a specified order.
 public static  void quickSort(short[] array,
    int start,
    int end,
    ShortComparator comp) 
    Sorts the specified range in the array in ascending numerical order.
 static int upper_bound(int first,
    int last,
    int x,
    IntComparator comp) 
    Performs a binary search on an already-sorted range: finds the last position where an element can be inserted without violating the ordering. Sorting is by a user-supplied comparison function.