public interface NAryTree extends java.lang.Comparable<NAryTree>
Modifier and Type | Field and Description |
---|---|
static short |
AND
indicates the type AND
|
static short |
ILV
indicates the type INTERLEAVED
|
static short |
LOOP
indicates the type LOOP
|
static short |
NONE
constant for no child/parent
|
static short |
OR
indicates the type OR
|
static short |
REVSEQ
indicates the type REVSEQ
|
static short |
SEQ
indicates the type SEQ
|
static short |
TAU
indicates the type for tau-LEAF
|
static short |
XOR
indicates the type XOR
|
Modifier and Type | Method and Description |
---|---|
NAryTree |
add(NAryTree source,
int node,
int par,
int location)
Returns a new tree where the subtree below the node at index node in the
source tree is copied into this tree under node with index parent at
location index.
|
NAryTree |
addChild(int operatorNode,
int index,
short leafType,
byte configurationType)
Returns a new tree in which a child is added to the operator at the given
index
|
void |
addConfiguration(Configuration configuration)
adds the given configurations to the list of configurations.
|
NAryTree |
addParent(int node,
short type,
byte configurationType)
Returns a new tree in which node from source is replaced by a new node of
the given type and where the existing node becomes a child of this newly
added parent.
|
NAryTree |
applyConfiguration(int configurationNumber)
Applies a configuration to the tree and returns the result.
|
int |
countNodes(short type)
counts the number of nodes of the given type
|
int |
findBlockEffect(int node) |
int |
getChildAtIndex(int par,
int n)
returns the id of the n-th child of par.
|
Configuration |
getConfiguration(int configurationNumber)
Returns the configuration stored at the given index.
|
int |
getNext(int node)
returns the first node larger than the given node, which is not part of
the subtree of the given node.
|
int |
getNextFast(int node)
returns the first node larger than the given node, which is not part of
the subtree of the given node.
|
int |
getNextLeaf(int node)
returns the leaf greater than the given node.
|
int |
getNextLeafFast(int node)
returns the leaf greater than the given node.
|
byte |
getNodeConfiguration(int configurationNumber,
int node)
returns the configuration of the node in the given configuration.
|
int |
getNumberOfConfigurations()
Returns the number of configurations.
|
int |
getParent(int node)
returns the parent of the given node.
|
int |
getParentFast(int node)
returns the parent of the given node.
|
short |
getType(int node)
returns the type of a node.
|
short |
getType(int configurationNumber,
int node)
returns the type of a node.
|
short |
getTypeFast(int node)
returns the type of a node.
|
short |
getTypeFast(int configurationNumber,
int node)
returns the type of a node.
|
boolean |
isBlocked(int configurationNumber,
int node)
returns true if the given node is blocked in the given configuration
|
boolean |
isConsistent()
returns true if the tree is (internally) consistent
|
boolean |
isHidden(int configurationNumber,
int node)
returns true if the given node is hidden in the given configuration
|
boolean |
isInSubtree(int par,
int child)
returns if the child appears in the subtree of the parent
|
boolean |
isLeaf(int node)
returns true if a node is a leaf.
|
NAryTree |
move(int node,
int newParent,
int location)
moves the given node by removing it from its parent and adding is under
the new parent.
|
NAryTree |
move(int par,
int location,
int newParent,
int newLocation)
moves the n-th child of the parent "par" by removing it from the tree and
inserting it as a new child under newParent.
|
int |
nChildren(int node)
returns the number of children of a node.
|
int |
numLeafs()
returns the number of leafs in the tree.
|
NAryTree |
remove(int node)
removes the node at index node from the tre
|
NAryTree |
remove(int par,
int index)
removes the child at index from node par.
|
void |
removeAllConfigurations() |
void |
removeConfiguration(int configurationNumber)
Removes the configuration at the given index from the list of
configurations.
|
NAryTree |
replace(int par,
int n,
NAryTree source,
int node)
replaces the n-th child of parent with the node from source.
|
NAryTree |
replace(int node,
NAryTree source,
int srcNode)
replaces node from this tree with the node from the source tree
It is assumed that this tree and the given tree have an equal number of
configurations.
|
void |
setNodeConfiguration(int configurationNumber,
int Node,
byte configurationOption)
Sets the configuration option for a node.
|
void |
setType(int par,
int n,
short t)
sets the type of the n-th child of parent par.
|
void |
setType(int index,
short t)
Sets the type of the node.
|
int |
size()
returns the number of nodes in the tree
|
int |
size(int node)
returns the size of the subtree under node
|
NAryTree |
swap(int node1,
int node2)
returns a new tree with the two nodes swapped.
|
java.lang.String |
toInternalString()
returns a string representation of the internal datastructures of the
tree (for debugging only)
|
static final short TAU
static final short XOR
static final short AND
static final short OR
static final short LOOP
static final short SEQ
static final short REVSEQ
static final short ILV
static final short NONE
void setType(int index, short t)
index
- Index of the node to updatet
- Type to set the node tovoid setType(int par, int n, short t)
par
- the parent. This should not be a leaf.n
- the child numbert
- NAryTree swap(int node1, int node2)
node1
- First node to swapnode2
- Other node to swap withNAryTree add(NAryTree source, int node, int par, int location)
source
- NAryTree to add a node fromnode
- Node to add from the source tree to the current treeparent
- Node to add the source node toindex
- Child index of the parent to add the node in (if index >
numChildren then new node becomes rightmost child)NAryTree addParent(int node, short type, byte configurationType)
node
- a node in the tree that gets a new parent (can be any node)type
- the type of the new parent (cannot be LOOP, TAU or any leaf
type)NAryTree addChild(int operatorNode, int index, short leafType, byte configurationType)
operatorNode
- node to which a child needs to be added (cannot be a leaf or a
LOOP)index
- the index at which the child should be added. 0 means the new
child becomes the leftmost, and any value greater than the
number of children implies the new node becomes the rightmost.leafType
- the new type of the new leaf node to be insertedNAryTree replace(int par, int n, NAryTree source, int node)
par
- a node. If par is a leaf, then the parameter n is ignoredn
- the child to replace. if n==0, the leftmost child is replaced,
if n>= nChildren the rightmost is.source
- NAryTree to get the new node fromnode
- Node from the source tree to be the replacement in this treeNAryTree replace(int node, NAryTree source, int srcNode)
node
- Node in this tree to be replacedsource
- NAryTree to get the new node fromsrcNode
- Node from the source tree to be the replacement in this treeNAryTree remove(int par, int index)
par
- the parent of the node to be removed. If par is a aleaf, a
clone is returnedindex
- Child index of the node to be removedNAryTree remove(int node)
node
- Index of the node to be removedint numLeafs()
NAryTree move(int node, int newParent, int location)
node
- Node to be (re)movednewParent
- Index of the new parentlocation
- Child index of the moved node in the parent nodeNAryTree move(int par, int location, int newParent, int newLocation)
par
- Index of the parent of the node to be movedlocation
- Child index of the node to be movednewParent
- Index of the new parent of the moved nodenewLocation
- Child location in the parent of the moved nodeshort getType(int node)
node
- Index of the node to get the type forshort getTypeFast(int node)
node
- Index of the node to get the type forshort getType(int configurationNumber, int node)
node
- Index of the node to get the type forshort getTypeFast(int configurationNumber, int node)
node
- Index of the node to get the type forint getChildAtIndex(int par, int n)
par
- a non-leaf node from which the index of the n-th child to get
fromn
- -th child to return index forint size(int node)
node
- Index of the node to get the size forint nChildren(int node)
node
- Index of the node to get the number of children forboolean isInSubtree(int par, int child)
par
- Index of the parent node (/root of subtree) to searchchild
- Index (absolute) of the child node to search forboolean isLeaf(int node)
node
- Index of the node to checkint size()
int getParent(int node)
node
- Index of the node to get the parent forint getNext(int node)
node
- Index of the node to get the first outside the subtree forint getParentFast(int node)
node
- Index of the node to get the parent forint getNextFast(int node)
node
- Index of the node to get the next node outside this subtree
forint getNextLeaf(int node)
node
- Index of the node to get the next leaf forint getNextLeafFast(int node)
node
- Index of the node to get the next leaf forjava.lang.String toInternalString()
boolean isConsistent()
void addConfiguration(Configuration configuration)
blockeable
- hideable
- Configuration getConfiguration(int configurationNumber)
configurationNumber
- NAryTree applyConfiguration(int configurationNumber)
configurationNumber
- void removeConfiguration(int configurationNumber)
configurationNumber
- int getNumberOfConfigurations()
boolean isBlocked(int configurationNumber, int node)
configurationNumber
- node
- boolean isHidden(int configurationNumber, int node)
configurationNumber
- node
- void setNodeConfiguration(int configurationNumber, int Node, byte configurationOption)
configurationNumber
- configurationOption
- byte getNodeConfiguration(int configurationNumber, int node)
configurationNumber
- node
- int countNodes(short type)
node
- int findBlockEffect(int node)
void removeAllConfigurations()