HGA Tree. More...
#include <rnodesga.h>
Public Member Functions | |
RNodesGA (RCursor< cObj > objs, size_t maxnodes, size_t maxattr) | |
void | Init (void) |
virtual void | Clear (void) |
size_t | GetNbNodes (void) const |
size_t | GetNbTopNodes (void) const |
size_t | GetMaxDepth (void) const |
cNode * | ReserveNode (void) |
void | InsertNode (cNode *parent, cNode *node) |
void | DeleteNode (cNode *node) |
virtual void | DeleteNodes (cNode *node) |
void | MoveNode (cNode *to, cNode *node) |
cNode * | CopyExceptBranch (const cNodes *from, const cNode *excluded=0, RNumContainer< size_t, true > *objs=0, bool copyobjs=true) |
cNode * | CopyExceptBranch (cNode *to, const cNode *from, const cNode *excluded=0, RNumContainer< size_t, true > *objs=0, bool copyobjs=true) |
void | InsertObj (cNode *to, cObj *obj) |
void | DeleteObj (cNode *from, const cObj *obj) |
void | DeleteObj (const cObj *obj) |
void | DeleteObjs (cNode *node) |
void | MoveObjs (cNode *to, cNode *from) |
RCursor< cObj > | GetObjs (const cNode *node) const |
bool | VerifyNodes (bool complete) |
void | CopyTree (const cNodes &nodes) |
void | BuildFile (const RString &name) |
virtual | ~RNodesGA (void) |
Public Member Functions inherited from RTree< cNodes, cNode, false > | |
RTree (void) | |
void | ClearNode (cNode *node) |
cNode * | GetFirst (void) const |
cNode * | GetLast (void) const |
size_t | GetMaxDepth (void) const |
cNode * | GetTop (void) |
const cNode * | GetTop (void) const |
size_t | GetNbNodes (void) const |
size_t | GetNbTopNodes (void) const |
size_t | GetTab (cNode **tab, cNode *node, bool children=false) |
void | InsertNode (cNode *to, cNode *node) |
void | DeleteNodes (cNode *node, bool del=false) |
void | DeleteNode (cNode *node, bool del=false) |
void | UpdateDepth (cNode *node) |
void | MoveNode (cNode *to, cNode *node) |
void | Copy (const RTree< cNodes, cNode, a > &src) |
void | DeepCopy (cNode *src, cNode *newparent) |
cNode * | GetNode (const TUse &tag) const |
double | GetUpOperationsCost (const cNode *u, const cNode *v) const |
virtual | ~RTree (void) |
Protected Attributes | |
RContainer< cNode, true, false > | Reserved |
RContainer< cNode, false, true > | Nodes |
RCursor< cObj > | Objs |
size_t * | ObjectsAss |
RContainer< cObj, false, false > | ObjsAss |
RContainer< cObj, false, false > | ObjsNoAss |
size_t | MaxAttr |
Protected Attributes inherited from RTree< cNodes, cNode, false > | |
cNode * | First |
cNode * | Last |
size_t | NbTopNodes |
size_t | NbNodes |
size_t | MaxDepth |
Private Member Functions | |
void | ReleaseNode (cNode *node) |
Detailed Description
template<class cNode, class cObj, class cNodes>
class R::RNodesGA< cNode, cObj, cNodes >
HGA Tree.
The RNodesGA class provides a representation of a tree in a HGA.
- See also
- R::RNodeGA
Constructor & Destructor Documentation
RVector Construct the nodes.
- Parameters
-
objs Objects to attach. maxnodes Maximum number of nodes. maxattr Maximum number of attributes per node.
|
virtual |
Destruct the chromosome.
Member Function Documentation
void Init | ( | void | ) |
Init the nodes.
|
virtual |
Clear all the information.
Reimplemented from RTree< cNodes, cNode, false >.
Reimplemented in RChromoH< cInst, cChromo, cFit, cThreadData, cNode, cObj >.
size_t GetNbNodes | ( | void | ) | const |
- Returns
- the total number of nodes in the tree.
size_t GetNbTopNodes | ( | void | ) | const |
- Returns
- the total number of top nodes in the tree.
size_t GetMaxDepth | ( | void | ) | const |
- Returns
- the maximum depth in the tree.
cNode* ReserveNode | ( | void | ) |
Reserve a Node.
- Returns
- A pointer to the node reserved.
|
private |
Release a node.
- Parameters
-
node Pointer to the node.
void InsertNode | ( | cNode * | parent, |
cNode * | node | ||
) |
Insert a node in the list attached to a parent. If the parent is null, the node is to insert as a top node of the tree.
- Parameters
-
parent Parent where the node is to attached. node Node to insert.
void DeleteNode | ( | cNode * | node | ) |
Delete and release a node in the list attached from a parent. If the parent is null, the node to delete is considered a top node of the tree.
The child nodes are also deleted and released.
- Parameters
-
node Node to delete.
|
virtual |
Delete and Releases all the child nodes of a given node.
- Parameters
-
node Pointer to the node.
void MoveNode | ( | cNode * | to, |
cNode * | node | ||
) |
Move a node to the list of child nodes of a given node.
- Parameters
-
to Pointer to the destination node. node Pointer to the node to move.
cNode* CopyExceptBranch | ( | const cNodes * | from, |
const cNode * | excluded = 0 , |
||
RNumContainer< size_t, true > * | objs = 0 , |
||
bool | copyobjs = true |
||
) |
Copy a tree except one branch.
- Parameters
-
from Tree to copy from. excluded Node that must (eventually) not be copied. objs Objects that must not be copied. copyobjs Must the objects be copied?
- Returns
- Pointer to the node that was supposed to have the node excluded (or 0 if not found).
cNode* CopyExceptBranch | ( | cNode * | to, |
const cNode * | from, | ||
const cNode * | excluded = 0 , |
||
RNumContainer< size_t, true > * | objs = 0 , |
||
bool | copyobjs = true |
||
) |
Copy all the objects and the nodes to a node except one node if it exists. The two nodes have to be of two different owners.
- Parameters
-
to Node where to copy. from Node to copy from. copyobjs Must the objects of from be copied? objs Objects that must not be copied. excluded Node that must (eventually) not be copied.
This method can be used to copy a whole tree "from" into another "to":
- Returns
- Pointer to the node that was supposed to have the node excluded (or 0 if not found).
void InsertObj | ( | cNode * | to, |
cObj * | obj | ||
) |
Insert an object to a node.
- Parameters
-
to Pointer of the destination node. obj Pointer to the object to insert.
void DeleteObj | ( | cNode * | from, |
const cObj * | obj | ||
) |
Delete an object from a node.
- Parameters
-
from Pointer to the node. obj Pointer to the object to delete.
void DeleteObj | ( | const cObj * | obj | ) |
Delete an object from the tree.
- Parameters
-
obj Pointer to the object to delete.
void DeleteObjs | ( | cNode * | node | ) |
Delete all the objects attached to a given node.
- Parameters
-
node Pointer to the node.
void MoveObjs | ( | cNode * | to, |
cNode * | from | ||
) |
Move all the objects of a node to another.
- Parameters
-
to Pointer of the destination node. from Pointer of the origin node.
RCursor<cObj> GetObjs | ( | const cNode * | node | ) | const |
Return a cursor over the objects of a node. The cursor cannot iterate after the last object.
- Parameters
-
node Node.
bool VerifyNodes | ( | bool | complete | ) |
Verify the validity of the tree.
- Parameters
-
complete Is the tree supposed to be complete.
- Returns
- True if the chromosome is a valid one, false else.
void CopyTree | ( | const cNodes & | nodes | ) |
Copy a whole tree in the current one.
- Parameters
-
nodes Nodes used as source.
void BuildFile | ( | const RString & | name | ) |
Build a file with a tree.
- Parameters
-
name Name of the file.
Member Data Documentation
|
protected |
Nodes reserved. It contains a number of allocated nodes, some of them being used in the tree.
|
protected |
All the nodes used in the tree, ordered by identifier.
|
protected |
The Objects to put in a tree.
|
protected |
Assignment of the objects.
|
protected |
Array of objects attached.
|
protected |
Array of objects not yet attached.
|
protected |
Maximum number of attributes for an object.