ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/jtreg/util/TimSort/Sorter.java
Revision: 1.3
Committed: Tue Jan 22 20:31:05 2013 UTC (11 years, 3 months ago) by jsr166
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -1 lines
Log Message:
whitespace

File Contents

# Content
1 /*
2 * Copyright 2009 Google Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.util.*;
25
26 public enum Sorter {
27 TIMSORT {
28 public void sort(Object[] array) {
29 ComparableTimSort.sort(array);
30 }
31 },
32 MERGESORT {
33 public void sort(Object[] array) {
34 Arrays.sort(array);
35 }
36 };
37
38 public abstract void sort(Object[] array);
39
40 public static void warmup() {
41 System.out.println("start warm up");
42 Integer[] gold = new Integer[10000];
43 Random random = new java.util.Random();
44 for (int i=0; i < gold.length; i++)
45 gold[i] = random.nextInt();
46
47 for (int i=0; i < 10000; i++) {
48 for (Sorter s : values()) {
49 Integer[] test = gold.clone();
50 s.sort(test);
51 }
52 }
53 System.out.println(" end warm up");
54 }
55 }