projects
/
IRC.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
709fcfa
)
this little example only parallelizes for oooj with defreach
author
jjenista
<jjenista>
Fri, 6 Jan 2012 23:41:12 +0000
(23:41 +0000)
committer
jjenista
<jjenista>
Fri, 6 Jan 2012 23:41:12 +0000
(23:41 +0000)
Robust/src/Tests/disjoint/definite-example/test.java
patch
|
blob
|
history
diff --git
a/Robust/src/Tests/disjoint/definite-example/test.java
b/Robust/src/Tests/disjoint/definite-example/test.java
index b93eed253362ff481a6c04469d6b2e7bede7d217..ca619c0a147c300eedc074f07f04dbb356e02fdc 100644
(file)
--- a/
Robust/src/Tests/disjoint/definite-example/test.java
+++ b/
Robust/src/Tests/disjoint/definite-example/test.java
@@
-1,63
+1,79
@@
-public class Foo {
+public class Tree {
+ Node root;
+}
+
+public class Node {
int z;
int z;
+ Node left;
+ Node right;
+ Node() {
+ z = 1;
+ left = null;
+ right = null;
+ }
}
}
+
public class Test {
static public void main( String args[] ) {
public class Test {
static public void main( String args[] ) {
- int m = 2;
int n = 3;
int n = 3;
-
- Foo[] a;
- Foo b;
-
- Foo[][] top = new Foo[m][];
- for( int i = 0; i < m; ++i ) {
- a = getArray( n );
- for( int j = 0; j < n; ++j ) {
- b = getFoo();
- a[j] = b;
- }
- top[i] = a;
+ Tree[] trees = new Tree[n];
+ for( int i = 0; i < n; ++i ) {
+ trees[i] = getTree();
+ build( trees[i] );
}
}
- // every
Foo is reachable from only one Foo array
+ // every
Node is reachable from only one Tree
gendefreach z0;
genreach z0;
gendefreach z0;
genreach z0;
- // resize array...
- //Foo[] b = getArray( n + 1 );
- //Foo[] notused = getArray( 1 );
- //b[0] = getFoo();
- //for( int j = 0; j < n; ++j ) {
- // b[j+1] = a[j];
- //}
+ int total = 0;
+ for( int i = 0; i < n; ++i ) {
+ Tree t = trees[i];
- // after array resize?
- gendefreach z1;
- genreach z1;
+ // select a tree
+
gendefreach z1;
+
genreach z1;
- // use info to keep compiler from optimizing anything away
- int total = 0;
- for( int i = 0; i < m; ++i ) {
- for( int j = 0; j < n; ++j ) {
- total += top[i][j].z;
- }
+ sillyRemove( t.root );
+
+ // after remove
+ gendefreach z2;
+ genreach z2;
+
+ total += t.root.z;
}
}
+
System.out.println( " "+total );
}
System.out.println( " "+total );
}
+
+ static public Tree getTree() {
+ return disjoint jupiter new Tree();
+ }
- static public
Foo[] getArray( int n
) {
- return
disjoint jupiter new Foo[n]
;
+ static public
Node getNode(
) {
+ return
new Node()
;
}
}
- static public Foo getFoo() {
- Foo f = new Foo();
- f.z = 1;
- return f;
+ static public void build( Tree t ) {
+ t.root = getNode();
+ t.root.left = getNode();
+ t.root.left.left = getNode();
+ t.root.left.right = getNode();
+ t.root.right = getNode();
+ t.root.right.left = getNode();
+ t.root.right.right = getNode();
}
}
+ static public void sillyRemove( Node n ) {
+ if( n != null &&
+ n.left != null &&
+ n.left.left != null ) {
+ n.left = n.left.left;
+ }
+ }
}
}