test/jdk/java/util/Arrays/java.base/java/util/SortingHelper.java
author bchristi
Tue, 12 Nov 2019 13:49:40 -0800
changeset 59042 8910b995a2ee
permissions -rw-r--r--
8226297: Dual-pivot quicksort improvements Reviewed-by: dl, lbourges Contributed-by: Vladimir Yaroslavskiy <vlv.spb.ru@mail.ru>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59042
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
     1
/*
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
     4
 *
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    10
 *
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    15
 * accompanied this code).
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    16
 *
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    20
 *
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    23
 * questions.
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    24
 */
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    25
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    26
package java.util;
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    27
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    28
/**
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    29
 * This class provides access to package-private
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    30
 * methods of DualPivotQuicksort class.
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    31
 *
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    32
 * @author Vladimir Yaroslavskiy
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    33
 *
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    34
 * @version 2019.09.19
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    35
 *
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    36
 * @since 14
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    37
 */
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    38
public enum SortingHelper {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    39
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    40
    DUAL_PIVOT_QUICKSORT("Dual-Pivot Quicksort") {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    41
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    42
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    43
        public void sort(Object a) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    44
            if (a instanceof int[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    45
                DualPivotQuicksort.sort((int[]) a, SEQUENTIAL, 0, ((int[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    46
            } else if (a instanceof long[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    47
                DualPivotQuicksort.sort((long[]) a, SEQUENTIAL, 0, ((long[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    48
            } else if (a instanceof byte[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    49
                DualPivotQuicksort.sort((byte[]) a, 0, ((byte[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    50
            } else if (a instanceof char[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    51
                DualPivotQuicksort.sort((char[]) a, SEQUENTIAL, 0, ((char[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    52
            } else if (a instanceof short[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    53
                DualPivotQuicksort.sort((short[]) a, SEQUENTIAL, 0, ((short[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    54
            } else if (a instanceof float[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    55
                DualPivotQuicksort.sort((float[]) a, SEQUENTIAL, 0, ((float[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    56
            } else if (a instanceof double[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    57
                DualPivotQuicksort.sort((double[]) a, SEQUENTIAL, 0, ((double[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    58
            } else {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    59
                fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    60
            }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    61
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    62
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    63
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    64
        public void sort(Object a, int low, int high) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    65
            if (a instanceof int[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    66
                DualPivotQuicksort.sort((int[]) a, SEQUENTIAL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    67
            } else if (a instanceof long[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    68
                DualPivotQuicksort.sort((long[]) a, SEQUENTIAL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    69
            } else if (a instanceof byte[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    70
                DualPivotQuicksort.sort((byte[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    71
            } else if (a instanceof char[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    72
                DualPivotQuicksort.sort((char[]) a, SEQUENTIAL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    73
            } else if (a instanceof short[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    74
                DualPivotQuicksort.sort((short[]) a, SEQUENTIAL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    75
            } else if (a instanceof float[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    76
                DualPivotQuicksort.sort((float[]) a, SEQUENTIAL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    77
            } else if (a instanceof double[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    78
                DualPivotQuicksort.sort((double[]) a, SEQUENTIAL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    79
            } else {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    80
                fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    81
            }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    82
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    83
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    84
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    85
        public void sort(Object[] a) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    86
            fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    87
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    88
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    89
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    90
        public void sort(Object[] a, Comparator comparator) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    91
            fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    92
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    93
    },
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    94
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    95
    PARALLEL_SORT("Parallel sort") {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    96
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    97
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    98
        public void sort(Object a) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
    99
            if (a instanceof int[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   100
                DualPivotQuicksort.sort((int[]) a, PARALLEL, 0, ((int[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   101
            } else if (a instanceof long[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   102
                DualPivotQuicksort.sort((long[]) a, PARALLEL, 0, ((long[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   103
            } else if (a instanceof byte[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   104
                DualPivotQuicksort.sort((byte[]) a, 0, ((byte[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   105
            } else if (a instanceof char[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   106
                DualPivotQuicksort.sort((char[]) a, PARALLEL, 0, ((char[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   107
            } else if (a instanceof short[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   108
                DualPivotQuicksort.sort((short[]) a, PARALLEL, 0, ((short[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   109
            } else if (a instanceof float[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   110
                DualPivotQuicksort.sort((float[]) a, PARALLEL, 0, ((float[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   111
            } else if (a instanceof double[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   112
                DualPivotQuicksort.sort((double[]) a, PARALLEL, 0, ((double[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   113
            } else {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   114
                fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   115
            }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   116
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   117
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   118
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   119
        public void sort(Object a, int low, int high) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   120
            if (a instanceof int[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   121
                DualPivotQuicksort.sort((int[]) a, PARALLEL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   122
            } else if (a instanceof long[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   123
                DualPivotQuicksort.sort((long[]) a, PARALLEL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   124
            } else if (a instanceof byte[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   125
                DualPivotQuicksort.sort((byte[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   126
            } else if (a instanceof char[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   127
                DualPivotQuicksort.sort((char[]) a, PARALLEL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   128
            } else if (a instanceof short[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   129
                DualPivotQuicksort.sort((short[]) a, PARALLEL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   130
            } else if (a instanceof float[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   131
                DualPivotQuicksort.sort((float[]) a, PARALLEL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   132
            } else if (a instanceof double[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   133
                DualPivotQuicksort.sort((double[]) a, PARALLEL, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   134
            } else {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   135
                fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   136
            }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   137
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   138
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   139
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   140
        public void sort(Object[] a) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   141
            fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   142
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   143
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   144
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   145
        public void sort(Object[] a, Comparator comparator) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   146
            fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   147
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   148
    },
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   149
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   150
    HEAP_SORT("Heap sort") {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   151
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   152
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   153
        public void sort(Object a) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   154
            if (a instanceof int[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   155
                DualPivotQuicksort.sort(null, (int[]) a, BIG_DEPTH, 0, ((int[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   156
            } else if (a instanceof long[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   157
                DualPivotQuicksort.sort(null, (long[]) a, BIG_DEPTH, 0, ((long[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   158
            } else if (a instanceof byte[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   159
                DualPivotQuicksort.sort((byte[]) a, 0, ((byte[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   160
            } else if (a instanceof char[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   161
                DualPivotQuicksort.sort((char[]) a, BIG_DEPTH, 0, ((char[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   162
            } else if (a instanceof short[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   163
                DualPivotQuicksort.sort((short[]) a, BIG_DEPTH, 0, ((short[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   164
            } else if (a instanceof float[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   165
                DualPivotQuicksort.sort(null, (float[]) a, BIG_DEPTH, 0, ((float[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   166
            } else if (a instanceof double[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   167
                DualPivotQuicksort.sort(null, (double[]) a, BIG_DEPTH, 0, ((double[]) a).length);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   168
            } else {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   169
                fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   170
            }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   171
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   172
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   173
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   174
        public void sort(Object a, int low, int high) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   175
            if (a instanceof int[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   176
                DualPivotQuicksort.sort(null, (int[]) a, BIG_DEPTH, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   177
            } else if (a instanceof long[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   178
                DualPivotQuicksort.sort(null, (long[]) a, BIG_DEPTH, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   179
            } else if (a instanceof byte[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   180
                DualPivotQuicksort.sort((byte[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   181
            } else if (a instanceof char[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   182
                DualPivotQuicksort.sort((char[]) a, BIG_DEPTH, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   183
            } else if (a instanceof short[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   184
                DualPivotQuicksort.sort((short[]) a, BIG_DEPTH, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   185
            } else if (a instanceof float[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   186
                DualPivotQuicksort.sort(null, (float[]) a, BIG_DEPTH, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   187
            } else if (a instanceof double[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   188
                DualPivotQuicksort.sort(null, (double[]) a, BIG_DEPTH, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   189
            } else {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   190
                fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   191
            }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   192
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   193
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   194
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   195
        public void sort(Object[] a) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   196
            fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   197
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   198
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   199
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   200
        public void sort(Object[] a, Comparator comparator) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   201
            fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   202
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   203
    },
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   204
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   205
    ARRAYS_SORT("Arrays.sort") {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   206
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   207
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   208
        public void sort(Object a) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   209
            if (a instanceof int[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   210
                Arrays.sort((int[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   211
            } else if (a instanceof long[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   212
                Arrays.sort((long[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   213
            } else if (a instanceof byte[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   214
                Arrays.sort((byte[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   215
            } else if (a instanceof char[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   216
                Arrays.sort((char[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   217
            } else if (a instanceof short[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   218
                Arrays.sort((short[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   219
            } else if (a instanceof float[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   220
                Arrays.sort((float[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   221
            } else if (a instanceof double[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   222
                Arrays.sort((double[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   223
            } else {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   224
                fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   225
            }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   226
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   227
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   228
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   229
        public void sort(Object a, int low, int high) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   230
            if (a instanceof int[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   231
                Arrays.sort((int[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   232
            } else if (a instanceof long[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   233
                Arrays.sort((long[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   234
            } else if (a instanceof byte[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   235
                Arrays.sort((byte[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   236
            } else if (a instanceof char[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   237
                Arrays.sort((char[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   238
            } else if (a instanceof short[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   239
                Arrays.sort((short[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   240
            } else if (a instanceof float[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   241
                Arrays.sort((float[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   242
            } else if (a instanceof double[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   243
                Arrays.sort((double[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   244
            } else {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   245
                fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   246
            }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   247
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   248
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   249
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   250
        public void sort(Object[] a) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   251
            Arrays.sort(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   252
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   253
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   254
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   255
        @SuppressWarnings("unchecked")
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   256
        public void sort(Object[] a, Comparator comparator) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   257
            Arrays.sort(a, comparator);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   258
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   259
    },
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   260
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   261
    ARRAYS_PARALLEL_SORT("Arrays.parallelSort") {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   262
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   263
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   264
        public void sort(Object a) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   265
            if (a instanceof int[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   266
                Arrays.parallelSort((int[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   267
            } else if (a instanceof long[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   268
                Arrays.parallelSort((long[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   269
            } else if (a instanceof byte[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   270
                Arrays.parallelSort((byte[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   271
            } else if (a instanceof char[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   272
                Arrays.parallelSort((char[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   273
            } else if (a instanceof short[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   274
                Arrays.parallelSort((short[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   275
            } else if (a instanceof float[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   276
                Arrays.parallelSort((float[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   277
            } else if (a instanceof double[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   278
                Arrays.parallelSort((double[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   279
            } else {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   280
                fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   281
            }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   282
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   283
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   284
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   285
        public void sort(Object a, int low, int high) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   286
            if (a instanceof int[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   287
                Arrays.parallelSort((int[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   288
            } else if (a instanceof long[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   289
                Arrays.parallelSort((long[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   290
            } else if (a instanceof byte[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   291
                Arrays.parallelSort((byte[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   292
            } else if (a instanceof char[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   293
                Arrays.parallelSort((char[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   294
            } else if (a instanceof short[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   295
                Arrays.parallelSort((short[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   296
            } else if (a instanceof float[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   297
                Arrays.parallelSort((float[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   298
            } else if (a instanceof double[]) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   299
                Arrays.parallelSort((double[]) a, low, high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   300
            } else {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   301
                fail(a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   302
            }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   303
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   304
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   305
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   306
        @SuppressWarnings("unchecked")
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   307
        public void sort(Object[] a) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   308
            Arrays.parallelSort((Comparable[]) a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   309
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   310
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   311
        @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   312
        @SuppressWarnings("unchecked")
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   313
        public void sort(Object[] a, Comparator comparator) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   314
            Arrays.parallelSort(a, comparator);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   315
        }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   316
    };
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   317
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   318
    abstract public void sort(Object a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   319
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   320
    abstract public void sort(Object a, int low, int high);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   321
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   322
    abstract public void sort(Object[] a);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   323
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   324
    abstract public void sort(Object[] a, Comparator comparator);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   325
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   326
    private SortingHelper(String name) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   327
        this.name = name;
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   328
    }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   329
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   330
    @Override
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   331
    public String toString() {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   332
        return name;
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   333
    }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   334
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   335
    private static void fail(Object a) {
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   336
        throw new RuntimeException("Unexpected type of array: " + a.getClass().getName());
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   337
    }
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   338
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   339
    private String name;
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   340
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   341
    /**
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   342
     * Parallelism level for sequential and parallel sorting.
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   343
     */
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   344
    private static final int SEQUENTIAL = 0;
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   345
    private static final int PARALLEL = 87;
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   346
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   347
    /**
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   348
     * Heap sort will be invoked, if recursion depth is too big.
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   349
     * Value is taken from DualPivotQuicksort.MAX_RECURSION_DEPTH.
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   350
     */
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   351
    private static final int BIG_DEPTH = 64 * (3 << 1);
8910b995a2ee 8226297: Dual-pivot quicksort improvements
bchristi
parents:
diff changeset
   352
}