|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.neu.ccs.demeterf.FC edu.neu.ccs.demeterf.TU<T>
public abstract class TU<T>
A Helper Class to implement something like SYB queries. To use this class, you must implement at least three methods:
public T combine(){ ... }
public T fold(T acc, T one){ ... }
T
s for unification of compound objectsT combine(X x)
for interesting
types, that will add to the final accumulated value.
// Example Binary Tree Representation...
abstract class BTree{}
class Leaf extends BTree{
int data;
Leaf(int i){ data = i; }
}
class Node extends BTree{
BTree left, right;
Node(BTree l, BTree r){ left = l; right = r; }
}
// Concrete TUCombiner Class
// Counts the number of Leafs in a BTree instance
class CountLeafs extends TUCombiner<Integer>{
public Integer combine(){ return 0; }
public Integer fold(Integer i, Integer j){ return i+j; }
int combine(Leaf l){ return 1; }
static int leafs(BTree t){
return TUCombiner.traverse(t, new CountLeafs());
}
}
TUCombiner will make sure that the Leaf
class becomes an actual
leaf of the traversal, because the combine method only takes one parameter.
If there are other cases that we care about we can add more combine
methods, one for each to be considered a value producing leaf with a
return type T
.
Field Summary |
---|
Fields inherited from class edu.neu.ccs.demeterf.FC |
---|
augMethodName, buildMethodName |
Constructor Summary | |
---|---|
TU()
|
Method Summary | ||
---|---|---|
abstract T |
combine()
Default combine (must be implemented for safety) |
|
T |
combine(java.lang.Object o1)
|
|
T |
combine(java.lang.Object o1,
T o2)
A Bunch of simple Object* methods to catch all the rest |
|
T |
combine(java.lang.Object o1,
T o2,
T o3)
|
|
T |
combine(java.lang.Object o1,
T o2,
T o3,
T o4)
|
|
T |
combine(java.lang.Object o1,
T o2,
T o3,
T o4,
T o5)
|
|
T |
combine(java.lang.Object o1,
T o2,
T o3,
T o4,
T o5,
T o6)
|
|
T |
combine(java.lang.Object o1,
T o2,
T o3,
T o4,
T o5,
T o6,
T o7)
|
|
T |
combine(java.lang.Object o1,
T o2,
T o3,
T o4,
T o5,
T o6,
T o7,
T o8)
|
|
T |
combine(java.lang.Object o1,
T o2,
T o3,
T o4,
T o5,
T o6,
T o7,
T o8,
T o9)
|
|
T |
combine(java.lang.Object o1,
T o2,
T o3,
T o4,
T o5,
T o6,
T o7,
T o8,
T o9,
T o10)
|
|
abstract T |
fold(T accum,
T one)
Perform one step of the combination |
|
T |
traverse(java.lang.Object o)
Use this to do a TU Traversal of an Object. |
|
T |
traverse(java.lang.Object o,
MutableControl c)
Use this to do a TU Traversal of an Object with a given Control for optimization purposes. |
|
T |
traverseHeap(java.lang.Object o)
TU Traversal On the Heap instead of the stack |
|
T |
traverseHeap(java.lang.Object o,
MutableControl c)
TU Traversal On the Heap instead of the stack, with the given control |
|
static
|
traversePar(java.lang.Object o,
TU<R> tuc)
Uses ParTraversal to do combines in parallel |
|
static
|
traversePar(java.lang.Object o,
TU<R> tuc,
MutableControl c)
Uses ParTraversal to do combines in parallel |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TU()
Method Detail |
---|
public T combine(java.lang.Object o1)
public T combine(java.lang.Object o1, T o2)
public T combine(java.lang.Object o1, T o2, T o3)
public T combine(java.lang.Object o1, T o2, T o3, T o4)
public T combine(java.lang.Object o1, T o2, T o3, T o4, T o5)
public T combine(java.lang.Object o1, T o2, T o3, T o4, T o5, T o6)
public T combine(java.lang.Object o1, T o2, T o3, T o4, T o5, T o6, T o7)
public T combine(java.lang.Object o1, T o2, T o3, T o4, T o5, T o6, T o7, T o8)
public T combine(java.lang.Object o1, T o2, T o3, T o4, T o5, T o6, T o7, T o8, T o9)
public T combine(java.lang.Object o1, T o2, T o3, T o4, T o5, T o6, T o7, T o8, T o9, T o10)
public abstract T fold(T accum, T one)
public abstract T combine()
public T traverse(java.lang.Object o)
public T traverse(java.lang.Object o, MutableControl c)
public T traverseHeap(java.lang.Object o)
public T traverseHeap(java.lang.Object o, MutableControl c)
public static <R> R traversePar(java.lang.Object o, TU<R> tuc)
public static <R> R traversePar(java.lang.Object o, TU<R> tuc, MutableControl c)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |