Package protelis.coord.treeimport
Class Tree
-
- All Implemented Interfaces:
public final class Tree
-
-
Method Summary
Modifier and Type Method Description final static <Error class: unknown class>
spanningTree(Number potential)
Build a spanning tree. final static <T extends Any, U extends Any> <Error class: unknown class>
spanningTreeExtended(Number potential, Function1<T, U> function, U init)
Build a spanning tree. final static <T extends Any, U extends Any> U
applyOnTree(Function1<Unit, T> tree, Boolean condition, Function1<T, U> f, Function1<T, U> g)
Assuming to have a spanning tree, apply f where condition holds, g otherwise. final static <E extends Any, C extends Any, U extends Any> U
descendBranch(Number potential, Function1<Boolean, Boolean> filter, Function2<Object, Object, U> f, Function2<Object, Object, U> g)
Assuming to have a spanning tree, apply f to the children of the first device where condition holds, g otherwise. final static <E extends Any, C extends Any, U extends Any> U
descendBranchWithNull(Number potential, Number null, Function1<Boolean, Boolean> filter, Function2<Object, Object, U> f, Function2<Object, Object, U> g)
Assuming to have a spanning tree, apply f to the children of the first device where condition holds, g otherwise. final static <E extends Any, C extends Any, U extends Any> U
ascendBranch(Number potential, Function1<Boolean, Boolean> filter, Function2<Object, Object, U> f, Function2<Object, Object, U> g)
Assuming to have a spanning tree, apply f to the father of any of the devices where condition holds, g otherwise. -
-
Method Detail
-
spanningTree
final static <Error class: unknown class> spanningTree(Number potential)
Build a spanning tree.
- Parameters:
potential
- potential to be followed- Returns:
parent
-
spanningTreeExtended
final static <T extends Any, U extends Any> <Error class: unknown class> spanningTreeExtended(Number potential, Function1<T, U> function, U init)
Build a spanning tree.
- Parameters:
potential
- potential to be followedfunction
- function to be applied to the parent valueinit
- initial value of the device
-
applyOnTree
final static <T extends Any, U extends Any> U applyOnTree(Function1<Unit, T> tree, Boolean condition, Function1<T, U> f, Function1<T, U> g)
Assuming to have a spanning tree, apply f where condition holds, g otherwise.
- Parameters:
tree
- treecondition
- conditionf
- what to do if condition is trueg
- what to do if condition is false- Returns:
apply f where condition holds, g otherwise
-
descendBranch
final static <E extends Any, C extends Any, U extends Any> U descendBranch(Number potential, Function1<Boolean, Boolean> filter, Function2<Object, Object, U> f, Function2<Object, Object, U> g)
Assuming to have a spanning tree, apply f to the children of the first device where condition holds, g otherwise.
- Parameters:
potential
- potentialfilter
- whether to execute f or g according to the parent conditionf
- what to do if condition is trueg
- what to do if condition is false- Returns:
apply f where condition holds, g otherwise
-
descendBranchWithNull
final static <E extends Any, C extends Any, U extends Any> U descendBranchWithNull(Number potential, Number null, Function1<Boolean, Boolean> filter, Function2<Object, Object, U> f, Function2<Object, Object, U> g)
Assuming to have a spanning tree, apply f to the children of the first device where condition holds, g otherwise.
- Parameters:
potential
- potentialnull
- null potential valuefilter
- whether to execute f or g according to the parent conditionf
- what to do if condition is trueg
- what to do if condition is false- Returns:
apply f where condition holds, g otherwise
-
ascendBranch
final static <E extends Any, C extends Any, U extends Any> U ascendBranch(Number potential, Function1<Boolean, Boolean> filter, Function2<Object, Object, U> f, Function2<Object, Object, U> g)
Assuming to have a spanning tree, apply f to the father of any of the devices where condition holds, g otherwise.
- Parameters:
potential
- potentialfilter
- whether to execute f or g according to the parent conditionf
- what to do if condition is trueg
- what to do if condition is false- Returns:
apply f where condition holds, g otherwise
-
-
-
-