jdk/src/share/classes/java/util/Arrays.java
changeset 6896 d229d56fd918
parent 5506 202f599c92aa
child 7668 d4a77089c587
child 7803 56bc97d69d93
equal deleted inserted replaced
6895:92894a4882e0 6896:d229d56fd918
    95      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
    95      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
    96      * @throws ArrayIndexOutOfBoundsException
    96      * @throws ArrayIndexOutOfBoundsException
    97      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
    97      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
    98      */
    98      */
    99     public static void sort(int[] a, int fromIndex, int toIndex) {
    99     public static void sort(int[] a, int fromIndex, int toIndex) {
   100         DualPivotQuicksort.sort(a, fromIndex, toIndex);
   100         rangeCheck(a.length, fromIndex, toIndex);
       
   101         DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
   101     }
   102     }
   102 
   103 
   103     /**
   104     /**
   104      * Sorts the specified array into ascending numerical order.
   105      * Sorts the specified array into ascending numerical order.
   105      *
   106      *
   134      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   135      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   135      * @throws ArrayIndexOutOfBoundsException
   136      * @throws ArrayIndexOutOfBoundsException
   136      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   137      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   137      */
   138      */
   138     public static void sort(long[] a, int fromIndex, int toIndex) {
   139     public static void sort(long[] a, int fromIndex, int toIndex) {
   139         DualPivotQuicksort.sort(a, fromIndex, toIndex);
   140         rangeCheck(a.length, fromIndex, toIndex);
       
   141         DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
   140     }
   142     }
   141 
   143 
   142     /**
   144     /**
   143      * Sorts the specified array into ascending numerical order.
   145      * Sorts the specified array into ascending numerical order.
   144      *
   146      *
   173      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   175      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   174      * @throws ArrayIndexOutOfBoundsException
   176      * @throws ArrayIndexOutOfBoundsException
   175      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   177      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   176      */
   178      */
   177     public static void sort(short[] a, int fromIndex, int toIndex) {
   179     public static void sort(short[] a, int fromIndex, int toIndex) {
   178         DualPivotQuicksort.sort(a, fromIndex, toIndex);
   180         rangeCheck(a.length, fromIndex, toIndex);
       
   181         DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
   179     }
   182     }
   180 
   183 
   181     /**
   184     /**
   182      * Sorts the specified array into ascending numerical order.
   185      * Sorts the specified array into ascending numerical order.
   183      *
   186      *
   212      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   215      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   213      * @throws ArrayIndexOutOfBoundsException
   216      * @throws ArrayIndexOutOfBoundsException
   214      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   217      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   215      */
   218      */
   216     public static void sort(char[] a, int fromIndex, int toIndex) {
   219     public static void sort(char[] a, int fromIndex, int toIndex) {
   217         DualPivotQuicksort.sort(a, fromIndex, toIndex);
   220         rangeCheck(a.length, fromIndex, toIndex);
       
   221         DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
   218     }
   222     }
   219 
   223 
   220     /**
   224     /**
   221      * Sorts the specified array into ascending numerical order.
   225      * Sorts the specified array into ascending numerical order.
   222      *
   226      *
   251      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   255      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   252      * @throws ArrayIndexOutOfBoundsException
   256      * @throws ArrayIndexOutOfBoundsException
   253      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   257      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   254      */
   258      */
   255     public static void sort(byte[] a, int fromIndex, int toIndex) {
   259     public static void sort(byte[] a, int fromIndex, int toIndex) {
   256         DualPivotQuicksort.sort(a, fromIndex, toIndex);
   260         rangeCheck(a.length, fromIndex, toIndex);
       
   261         DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
   257     }
   262     }
   258 
   263 
   259     /**
   264     /**
   260      * Sorts the specified array into ascending numerical order.
   265      * Sorts the specified array into ascending numerical order.
   261      *
   266      *
   306      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   311      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   307      * @throws ArrayIndexOutOfBoundsException
   312      * @throws ArrayIndexOutOfBoundsException
   308      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   313      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   309      */
   314      */
   310     public static void sort(float[] a, int fromIndex, int toIndex) {
   315     public static void sort(float[] a, int fromIndex, int toIndex) {
   311         DualPivotQuicksort.sort(a, fromIndex, toIndex);
   316         rangeCheck(a.length, fromIndex, toIndex);
       
   317         DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
   312     }
   318     }
   313 
   319 
   314     /**
   320     /**
   315      * Sorts the specified array into ascending numerical order.
   321      * Sorts the specified array into ascending numerical order.
   316      *
   322      *
   361      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   367      * @throws IllegalArgumentException if {@code fromIndex > toIndex}
   362      * @throws ArrayIndexOutOfBoundsException
   368      * @throws ArrayIndexOutOfBoundsException
   363      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   369      *     if {@code fromIndex < 0} or {@code toIndex > a.length}
   364      */
   370      */
   365     public static void sort(double[] a, int fromIndex, int toIndex) {
   371     public static void sort(double[] a, int fromIndex, int toIndex) {
   366         DualPivotQuicksort.sort(a, fromIndex, toIndex);
   372         rangeCheck(a.length, fromIndex, toIndex);
       
   373         DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
   367     }
   374     }
   368 
   375 
   369     /*
   376     /*
   370      * Sorting of complex type arrays.
   377      * Sorting of complex type arrays.
   371      *
       
   372      */
   378      */
   373 
   379 
   374     /**
   380     /**
   375      * Old merge sort implementation can be selected (for
   381      * Old merge sort implementation can be selected (for
   376      * compatibility with broken comparators) using a system property.
   382      * compatibility with broken comparators) using a system property.