Class BucketSort


  • final class BucketSort
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      BucketSort()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private int getBucket​(double value)
      Adds new element to the bucket builder.
      private int getBucketCount()
      Returns the bucket count.
      private boolean reset​(int bucket_count, double min_value, double max_value, int capacity)
      Clears and resets Bucket_sort to the new state, preparing for the accumulation of new data.
      void sort​(AttributeStreamOfInt32 indices, int begin, int end, ClassicSort sorter)
      Executes sort on the Bucket_sort.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BucketSort

        public BucketSort()
    • Method Detail

      • sort

        public void sort​(AttributeStreamOfInt32 indices,
                         int begin,
                         int end,
                         ClassicSort sorter)
        Executes sort on the Bucket_sort. The result is fed into the indices array in the range between begin (inclusive) and end (exclusive). Uses user supplied sorter to execute sort on each bucket. Users either supply the sorter and use this method of Bucket_sort class, or use other methods to form the buckets and take care of bucket sorting themselves.
      • reset

        private boolean reset​(int bucket_count,
                              double min_value,
                              double max_value,
                              int capacity)
        Clears and resets Bucket_sort to the new state, preparing for the accumulation of new data.
        Parameters:
        bucket_count - - the number of buckets. Usually equal to the number of elements to sort.
        min_value - - the minimum value of elements to sort.
        max_value - - the maximum value of elements to sort.
        capacity - - the number of elements to sort (-1 if not known). The bucket_count are usually equal.
        Returns:
        Returns False, if the bucket sort cannot be used with the given parameters. The method also can throw out of memory exception. In the later case, one should fall back to the regular sort.
      • getBucket

        private int getBucket​(double value)
        Adds new element to the bucket builder. The value must be between min_value and max_value.
        Parameters:
        The - value used for bucketing.
        The - index of the element to store in the buffer. Usually it is an index into some array, where the real elements are stored.
      • getBucketCount

        private int getBucketCount()
        Returns the bucket count.