public class EfficientTreeImpl extends java.lang.Object implements EfficientTree
EfficientTree.NodeType
Modifier and Type | Field and Description |
---|---|
static int |
childrenFactor |
Constructor and Description |
---|
EfficientTreeImpl(int[] tree,
gnu.trove.map.TObjectIntMap<java.lang.String> activity2int,
java.lang.String[] int2activity)
Construct a new efficient tree using the given inputs.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(int parent,
int asChildNr,
int operatorOrActivity)
Add a child to the tree, as a child of parent, at the given position.
|
EfficientTree |
clone() |
void |
copy(int srcPos,
int destPos,
int length)
Please refer to EfficientTreeUtils for higher-level editing functions.
|
boolean |
equals(java.lang.Object obj) |
int |
getActivity(int node) |
gnu.trove.map.TObjectIntMap<java.lang.String> |
getActivity2int() |
java.lang.String |
getActivityName(int node) |
int |
getChild(int parent,
int numberOfChild) |
java.lang.Iterable<java.lang.Integer> |
getChildren(int node) |
int[] |
getChildTree(int node)
Deprecated.
|
static gnu.trove.map.TObjectIntMap<java.lang.String> |
getEmptyActivity2int() |
java.lang.String[] |
getInt2activity() |
int |
getMaxNumberOfNodes() |
EfficientTree.NodeType |
getNodeType(int node) |
int |
getNumberOfChildren(int node) |
int |
getRoot() |
int[] |
getTree() |
int |
hashCode() |
boolean |
isActivity(int node) |
boolean |
isConcurrent(int node) |
boolean |
isInterleaved(int node) |
boolean |
isLoop(int node) |
boolean |
isOperator(int node) |
boolean |
isOr(int node) |
boolean |
isSequence(int node) |
boolean |
isSkip(int node) |
boolean |
isTau(int node) |
boolean |
isXor(int node) |
void |
reorderNodes(java.lang.Integer[] nodes,
int end)
Please refer to EfficientTreeUtils for higher-level editing functions.
|
void |
replaceTree(int[] tree)
Replace the tree structure.
|
void |
setNodeActivity(int node,
int activity)
Please refer to EfficientTreeUtils for higher-level editing functions.
|
void |
setNodeType(int node,
EfficientTree.NodeType operator)
Please refer to EfficientTreeUtils for higher-level editing functions.
|
void |
setNumberOfChildren(int node,
int numberOfChildren)
Please refer to EfficientTreeUtils for higher-level editing functions.
|
void |
setSize(int size)
Please refer to EfficientTreeUtils for higher-level editing functions.
|
EfficientTreeImpl |
shortenTree()
Copy the tree into a tight array
|
void |
swap(int startA,
int startB,
int lengthB)
Please refer to EfficientTreeUtils for higher-level editing functions.
|
java.lang.String |
toString()
Return a string representation of this tree.
|
void |
toString(int node,
java.lang.StringBuilder result) |
int |
traverse(int node) |
public static final int childrenFactor
public EfficientTreeImpl(int[] tree, gnu.trove.map.TObjectIntMap<java.lang.String> activity2int, java.lang.String[] int2activity)
tree
- activity2int
- The mapping from activities (strings) to integers. The map
should be created such that the emptiness value is not 0 (as
that is a valid activity). Preferably, use
getEmptyActivity2int() to obtain such a map.int2activity
- The mapping from integers to the activities (strings). Should
be consistent with activity2int.public int[] getTree()
getTree
in interface EfficientTree
public gnu.trove.map.TObjectIntMap<java.lang.String> getActivity2int()
getActivity2int
in interface EfficientTree
public java.lang.String[] getInt2activity()
getInt2activity
in interface EfficientTree
public void addChild(int parent, int asChildNr, int operatorOrActivity)
parent
- asChildNr
- public int traverse(int node)
traverse
in interface EfficientTree
public int getActivity(int node)
getActivity
in interface EfficientTree
public java.lang.String getActivityName(int node)
getActivityName
in interface EfficientTree
public boolean isOperator(int node)
isOperator
in interface EfficientTree
public int getNumberOfChildren(int node)
getNumberOfChildren
in interface EfficientTree
public int getChild(int parent, int numberOfChild)
getChild
in interface EfficientTree
numberOfChild
- (the first child has number 0)public boolean isTau(int node)
isTau
in interface EfficientTree
public boolean isActivity(int node)
isActivity
in interface EfficientTree
public boolean isSequence(int node)
isSequence
in interface EfficientTree
public boolean isXor(int node)
isXor
in interface EfficientTree
public boolean isConcurrent(int node)
isConcurrent
in interface EfficientTree
public boolean isInterleaved(int node)
isInterleaved
in interface EfficientTree
public boolean isLoop(int node)
isLoop
in interface EfficientTree
public boolean isOr(int node)
isOr
in interface EfficientTree
public int getRoot()
getRoot
in interface EfficientTree
public java.lang.Iterable<java.lang.Integer> getChildren(int node)
getChildren
in interface EfficientTree
public EfficientTreeImpl shortenTree()
public boolean isSkip(int node)
isSkip
in interface EfficientTree
@Deprecated public int[] getChildTree(int node)
public static gnu.trove.map.TObjectIntMap<java.lang.String> getEmptyActivity2int()
public void replaceTree(int[] tree)
tree
- public java.lang.String toString()
toString
in class java.lang.Object
public void toString(int node, java.lang.StringBuilder result) throws UnknownTreeNodeException
UnknownTreeNodeException
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public EfficientTree clone()
clone
in interface EfficientTree
clone
in class java.lang.Object
public EfficientTree.NodeType getNodeType(int node)
getNodeType
in interface EfficientTree
public int getMaxNumberOfNodes()
getMaxNumberOfNodes
in interface EfficientTree
public void copy(int srcPos, int destPos, int length)
EfficientTree
copy
in interface EfficientTree
srcPos
- start of the block - sourcedestPos
- start of the block - destinationlength
- number of nodes to be movedpublic void setNodeType(int node, EfficientTree.NodeType operator)
EfficientTree
setNodeType
in interface EfficientTree
public void setNodeActivity(int node, int activity)
EfficientTree
setNodeActivity
in interface EfficientTree
public void setNumberOfChildren(int node, int numberOfChildren)
EfficientTree
setNumberOfChildren
in interface EfficientTree
public void setSize(int size)
EfficientTree
setSize
in interface EfficientTree
public void swap(int startA, int startB, int lengthB)
EfficientTree
swap
in interface EfficientTree
public void reorderNodes(java.lang.Integer[] nodes, int end)
EfficientTree
reorderNodes
in interface EfficientTree
nodes
- A consecutive but possibly shuffled list of indices, in which
to reorder nodes.end
- The index after the end of the last node.