@@ -6,8 +6,15 @@ class Main { | |||
} | |||
NPunkter17 points = new NPunkter17(Integer.parseInt(args[0])); | |||
Oblig4 seq = new Sequential(points); | |||
Oblig4 par = new Parallel(points); | |||
int[] x = new int[points.n]; | |||
int[] y = new int[points.n]; | |||
System.out.println("Filling..."); | |||
points.fyllArrayer(x, y); | |||
System.out.println("Done."); | |||
Oblig4 seq = new Sequential(x, y, points.n); | |||
Oblig4 par = new Parallel(x, y, points.n); | |||
Timer tseq = run(seq, null); | |||
run(par, tseq); | |||
@@ -17,10 +24,6 @@ class Main { | |||
} | |||
static Timer run(Oblig4 o, Timer base) { | |||
System.out.println(o.name+": filling..."); | |||
o.fill(); | |||
System.out.println("Done."); | |||
Timer t = new Timer().start(); | |||
o.solve(); | |||
t.end(); |
@@ -10,19 +10,13 @@ abstract class Oblig4 { | |||
NPunkter17 points; | |||
String name = "Oblig4"; | |||
Oblig4(NPunkter17 points) { | |||
this.points = points; | |||
n = points.n; | |||
x = new int[n]; | |||
y = new int[n]; | |||
Oblig4(int[] x, int[] y, int n) { | |||
this.x = x; | |||
this.y = y; | |||
this.n = n; | |||
coHull = new IntList(); | |||
} | |||
// Fill x and y arrays | |||
void fill() { | |||
points.fyllArrayer(x, y); | |||
} | |||
// This method should be overwritten by each implementation. | |||
// It's responsible for filling in MAX_X, MAX_Y, and coHull | |||
abstract void solve(); |
@@ -3,8 +3,8 @@ class Parallel extends Oblig4 { | |||
Runtime.getRuntime().availableProcessors(), | |||
16); | |||
Parallel(NPunkter17 points) { | |||
super(points); | |||
Parallel(int[] x, int[] y, int n) { | |||
super(x, y, n); | |||
name = "Parallel"; | |||
} | |||
@@ -1,7 +1,7 @@ | |||
class Sequential extends Oblig4 { | |||
Sequential(NPunkter17 points) { | |||
super(points); | |||
Sequential(int[] x, int[] y, int n) { | |||
super(x, y, n); | |||
name = "Sequential"; | |||
} | |||