Glossygloss  0.2
Glossygloss is set of classes to use several data structure as Tree or hash table.
 All Classes Files Functions Variables Macros Pages
Public Member Functions | Private Attributes | List of all members
Node< T > Class Template Reference

Defines tree nodes. More...

#include <tree.hpp>

Public Member Functions

 Node (const Node< T > &other)
 
 Node (T data)
 
 ~Node ()
 
Node< T > & operator= (Node< T > &other)
 
bool operator== (const Node< T > &rhs)
 
bool operator!= (const Node< T > &rhs)
 
bool isLeaf ()
 
int height ()
 
void append (T n_data)
 
void remove (T data)
 
getTag ()
 
bool contains (T element)
 
string toString ()
 
 Node (const Node &other)
 
 Node (char data, int frequency)
 
 Node ()
 
 ~Node ()
 
Nodeoperator= (const Node &other)
 
bool operator== (const Node &rhs)
 
bool operator!= (const Node &rhs)
 
bool isLeaf ()
 
int height ()
 
Nodeappend (const char n_data, int frequency)
 
char getTag ()
 
string toString ()
 
void toList (forward_list< string > &words, string word)
 
void toFrequencedList (forward_list< pair< string, int >> &words, string word)
 

Private Attributes

int _childNbr
 Number of children. More...
 
_tag
 letter stored into Node, the tag More...
 
forward_list< Node< T > > _children
 children of the Node More...
 
int _wordFrequency
 
char _tag
 letter stored into Node, the tag More...
 
forward_list< Node * > _children
 children of the Node More...
 

Detailed Description

template<typename T = char>
class Node< T >

Defines tree nodes.

Class for nodes of a tree. A Node store a tag and can have several children

Class for nodes of a TreeString. A Node store a letter and can have several children.

Constructor & Destructor Documentation

template<typename T = char>
Node< T >::Node ( const Node< T > &  other)

Copy constructor

Parameters
[in]otherNode to copy
template<typename T = char>
Node< T >::Node ( data)

Simple constructor

Parameters
[in]datato store into the Node
template<typename T = char>
Node< T >::~Node ( )

Destructor for Node

template<typename T = char>
Node< T >::Node ( const Node< T > &  other)

Copy constructor

Parameters
[in]otherNode to copy
template<typename T = char>
Node< T >::Node ( char  data,
int  frequency 
)

Simple constructor

Parameters
[in]datato store into the Node
[in]endis it the last letter of a word ?
template<typename T = char>
Node< T >::Node ( )

Empty constructor

template<typename T = char>
Node< T >::~Node ( )

Destructor for Node

Member Function Documentation

template<typename T = char>
void Node< T >::append ( n_data)

Hook up a new child to the node

Parameters
[in]n_datanew data to store as a child of the node
template<typename T = char>
Node* Node< T >::append ( const char  n_data,
int  frequency 
)

Hook up a new child to the node

Parameters
[in]n_datanew data to store as a child of the node
[in]frequencyif greater than 0, end of a word.
[out]newchildreturn the adress of the new child created
template<typename T = char>
bool Node< T >::contains ( element)

Do the tag is element or one of his children ?

Parameters
[in]elementElement to look for
[out]boolTrue if node or one of his child has the right tag, else false.
template<typename T = char>
T Node< T >::getTag ( )

What is the tag of the Node ?

Parameters
[out]tagThe tag of the node
template<typename T = char>
char Node< T >::getTag ( )

What is the tag of the Node ?

Parameters
[out]tagThe tag of the node
template<typename T = char>
int Node< T >::height ( )

The height of the node

Parameters
[out]hgtheight of the node
template<typename T = char>
int Node< T >::height ( )

The height of the node

Parameters
[out]hgtheight of the node
template<typename T = char>
bool Node< T >::isLeaf ( )

Is the node a leaf ?

Parameters
[out]booltrue, if no child, else false
template<typename T = char>
bool Node< T >::isLeaf ( )

Is the node a leaf ?

Parameters
[out]booltrue, if no child, else false
template<typename T = char>
bool Node< T >::operator!= ( const Node< T > &  rhs)

inequality operator

Parameters
[in]lhsfirst node to compare
[in]rhssecond node to compare
[out]booltrue if nodes have not the same memory adress, else false
template<typename T = char>
bool Node< T >::operator!= ( const Node< T > &  rhs)

inequality operator

Parameters
[in]lhsfirst node to compare
[in]rhssecond node to compare
[out]booltrue if nodes have not the same memory adress, else false
template<typename T = char>
Node<T>& Node< T >::operator= ( Node< T > &  other)

assignment operator overload

Parameters
[in]othernode to assign
[out]noteassigned node
template<typename T = char>
Node& Node< T >::operator= ( const Node< T > &  other)

assignment operator overload

Parameters
[in]othernode to assign
[out]noteassigned node
template<typename T = char>
bool Node< T >::operator== ( const Node< T > &  rhs)

equality operator

Parameters
[in]lhsleft hand side, first node to compare
[in]rhsright hand side, second node to compare
[out]booltrue if nodes have the same memory adress, else false
template<typename T = char>
bool Node< T >::operator== ( const Node< T > &  rhs)

equality operator

Parameters
[in]lhsleft hand side, first node to compare
[in]rhsright hand side, second node to compare
[out]booltrue if nodes have the same memory adress, else false
template<typename T = char>
void Node< T >::remove ( data)

Remove a leaf from the node

Parameters
[in]datadata of the node's tag to remove
Exceptions
TreeExceptionThrew if data is not removed
template<typename T = char>
void Node< T >::toFrequencedList ( forward_list< pair< string, int >> &  words,
string  word 
)

Put each word in a list

Parameters
[in]wordsList containing all words and his frequency in pairs
[in]stringwordCom Word which is currently reconvene
template<typename T = char>
void Node< T >::toList ( forward_list< string > &  words,
string  word 
)

Put each words in a list

Parameters
[in]wordsList containing all words
[in]stringwordCom Word which is currently reconvene
template<typename T = char>
string Node< T >::toString ( )

Get a string representation of the node and his child

Parameters
[out]descDescription of the node (and his child)
template<typename T = char>
string Node< T >::toString ( )

Get a string representation of the node and his child

Parameters
[out]descDescription of the node (and his child)

Member Data Documentation

template<typename T = char>
int Node< T >::_childNbr
private

Number of children.

template<typename T = char>
forward_list<Node<T> > Node< T >::_children
private

children of the Node

template<typename T = char>
forward_list<Node*> Node< T >::_children
private

children of the Node

template<typename T = char>
T Node< T >::_tag
private

letter stored into Node, the tag

template<typename T = char>
char Node< T >::_tag
private

letter stored into Node, the tag

template<typename T = char>
int Node< T >::_wordFrequency
private

the end of a word and his frequency if _wordFrequency > 0, it's a word end


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