Class InfoTree
- java.lang.Object
-
- com.crawljax.stateabstractions.dom.RTED.InfoTree
-
public class InfoTree extends Object
Stores all needed information about a single tree in several indeces.- Author:
- Mateusz Pawlik
-
-
Field Summary
Fields Modifier and Type Field Description private static byteBOTHprivate intcurrentNodeprivate intdescSizesTmpprivate static byteHEAVYint[][]infostatic byteKRprivate intkrSizesSumTmpprivate LabelDictionaryldprivate intleafCountprivate static byteLEFTboolean[][]nodeTypeprivate int[][]pathsstatic bytePOST2_DESC_SUMstatic bytePOST2_KR_SUMstatic bytePOST2_LABELstatic bytePOST2_LLDstatic bytePOST2_MIN_KRstatic bytePOST2_PARENTstatic bytePOST2_PREstatic bytePOST2_REV_KR_SUMstatic bytePOST2_SIZEstatic bytePOST2_STRATEGYstatic bytePRE2_POSTprivate intpreorderTmpprivate int[][][]relSubtreesprivate intrevkrSizesSumTmpprivate static byteRIGHTstatic byteRKRstatic byteRPOST2_MIN_RKRstatic byteRPOST2_POSTstatic byteRPOST2_RLDprivate intsizeTmpprivate booleanswitchedprivate inttreeSize
-
Constructor Summary
Constructors Constructor Description InfoTree(LblTree aInputTree, LabelDictionary aLd)Creates an InfoTree object, gathers all information about aInputTree and stores in indexes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private intgatherInfo(LblTree aT, int postorder)Gathers information of a given tree in corresponding arrays.intgetCurrentNode()Returns the postorder of current root node.intgetInfo(int infoCode, int nodesPostorder)For given infoCode and postorder of a node returns requested information of that node.int[]getInfoArray(int infoCode)For given infoCode returns an info array (index array)int[]getNodeRelSubtrees(int pathType, int nodePostorder)Returns relevant subtrees for given node.boolean[]getNodeTypeArray(int type)int[]getPath(int pathType)Returns an array representation of a given path's type.intgetSize()Returns the size of the tree.booleanifNodeOfType(int postorder, int type)booleanisSwitched()private voidpostTraversalProcessing()Gathers information, that couldn't be collected while tree traversal.voidsetCurrentNode(int postorder)Sets postorder of the current node in the recursion.voidsetSwitched(boolean value)(package private) static int[]toIntArray(List<Integer> integers)Transforms a list of Integer objects to an array of primitive int values.
-
-
-
Field Detail
-
POST2_SIZE
public static final byte POST2_SIZE
- See Also:
- Constant Field Values
-
POST2_KR_SUM
public static final byte POST2_KR_SUM
- See Also:
- Constant Field Values
-
POST2_REV_KR_SUM
public static final byte POST2_REV_KR_SUM
- See Also:
- Constant Field Values
-
POST2_DESC_SUM
public static final byte POST2_DESC_SUM
- See Also:
- Constant Field Values
-
POST2_PRE
public static final byte POST2_PRE
- See Also:
- Constant Field Values
-
POST2_PARENT
public static final byte POST2_PARENT
- See Also:
- Constant Field Values
-
POST2_LABEL
public static final byte POST2_LABEL
- See Also:
- Constant Field Values
-
KR
public static final byte KR
- See Also:
- Constant Field Values
-
POST2_LLD
public static final byte POST2_LLD
- See Also:
- Constant Field Values
-
POST2_MIN_KR
public static final byte POST2_MIN_KR
- See Also:
- Constant Field Values
-
RKR
public static final byte RKR
- See Also:
- Constant Field Values
-
RPOST2_RLD
public static final byte RPOST2_RLD
- See Also:
- Constant Field Values
-
RPOST2_MIN_RKR
public static final byte RPOST2_MIN_RKR
- See Also:
- Constant Field Values
-
RPOST2_POST
public static final byte RPOST2_POST
- See Also:
- Constant Field Values
-
POST2_STRATEGY
public static final byte POST2_STRATEGY
- See Also:
- Constant Field Values
-
PRE2_POST
public static final byte PRE2_POST
- See Also:
- Constant Field Values
-
LEFT
private static final byte LEFT
- See Also:
- Constant Field Values
-
RIGHT
private static final byte RIGHT
- See Also:
- Constant Field Values
-
HEAVY
private static final byte HEAVY
- See Also:
- Constant Field Values
-
BOTH
private static final byte BOTH
- See Also:
- Constant Field Values
-
info
public final int[][] info
-
nodeType
public final boolean[][] nodeType
-
ld
private final LabelDictionary ld
-
paths
private final int[][] paths
-
relSubtrees
private final int[][][] relSubtrees
-
sizeTmp
private int sizeTmp
-
descSizesTmp
private int descSizesTmp
-
krSizesSumTmp
private int krSizesSumTmp
-
revkrSizesSumTmp
private int revkrSizesSumTmp
-
preorderTmp
private int preorderTmp
-
currentNode
private int currentNode
-
switched
private boolean switched
-
leafCount
private int leafCount
-
treeSize
private int treeSize
-
-
Constructor Detail
-
InfoTree
public InfoTree(LblTree aInputTree, LabelDictionary aLd)
Creates an InfoTree object, gathers all information about aInputTree and stores in indexes. aInputTree is not needed any more. Remember to pass the same LabelDictionary object to both trees which are compared.- Parameters:
aInputTree- an LblTree objectaLd- a LabelDictionary object
-
-
Method Detail
-
toIntArray
static int[] toIntArray(List<Integer> integers)
Transforms a list of Integer objects to an array of primitive int values.- Parameters:
integers-- Returns:
-
getSize
public int getSize()
Returns the size of the tree.- Returns:
-
ifNodeOfType
public boolean ifNodeOfType(int postorder, int type)
-
getNodeTypeArray
public boolean[] getNodeTypeArray(int type)
-
getInfo
public int getInfo(int infoCode, int nodesPostorder)For given infoCode and postorder of a node returns requested information of that node.- Parameters:
infoCode-nodesPostorder- postorder of a node- Returns:
- a value of requested information
-
getInfoArray
public int[] getInfoArray(int infoCode)
For given infoCode returns an info array (index array)- Parameters:
infoCode-- Returns:
- array with requested index
-
getNodeRelSubtrees
public int[] getNodeRelSubtrees(int pathType, int nodePostorder)Returns relevant subtrees for given node. Assuming that child v of given node belongs to given path, all children of given node are returned but node v.- Parameters:
pathType-nodePostorder- postorder of a node- Returns:
- an array with relevant subtrees of a given node
-
getPath
public int[] getPath(int pathType)
Returns an array representation of a given path's type.- Parameters:
pathType-- Returns:
- an array with a requested path
-
getCurrentNode
public int getCurrentNode()
Returns the postorder of current root node.- Returns:
-
setCurrentNode
public void setCurrentNode(int postorder)
Sets postorder of the current node in the recursion.- Parameters:
postorder-
-
gatherInfo
private int gatherInfo(LblTree aT, int postorder)
Gathers information of a given tree in corresponding arrays. At this point the given tree is traversed once, but there is a loop over current nodes children to assign them their parents.- Parameters:
aT-postorder-- Returns:
-
postTraversalProcessing
private void postTraversalProcessing()
Gathers information, that couldn't be collected while tree traversal.
-
isSwitched
public boolean isSwitched()
-
setSwitched
public void setSwitched(boolean value)
-
-