/** * Sorts the specified range of the receiver into ascending order. * * The sorting algorithm is countsort. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). */ public void sortFromTo(int from, int to) { // try to figure out which option is fastest. double N = to - from + 1; double quickSortEstimate = N * Math.log(N)/0.6931471805599453; // O(N*log(N,base=2)) ; ln(2)=0.6931471805599453 double width = 256; double countSortEstimate = Math.max(width,N); // O(Max(width,N)) if (countSortEstimate < quickSortEstimate) { countSortFromTo(from, to); } else { quickSortFromTo(from, to); } } /**
/** * Sorts the specified range of the receiver into ascending order. * * The sorting algorithm is countsort. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). */ public void sortFromTo(int from, int to) { // try to figure out which option is fastest. double N = to - from + 1; double quickSortEstimate = N * Math.log(N)/0.6931471805599453; // O(N*log(N,base=2)) ; ln(2)=0.6931471805599453 double width = 256; double countSortEstimate = Math.max(width,N); // O(Max(width,N)) if (countSortEstimate < quickSortEstimate) { countSortFromTo(from, to); } else { quickSortFromTo(from, to); } } /**
/** * Sorts the specified range of the receiver into ascending order. * * The sorting algorithm is countsort. * * @param from * the index of the first element (inclusive) to be sorted. * @param to * the index of the last element (inclusive) to be sorted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void sortFromTo(int from, int to) { // try to figure out which option is fastest. double N = to - from + 1; double quickSortEstimate = N * Math.log(N) / 0.6931471805599453; // O(N*log(N,base=2)) // ; // ln(2)=0.6931471805599453 double width = 256; double countSortEstimate = Math.max(width, N); // O(Max(width,N)) if (countSortEstimate < quickSortEstimate) { countSortFromTo(from, to); } else { quickSortFromTo(from, to); } }