LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::decisionTree::dtNode Class Reference

a simple Node for decision trees More...

#include <ltiDecisionTree.h>

Inheritance diagram for lti::decisionTree::dtNode:
Inheritance graph
[legend]
Collaboration diagram for lti::decisionTree::dtNode:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 dtNode ()
 dtNode (const int &theId)
 dtNode (const dtNode &other)
virtual ~dtNode ()
const char * getTypeName () const
dtNodecopy (const dtNode &other)
dtNodeoperator= (const dtNode &other)
virtual dtNodeclone () const
dtNodesetLeftChild (dtNode *newLeft)
dtNodesetRightChild (dtNode *newRight)
const dtNodegetLeftChild () const
const dtNodegetRightChild () const
bool isLeaf () const
void setId (const int &theId)
int getId () const
virtual bool write (ioHandler &handler, const bool complete=true) const
virtual bool read (ioHandler &handler, const bool complete=true)

Protected Member Functions

int assignIds ()

Protected Attributes

dtNodeleft
dtNoderight
int id

Detailed Description

a simple Node for decision trees


Constructor & Destructor Documentation

lti::decisionTree::dtNode::dtNode (  ) 

default constructor

lti::decisionTree::dtNode::dtNode ( const int &  theId  ) 

Constructor.

Sets the id of the node.

Parameters:
theId the nodes id.
lti::decisionTree::dtNode::dtNode ( const dtNode other  ) 

copy constructor

Parameters:
other the dtNode object to be copied
virtual lti::decisionTree::dtNode::~dtNode (  )  [virtual]

destructor


Member Function Documentation

int lti::decisionTree::dtNode::assignIds (  )  [protected]

Assigns ids to the leaf node from left to right starting with 0.

The ids are equivalent to the positions in the decisionTrees outTemplate. The starting point is this node. Usually, this method will be called for the root node of some decisionTree. The method returns the number of leaf nodes.

virtual dtNode* lti::decisionTree::dtNode::clone (  )  const [virtual]

returns a pointer to a clone of the dtNode

Reimplemented in lti::crispDecisionTree::crispNode.

dtNode& lti::decisionTree::dtNode::copy ( const dtNode other  ) 

copy the contents of a dtNode object

Parameters:
other the dtNode object to be copied
Returns:
a reference to this dtNode object

Reimplemented in lti::crispDecisionTree::crispNode.

int lti::decisionTree::dtNode::getId (  )  const

Get the nodes id.

const dtNode* lti::decisionTree::dtNode::getLeftChild (  )  const

Gets the left child node.

const dtNode* lti::decisionTree::dtNode::getRightChild (  )  const

Gets the right child node.

const char* lti::decisionTree::dtNode::getTypeName (  )  const [virtual]

returns name of this type

Reimplemented from lti::object.

Reimplemented in lti::crispDecisionTree::crispNode.

bool lti::decisionTree::dtNode::isLeaf (  )  const

Returns true if this node is a leaf, ie it has no children.

dtNode& lti::decisionTree::dtNode::operator= ( const dtNode other  ) 

copy the contents of a dtNode object

Parameters:
other the dtNode object to be copied
Returns:
a reference to this dtNode object

Reimplemented in lti::crispDecisionTree::crispNode.

virtual bool lti::decisionTree::dtNode::read ( ioHandler handler,
const bool  complete = true 
) [virtual]

read the dtNode from the given ioHandler NOTE: Reading a node results in reading of the complete tree following this node.

Parameters:
handler the ioHandler to be used
complete if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written.
Returns:
true if write was successful

Reimplemented in lti::crispDecisionTree::crispNode.

void lti::decisionTree::dtNode::setId ( const int &  theId  ) 

Set the nodes id.

dtNode* lti::decisionTree::dtNode::setLeftChild ( dtNode newLeft  ) 

Sets the left child node and returns the previous left child node.

NOTE: No copy or clone is performed, ie left is the same pointer as newLeft. This is necessary for building trees.

Parameters:
newLeft new left child node
Returns:
the previous left child node
dtNode* lti::decisionTree::dtNode::setRightChild ( dtNode newRight  ) 

Sets the right child node and returns the previous right child node.

NOTE: No copy or clone is performed, ie left is the same pointer as newLeft. This is necessary for building trees.

Parameters:
newRight new right child node
Returns:
the previous right child node
virtual bool lti::decisionTree::dtNode::write ( ioHandler handler,
const bool  complete = true 
) const [virtual]

write the dtNode in the given ioHandler

NOTE: Writing a node results in writing of the complete tree following this node.

Parameters:
handler the ioHandler to be used
complete if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written.
Returns:
true if write was successful

Reimplemented in lti::crispDecisionTree::crispNode.


Member Data Documentation

The nodes id.

It is used as a reference to the nodes position in the decisionTrees outTemplate. So the ids should always be between 0 and n-1 with n being the number of leaf nodes of the decision tree.

Pointer to the left child node.

Pointer to the right child node.


The documentation for this class was generated from the following file:

Generated on Sat Apr 10 15:26:50 2010 for LTI-Lib by Doxygen 1.6.1