Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.38 KB | None | 0 0
  1. public class Tree<T> : where T : Tree<T>
  2. {
  3.     T parent;
  4.     List<T> children;
  5.  
  6.     public Tree(T parent)
  7.     {
  8.         this.parent = parent;
  9.         this.children = new List<T>();
  10.         if( parent!=null ) { parent.children.Add(this as T); }
  11.     }
  12.     public bool IsRoot { get { return parent == null; } }
  13.     public bool IsLeaf { get { return children.Count == 0; } }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement