01: /*
02: * Primitive Collections for Java.
03: * Copyright (C) 2003 Søren Bak
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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ø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++)
58: s[i] = i;
59: break;
60: case 1:
61: for (int i = 0; i < size; i++)
62: s[i] = i + size;
63: break;
64: case 2:
65: for (int i = 0; i < size; i++)
66: s[i] = i + 2 * size;
67: break;
68: default:
69: throw new IllegalArgumentException();
70: }
71: return s;
72: }
73:
74: }
|