예제 #1
0
        public void FormatString(StringBuilder sb, BracketNode node)
        {
            if (node is null)
            {
                return;
            }

            FormatString(sb, node.Left);
            sb.AppendLine(node.GetFormattedString());
            FormatString(sb, node.Right);
        }
예제 #2
0
 public void Split(Entrant newEntrant)
 {
     if (Left is null && Right is null)
     {
         Left = new BracketNode(this)
         {
             Entrant = Entrant
         };
         Right = new BracketNode(this)
         {
             Entrant = newEntrant
         };
         Entrant = null;
     }
 }
예제 #3
0
        public BracketTree(IEnumerable <Entrant> entrants)
        {
            foreach (var entrant in entrants)
            {
                if (Root is null)
                {
                    Root = new BracketNode()
                    {
                        Entrant = entrant
                    };
                }
                else
                {
                    var leaf = AllLeaves().ToList().OrderBy(l => l.Depth).First(); // TODO: May be slow

                    leaf.Split(entrant);
                }
            }
        }
예제 #4
0
 public BracketNode(BracketNode parent)
 {
     Parent = parent;
 }