OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Private Attributes | List of all members
WTreeNode Class Reference

A node in a tree, holding an index, a level in the tree and pointers to its child nodes. More...

#include <WTreeNode.h>

+ Inheritance diagram for WTreeNode:
+ Collaboration diagram for WTreeNode:

Public Types

typedef std::shared_ptr< WTreeNodeSPtr
 Shared pointer abbreviation. More...
 

Public Member Functions

 WTreeNode (size_t index, double level)
 Constructs a new TreeNode. More...
 
 WTreeNode (const WDendrogram &dendrogram)
 Constructs a tree of WTreeNodes from a WDendrogram with this WTreeNode as root. More...
 
 ~WTreeNode ()
 Default destructor. More...
 
void addChild (WTreeNode::SPtr child)
 Adds a childnode to this node. More...
 
size_t index ()
 Returns the index of the TreeNode. More...
 
double level ()
 Returns the level of the TreeNode. More...
 
std::vector< WTreeNode::SPtrgetChildren ()
 Returns the child nodes of this node. More...
 
WTreeNode::SPtr getParent ()
 Returns the parent node of this node. More...
 

Private Attributes

std::vector< WTreeNode::SPtrm_children
 Stores the childnodes of this node. More...
 
double m_level
 Stores the level of this node. More...
 
size_t m_index
 Stores the index of this node. More...
 
WTreeNode::SPtr m_parent
 Stores the parent node. More...
 

Detailed Description

A node in a tree, holding an index, a level in the tree and pointers to its child nodes.

Definition at line 38 of file WTreeNode.h.

Member Typedef Documentation

◆ SPtr

typedef std::shared_ptr< WTreeNode > WTreeNode::SPtr

Shared pointer abbreviation.

Definition at line 44 of file WTreeNode.h.

Constructor & Destructor Documentation

◆ WTreeNode() [1/2]

WTreeNode::WTreeNode ( size_t  index,
double  level 
)

Constructs a new TreeNode.

Parameters
indexthe index of the new Node.
levelthe level of the Node in the Tree

Definition at line 32 of file WTreeNode.cpp.

Referenced by WTreeNode().

+ Here is the caller graph for this function:

◆ WTreeNode() [2/2]

WTreeNode::WTreeNode ( const WDendrogram dendrogram)
explicit

Constructs a tree of WTreeNodes from a WDendrogram with this WTreeNode as root.

Parameters
dendrogramReference to the dendrogram to construct the tree from

Definition at line 39 of file WTreeNode.cpp.

References WDendrogram::getHeights(), WDendrogram::getParents(), index(), m_children, m_index, m_level, and WTreeNode().

+ Here is the call graph for this function:

◆ ~WTreeNode()

WTreeNode::~WTreeNode ( )

Default destructor.

Definition at line 74 of file WTreeNode.cpp.

Member Function Documentation

◆ addChild()

void WTreeNode::addChild ( WTreeNode::SPtr  child)

Adds a childnode to this node.

Parameters
childthe child node to add

Definition at line 88 of file WTreeNode.cpp.

References m_children.

◆ getChildren()

std::vector< WTreeNode::SPtr > WTreeNode::getChildren ( )

Returns the child nodes of this node.

Returns
the child nodes of this node

Definition at line 99 of file WTreeNode.cpp.

References m_children.

◆ getParent()

WTreeNode::SPtr WTreeNode::getParent ( )

Returns the parent node of this node.

Returns
the parent node of this node

Definition at line 94 of file WTreeNode.cpp.

References m_parent.

◆ index()

size_t WTreeNode::index ( )

Returns the index of the TreeNode.

Returns
the node's index

Definition at line 83 of file WTreeNode.cpp.

References m_index.

Referenced by WTreeNode().

+ Here is the caller graph for this function:

◆ level()

double WTreeNode::level ( )

Returns the level of the TreeNode.

All level-0-nodes are leaves.

Returns
the node's level

Definition at line 78 of file WTreeNode.cpp.

References m_level.

Member Data Documentation

◆ m_children

std::vector< WTreeNode::SPtr > WTreeNode::m_children
private

Stores the childnodes of this node.

Definition at line 105 of file WTreeNode.h.

Referenced by addChild(), getChildren(), and WTreeNode().

◆ m_index

size_t WTreeNode::m_index
private

Stores the index of this node.

Definition at line 115 of file WTreeNode.h.

Referenced by index(), and WTreeNode().

◆ m_level

double WTreeNode::m_level
private

Stores the level of this node.

Definition at line 110 of file WTreeNode.h.

Referenced by level(), and WTreeNode().

◆ m_parent

WTreeNode::SPtr WTreeNode::m_parent
private

Stores the parent node.

Definition at line 120 of file WTreeNode.h.

Referenced by getParent().


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