From: jjenista Date: Fri, 6 Jan 2012 23:41:12 +0000 (+0000) Subject: this little example only parallelizes for oooj with defreach X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=6280d3ed9b069094c8566c1f69f0e4b36239eb23;p=IRC.git this little example only parallelizes for oooj with defreach --- diff --git a/Robust/src/Tests/disjoint/definite-example/test.java b/Robust/src/Tests/disjoint/definite-example/test.java index b93eed25..ca619c0a 100644 --- 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; + Node left; + Node right; + Node() { + z = 1; + left = null; + right = null; + } } + public class Test { static public void main( String args[] ) { - int m = 2; 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; - // 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 ); } + + 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; + } + } }