public void FormatString(StringBuilder sb, BracketNode node) { if (node is null) { return; } FormatString(sb, node.Left); sb.AppendLine(node.GetFormattedString()); FormatString(sb, node.Right); }
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; } }
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); } } }
public BracketNode(BracketNode parent) { Parent = parent; }