1 /* =============================================================================
5 * =============================================================================
7 * For the license of ssca2, please see ssca2/COPYRIGHT
9 * ------------------------------------------------------------------------
10 * Unless otherwise noted, the following license applies to STAMP files:
12 * Copyright (c) 2007, Stanford University
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are
19 * * Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
22 * * Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in
24 * the documentation and/or other materials provided with the
27 * * Neither the name of Stanford University nor the names of its
28 * contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
31 * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
32 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
41 * THE POSSIBILITY OF SUCH DAMAGE.
43 * =============================================================================
46 public class CreatePartition {
47 public CreatePartition() {
50 /* =============================================================================
52 * =============================================================================
55 createPartition (int min, int max, int id, int n, LocalStartStop lss)
57 int range = max - min;
58 int chunk = MAX(1, ((range + n/2) / n)); /* rounded */
59 int start = min + chunk * id;
64 stop = MIN(max, (start + chunk));
71 public static int MAX(int a, int b) {
72 int val = (a > b) ? (a) : (b);
76 public static int MIN(int a, int b) {
77 int val = (a < b) ? (a) : (b);
81 /* =============================================================================
83 * End of createPartition.java
85 * =============================================================================