Mercury library  1.0
Translation of CFG grammars into an object model (Bachelor's thesis).
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
Public Member Functions | Properties | List of all members
Mercury.Nucleus.Trees.Tree< T > Class Template Reference

A non-balanced tree implementation that can be referenced from many other trees. Because of that, there is no way to get back to the parent node. More...

Inheritance diagram for Mercury.Nucleus.Trees.Tree< T >:

Public Member Functions

 Tree (T value)
 Initializes a new instance of the Tree{T} class with no child nodes (Leaf) More...
 
 Tree (Tree< T > other, IEnumerable< Tree< T >> children)
 "Copy" constructor More...
 
 Tree (T value, IEnumerable< Tree< T >> children)
 Initializes a new instance of the Tree{T} class with the given parent and children More...
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
string ToString (int maxdepth)
 
override string ToString ()
 
bool Equals (Tree< T > other)
 
int CompareTo (Tree< T > other)
 
IEnumerator< T > GetEnumerator ()
 

Properties

int Depth [get, set]
 Maximum depth of the tree More...
 
int LeavesCount [get, set]
 Number of leaves in the tree More...
 
int NodesCount [get, set]
 Number of nodes in the tree More...
 
Value [get, set]
 The value of this node More...
 
bool IsLeaf [get]
 Checks whether this node has no children More...
 
IReadOnlyList< Tree< T > > Children [get, set]
 Tree's children More...
 
DFSTreeEnumerator< T > DepthFirstEnumerator [get]
 Depth-First enumerator (stack based) More...
 
BFSTreeEnumerator< T > BreadthFirstEnumerator [get]
 Breadth-First Enumerator (queue based) More...
 
Tree< T > this[int ix] [get]
 Indexer returns the child More...
 

Detailed Description

A non-balanced tree implementation that can be referenced from many other trees. Because of that, there is no way to get back to the parent node.

Example:

        A      |    D    
       / \     |   / \   
      B   C    |  B   B  
         / \   |         
        B   B  |         
    

All "B" subtrees here may be the same instance of the Tree{T} class.

Template Parameters
TThe type of node values

Definition at line 30 of file Tree.cs.

Constructor & Destructor Documentation

Mercury.Nucleus.Trees.Tree< T >.Tree ( value)

Initializes a new instance of the Tree{T} class with no child nodes (Leaf)

Parameters
valueThe value of the node

Definition at line 49 of file Tree.cs.

Mercury.Nucleus.Trees.Tree< T >.Tree ( Tree< T >  other,
IEnumerable< Tree< T >>  children 
)

"Copy" constructor

Parameters
otherSource tree
childrenAdditional children

Definition at line 56 of file Tree.cs.

Mercury.Nucleus.Trees.Tree< T >.Tree ( value,
IEnumerable< Tree< T >>  children 
)

Initializes a new instance of the Tree{T} class with the given parent and children

Parameters
valueThe value of the node
childrenThe children to be added

Definition at line 66 of file Tree.cs.

Member Function Documentation

int Mercury.Nucleus.Trees.Tree< T >.CompareTo ( Tree< T >  other)

Definition at line 197 of file Tree.cs.

override bool Mercury.Nucleus.Trees.Tree< T >.Equals ( object  obj)

Definition at line 125 of file Tree.cs.

bool Mercury.Nucleus.Trees.Tree< T >.Equals ( Tree< T >  other)

Definition at line 178 of file Tree.cs.

IEnumerator<T> Mercury.Nucleus.Trees.Tree< T >.GetEnumerator ( )

Definition at line 213 of file Tree.cs.

override int Mercury.Nucleus.Trees.Tree< T >.GetHashCode ( )

Definition at line 131 of file Tree.cs.

string Mercury.Nucleus.Trees.Tree< T >.ToString ( int  maxdepth)

Definition at line 148 of file Tree.cs.

override string Mercury.Nucleus.Trees.Tree< T >.ToString ( )

Definition at line 169 of file Tree.cs.

Property Documentation

BFSTreeEnumerator<T> Mercury.Nucleus.Trees.Tree< T >.BreadthFirstEnumerator
get

Breadth-First Enumerator (queue based)

Definition at line 112 of file Tree.cs.

IReadOnlyList<Tree<T> > Mercury.Nucleus.Trees.Tree< T >.Children
getset

Tree's children

Gets the children list as read-only

Definition at line 104 of file Tree.cs.

int Mercury.Nucleus.Trees.Tree< T >.Depth
getset

Maximum depth of the tree

Definition at line 88 of file Tree.cs.

DFSTreeEnumerator<T> Mercury.Nucleus.Trees.Tree< T >.DepthFirstEnumerator
get

Depth-First enumerator (stack based)

Definition at line 108 of file Tree.cs.

bool Mercury.Nucleus.Trees.Tree< T >.IsLeaf
get

Checks whether this node has no children

Definition at line 100 of file Tree.cs.

int Mercury.Nucleus.Trees.Tree< T >.LeavesCount
getset

Number of leaves in the tree

Definition at line 91 of file Tree.cs.

int Mercury.Nucleus.Trees.Tree< T >.NodesCount
getset

Number of nodes in the tree

Definition at line 94 of file Tree.cs.

Tree<T> Mercury.Nucleus.Trees.Tree< T >.this[int ix]
get

Indexer returns the child

Parameters
ix
Returns

Definition at line 119 of file Tree.cs.

T Mercury.Nucleus.Trees.Tree< T >.Value
getset

The value of this node

Definition at line 97 of file Tree.cs.


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