public class PKTrees
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static long |
ERROR_NODE
Value returned when there is an error
|
Constructor and Description |
---|
PKTrees() |
Modifier and Type | Method and Description |
---|---|
long |
atomChar(int opCode,
char c)
Builting char atomic tree
|
long |
atomInt(int opCode,
long val)
Builting int atomic tree
|
long |
atomString(int opCode,
java.lang.String st)
Builting string atomic tree
|
long |
attrCarrier(long e)
Get the link from a tree-attribute to tree.
|
boolean |
attrExist(long node,
int num)
Test if an attribute is assigned to a tree.
|
int |
attrInt(long node,
int num)
Get the attribute value.
|
long |
attrNtrees(long node,
int num)
Get the attribute value.
|
int |
attrNumber(long node)
Get the number of attributes.
|
long |
attrPtr(long node,
int num)
Get the attribute value.
|
java.lang.String |
attrStr(long node,
int num)
Get the attribute value.
|
void |
changChild(long listNode,
long node,
int i)
Replaces the
i -th son of listNode by node . |
char |
charOf(long node)
Getting atomic tree value.
|
long |
child(int i,
long node)
Getting a son.
|
long |
copyList(long node) |
long |
destroy(long listNode,
int i)
Deletes the
i -th son of the tree listNode . |
boolean |
destroyAttr(long node,
int num)
Removes, from the set of attributes assigned to
node , the num -th attribute. |
long |
getFather(long node)
Getting father
|
long |
getNilTree()
Getting nil tree.
|
void |
globalMemoryReset()
Reseting tree memory.
|
void |
insertLeft(int i,
long node,
long listNode)
Inserts
node at the left of the i -th son of listNode . |
void |
insertRight(int i,
long node,
long listNode)
Inserts
node at the right of the i -th son of listNode . |
long |
intOf(long node)
Get the atomic tree integer value
|
boolean |
isEmpty(long node)
Test if the list is empty
|
boolean |
isNilTree(long node)
Testing nil tree.
|
long |
left(int i,
long node)
Getting a brother node
|
void |
makeAttrInt(long node,
int num,
int val)
Assignes an integer attribute to a tree node.
|
void |
makeAttrNtrees(long node,
int num,
long val)
Assignes a ntrees attribute to a tree node.
|
void |
makeAttrPtr(long node,
int num,
long ptrVal)
Assignes a pointer attribute to a tree node.
|
void |
makeAttrStr(long node,
int num,
java.lang.String str)
Assignes a string attribute to a tree node.
|
long |
makeBinary(int opCode,
long node1,
long node2) |
long |
makeEmptyList(int opCode) |
long |
makeList(int opCode,
long elem) |
long |
makeNullary(int opCode) |
long |
makePragmaEnonce(java.lang.String enonce) |
long |
makeQuaternary(int opCode,
long node1,
long node2,
long node3,
long node4) |
long |
makeTernary(int opCode,
long node1,
long node2,
long node3) |
long |
makeUnary(int opCode,
long node) |
void |
memoryFinalize()
Tree Memory finalizing.
|
void |
memoryInitialize()
Global Tree Memory initializing.
|
void |
memoryReset()
Reseting tree memory (user tree area and registers).
|
void |
memoryRestoreIndex()
Sets the memory tree index (free area) to the index stored by the previous call to ntreesMemoryStoreIndex method.
|
void |
memoryStoreIndex()
Store current index of the memory tree (free area).
|
void |
modifCharVal(long node,
char c)
Modifies the value assigned to an atomic char tree node.
|
void |
modifIntVal(long node,
int val)
Modifies the value assigned to an atomic integer tree node.
|
boolean |
needGarbage()
Test if the size of available area in tree memory seems sufficient.
|
int |
oper(long node)
Get the tree operator
|
int |
posit(long node) |
long |
post(long listNode,
long node)
Adds an element node at the end of a list node
|
long |
pre(long listNode,
long node)
Adds an element node at the beginning of a list node
|
long |
right(int i,
long node)
Getting a brother node
|
long |
setOp(long node,
int opCode)
Set the tree operator.
|
long |
string2ident(java.lang.String s) |
java.lang.String |
stringOf(long node)
Get the atomic tree string value.
|
int |
treeArity(long node)
Get the tree arity
|
void |
treeDestroy(long node)
Removes
node from the list containing it. |
long |
treesLoad(java.lang.String filename)
Loading Tree from a file.
|
boolean |
treesSave(java.lang.String filename,
long node)
Saving a Tree into a file.
|
public static final long ERROR_NODE
public void memoryFinalize()
public void memoryInitialize()
public long atomChar(int opCode, char c)
opCode
- an operatorc
- a characteropCode
as operator and c
as char value.public long atomInt(int opCode, long val)
opCode
- an operatorval
- an integer valueopCode
as operator and val
as integer value.public long atomString(int opCode, java.lang.String st)
opCode
- the code representing an operatorst
- a stringopCode
as operator and st
as string value.public void changChild(long listNode, long node, int i)
i
-th son of listNode
by node
.listNode
- a node representing a listnode
- a tree nodei
- index of the element to modifypublic char charOf(long node)
node
- an atomic tree node (assumed)node
(assumed)public long child(int i, long node)
i
- index of the child to getnode
- the address of the nodei
-th child of node
public long copyList(long node)
node
- a tree nodenode
.public long destroy(long listNode, int i)
i
-th son of the tree listNode
.listNode
- a node representing a listi
- index of the son to deletepublic long getFather(long node)
node
- the address of the nodenode
public long getNilTree()
public void insertLeft(int i, long node, long listNode)
node
at the left of the i
-th son of listNode
.i
- index of the elementnode
- the new node to insertlistNode
- a node representing a listpublic void insertRight(int i, long node, long listNode)
node
at the right of the i
-th son of listNode
.i
- index of the elementnode
- the new node to insertlistNode
- a node representing a listpublic long intOf(long node)
node
- an atomic tree node (assumed)node
public boolean isEmpty(long node)
node
- an operand treenode
is an empty tree.public boolean isNilTree(long node)
node
- the address of the nodenode
is the undefined empty tree.public long left(int i, long node)
i
- index of the brother to getnode
- a nodei
-th left brother of node
, niltree if it does not exist.public long makeBinary(int opCode, long node1, long node2)
opCode
- the code representing the operator used as root nodenode1
- node used as first sonnode2
- node used as second sonnode1
and node2
as sons.public long makeEmptyList(int opCode)
opCode
- the code representing the operator used as root nodepublic long makeList(int opCode, long elem)
opCode
- the code representing the operator used as root nodeelem
- a nodepublic long makeNullary(int opCode)
opCode
- the code representing the operator used as root nodepublic long makeQuaternary(int opCode, long node1, long node2, long node3, long node4)
opCode
- the code representing the operator used as root nodenode1
- node used as first sonnode2
- node used as second sonnode3
- node used as third sonnode4
- node used as fourth sonnode1
, node2
, node3
, and node4
as sons.public long makeTernary(int opCode, long node1, long node2, long node3)
opCode
- the code representing the operator used as root nodenode1
- node used as first sonnode2
- node used as second sonnode3
- node used as third sonnode1
, node2
,
and node3
as sons.public long makeUnary(int opCode, long node)
opCode
- the code representing the operator used as root nodenode
- node used as sonnode1
as son.public void modifCharVal(long node, char c)
node
- an atomic char tree node (assumed)c
- the new character valuepublic void modifIntVal(long node, int val)
node
- an atomic integer tree node (assumed)val
- the new integer valuepublic int oper(long node)
node
- a nodenode
public int posit(long node)
node
- a nodenode
.public long post(long listNode, long node)
listNode
- a node representing a listnode
- the node to addlistNode
in which node
is added at the end of the list.public long pre(long listNode, long node)
listNode
- a node representing a listnode
- the node to addlistNode
in which node
is added at the beginning of the list.public long right(int i, long node)
i
- index of the brother to getnode
- a nodei
-th right brother of node
, niltree if it does not exist.public long setOp(long node, int opCode)
opCode
becomes the operator of node
. No controls are done on the
arity of node
.node
- a nodeopCode
- the new code of the operatorpublic java.lang.String stringOf(long node)
node
- an atomic tree string node (assumed)node
public int treeArity(long node)
node
- a nodenode
.public void treeDestroy(long node)
node
from the list containing it.node
- a nodepublic long treesLoad(java.lang.String filename)
filename
- the name of the file to loadpublic boolean treesSave(java.lang.String filename, long node)
filename
- the name of the file in which the tree will be savednode
- the tree node to savepublic long attrCarrier(long e)
node
- a nodenode
is assigned.public boolean attrExist(long node, int num)
node
- a tree nodenum
- the attribute rank numbernode
,
false otherwise.public int attrInt(long node, int num)
node
- a tree nodenum
- the rank of the attributenum
-th attribute assigned to node
.public long attrNtrees(long node, int num)
node
- a tree nodenum
- the rank of the attributenum
-th attribute assigned to node
.public int attrNumber(long node)
node
- a tree nodenode
.public long attrPtr(long node, int num)
node
- a tree nodenum
- the rank of the attributenum
-th attribute assigned to node
.public java.lang.String attrStr(long node, int num)
node
- a tree nodenum
- the rank of the attributenum
-th attribute assigned to node
.public boolean destroyAttr(long node, int num)
node
, the num
-th attribute.node
- a tree nodenum
- the rank of the attributenum
-th attribute was assigned to node
, false otherwise.public void makeAttrInt(long node, int num, int val)
node
- a tree nodenum
- the rank of the attributeval
- integer value of the attributepublic void makeAttrNtrees(long node, int num, long val)
node
- a tree nodenum
- the rank of the attributeval
- ntrees value of the attributepublic void makeAttrPtr(long node, int num, long ptrVal)
node
- a tree nodenum
- the rank of the attributeptrVal
- pointer value of the attributepublic void makeAttrStr(long node, int num, java.lang.String str)
node
- a tree nodenum
- the rank of the attributestr
- pointer value of the attributepublic void globalMemoryReset()
public void memoryReset()
public void memoryRestoreIndex()
public void memoryStoreIndex()
public boolean needGarbage()
public long makePragmaEnonce(java.lang.String enonce)
enonce
- public long string2ident(java.lang.String s)