this little example only parallelizes for oooj with defreach
[IRC.git] / Robust / src / Tests / disjoint / definite-example / test.java
1 public class Tree {
2   Node root;
3 }
4
5 public class Node {
6   int z;
7   Node left;
8   Node right;
9   Node() {
10     z     = 1;
11     left  = null;
12     right = null;
13   }
14 }
15
16
17 public class Test {
18
19   
20
21   static public void main( String args[] ) {
22
23     int n = 3;
24     Tree[] trees = new Tree[n];
25     for( int i = 0; i < n; ++i ) {
26       trees[i] = getTree();
27       build( trees[i] );
28     }
29
30     // every Node is reachable from only one Tree
31     gendefreach z0;
32     genreach z0;
33
34     int total = 0;
35     for( int i = 0; i < n; ++i ) {
36       Tree t = trees[i];
37
38       // select a tree
39       gendefreach z1;
40       genreach z1;
41
42       sillyRemove( t.root );
43
44       // after remove
45       gendefreach z2;
46       genreach z2;
47
48       total += t.root.z;
49     }
50
51     System.out.println( " "+total );
52   }
53   
54   static public Tree getTree() {
55     return disjoint jupiter new Tree();
56   }
57
58   static public Node getNode() {
59     return new Node();
60   }
61
62   static public void build( Tree t ) {
63     t.root             = getNode();
64     t.root.left        = getNode();
65     t.root.left.left   = getNode();
66     t.root.left.right  = getNode();
67     t.root.right       = getNode();
68     t.root.right.left  = getNode();
69     t.root.right.right = getNode();
70   }
71
72   static public void sillyRemove( Node n ) {
73     if( n != null &&
74         n.left != null &&
75         n.left.left != null ) {
76       n.left = n.left.left;
77     }
78   }
79 }