Interface EfficientTree
-
- All Superinterfaces:
java.lang.Cloneable
- All Known Implementing Classes:
EfficientTreeImpl
public interface EfficientTree extends java.lang.CloneableClass to store a process tree memory efficient and perform operations cpu efficient. Idea: keep an array of int. An activity is a greater than 0 value. A node is a negative value. Some bits encode the operator, the other bits the number of children.- Author:
- sleemans
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classEfficientTree.NodeType
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description EfficientTreeclone()voidcopy(int srcPos, int destPos, int length)Please refer to EfficientTreeUtils for higher-level editing functions.intgetActivity(int node)gnu.trove.map.TObjectIntMap<java.lang.String>getActivity2int()java.lang.StringgetActivityName(int node)intgetChild(int parent, int numberOfChild)java.lang.Iterable<java.lang.Integer>getChildren(int node)java.lang.String[]getInt2activity()intgetMaxNumberOfNodes()EfficientTree.NodeTypegetNodeType(int node)intgetNumberOfChildren(int node)intgetRoot()int[]getTree()Deprecated.booleanisActivity(int node)booleanisConcurrent(int node)booleanisInterleaved(int node)booleanisLoop(int node)booleanisOperator(int node)booleanisOr(int node)booleanisSequence(int node)booleanisSkip(int node)booleanisTau(int node)booleanisXor(int node)voidreorderNodes(java.lang.Integer[] nodes, int end)Please refer to EfficientTreeUtils for higher-level editing functions.voidsetNodeActivity(int node, int activity)Please refer to EfficientTreeUtils for higher-level editing functions.voidsetNodeType(int node, EfficientTree.NodeType nodeType)Please refer to EfficientTreeUtils for higher-level editing functions.voidsetNumberOfChildren(int node, int numberOfChildren)Please refer to EfficientTreeUtils for higher-level editing functions.voidsetSize(int size)Please refer to EfficientTreeUtils for higher-level editing functions.voidswap(int startA, int startB, int lengthB)Please refer to EfficientTreeUtils for higher-level editing functions.inttraverse(int node)
-
-
-
Method Detail
-
getTree
@Deprecated int[] getTree()
Deprecated.
-
getActivity2int
gnu.trove.map.TObjectIntMap<java.lang.String> getActivity2int()
- Returns:
- A map from activity to index
-
getInt2activity
java.lang.String[] getInt2activity()
- Returns:
- A map from index (not node!) to activity.
-
traverse
int traverse(int node)
- Parameters:
node-- Returns:
- the first node after node i.
-
getActivity
int getActivity(int node)
- Parameters:
node-- Returns:
- the activity number denoted at position node. Only call if the node is an activity.
-
getNodeType
EfficientTree.NodeType getNodeType(int node)
- Parameters:
node-- Returns:
- the type of operator. Only call if the node is an operator.
-
isOperator
boolean isOperator(int node)
- Parameters:
node-- Returns:
- whether the node at position i is an operator
-
getNumberOfChildren
int getNumberOfChildren(int node)
- Parameters:
node-- Returns:
- the number of children of the current node. Only call when the node is an operator.
-
isTau
boolean isTau(int node)
- Parameters:
node-- Returns:
- whether the given node is a tau
-
isActivity
boolean isActivity(int node)
- Parameters:
node-- Returns:
- whether the given node is an activity
-
isSequence
boolean isSequence(int node)
- Parameters:
node-- Returns:
- whether the given node is a sequence
-
isXor
boolean isXor(int node)
- Parameters:
node-- Returns:
- whether the given node is a xor
-
isConcurrent
boolean isConcurrent(int node)
- Parameters:
node-- Returns:
- whether the given node is an and
-
isInterleaved
boolean isInterleaved(int node)
- Parameters:
node-- Returns:
- whether the given node is an interleaved node
-
isLoop
boolean isLoop(int node)
- Parameters:
node-- Returns:
- whether the given node is a loop
-
isOr
boolean isOr(int node)
- Parameters:
node-- Returns:
- whether the given node is an or
-
isSkip
boolean isSkip(int node)
- Parameters:
node-- Returns:
- whether the given node is not a semantic node (doesn't exist)
-
getChildren
java.lang.Iterable<java.lang.Integer> getChildren(int node)
- Parameters:
node-- Returns:
- an iterable over all children of the given node.
-
getActivityName
java.lang.String getActivityName(int node)
- Parameters:
node-- Returns:
- the activity name denoted at position node. Only call if the node is an activity.
-
getChild
int getChild(int parent, int numberOfChild)- Parameters:
parent-numberOfChild- (the first child has number 0)- Returns:
- the position of the #nrOfChild child of parent.
-
getRoot
int getRoot()
- Returns:
- The index of the root of the tree.
-
getMaxNumberOfNodes
int getMaxNumberOfNodes()
- Returns:
- a number that is larger or equal to the number of nodes in the tree.
-
copy
void copy(int srcPos, int destPos, int length)Please refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Copies nodes in the tree, overwriting the nodes at the destination. It is the responsibility of the caller to ensure there is enough space in the tree, and to ensure the tree remains consistent.- Parameters:
srcPos- start of the block - sourcedestPos- start of the block - destinationlength- number of nodes to be moved
-
setNodeType
void setNodeType(int node, EfficientTree.NodeType nodeType)Please refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Sets the type of a node. It is the responsibility of the caller to ensure that no non-operator is changed into/from an operator, as this might have unexpected consequences.- Parameters:
node-nodeType-
-
setNumberOfChildren
void setNumberOfChildren(int node, int numberOfChildren)Please refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Sets the number of children of a node. It is the responsibility of the caller to ensure the tree remains consistent.- Parameters:
node-numberOfChildren-
-
setNodeActivity
void setNodeActivity(int node, int activity)Please refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged.- Parameters:
node-activity-
-
setSize
void setSize(int size)
Please refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Set the size as given. Adds skip nodes if necessary.- Parameters:
size-
-
swap
void swap(int startA, int startB, int lengthB)Please refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Swap two consecutive children in a tree.- Parameters:
startA-startB-lengthB-
-
reorderNodes
void reorderNodes(java.lang.Integer[] nodes, int end)Please refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Reorders nodes- Parameters:
nodes- A consecutive but possibly shuffled list of indices, in which to reorder nodes.end- The index after the end of the last node.
-
clone
EfficientTree clone()
-
-