KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > bak > pcj > benchmark > DataSetOrderedCompact


1 /*
2  * Primitive Collections for Java.
3  * Copyright (C) 2003 Søren Bak
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package bak.pcj.benchmark;
20
21 import bak.pcj.list.IntList;
22
23 /**
24  * This class represents a standard data set for benchmarks.
25  * The data set contains three disjoint lists each containing
26  * a range of consecutive int values in order:
27  * <pre>
28  * [0 - (size-1)]
29  * [(size) - (2*size-1)]
30  * [(2*size) - (3*size-1)]
31  * <pre>
32  *
33  * @author S&oslash;ren Bak
34  * @version 1.0 2003/5/1
35  * @since 1.0
36  */

37 public class DataSetOrderedCompact extends DataSet {
38
39     /**
40      * Creates a new ordered compact data set of a specified
41      * size.
42      *
43      * @param size
44      * the size of the data set to create.
45      *
46      * @throws IllegalArgumentException
47      * if <tt>size</tt> is not positive.
48      */

49     public DataSetOrderedCompact(int size) {
50         super("Ordered/Compact/"+size, size);
51     }
52
53     protected int[] createList(int n, int size) {
54         int[] s = new int[size];
55         switch (n) {
56         case 0:
57             for (int i = 0; i < size; i++) s[i] = i;
58             break;
59         case 1:
60             for (int i = 0; i < size; i++) s[i] = i+size;
61             break;
62         case 2:
63             for (int i = 0; i < size; i++) s[i] = i+2*size;
64             break;
65         default:
66             throw new IllegalArgumentException JavaDoc();
67         }
68         return s;
69     }
70
71 }
Popular Tags