本文整理汇总了C#中Tree.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.Add方法的具体用法?C# Tree.Add怎么用?C# Tree.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
var tree = new Tree<int>();
tree.Add(13);
tree.Add(18);
tree.Add(5);
tree.Add(20);
tree.Add(15);
tree.Add(5);
tree.Add(9);
tree.Add(3);
tree.Add(17);
tree.Add(10);
foreach (var item in tree)
{
Console.WriteLine("{0}", item);
}
tree.Remove(13);
foreach (var item in tree)
{
Console.WriteLine("{0}", item);
}
}
示例2: AddingTwo_SmallerGoesToLeft
public void AddingTwo_SmallerGoesToLeft()
{
var t = new Tree<int>();
t.Add(23);
t.Add(1);
Assert.AreEqual(1, t.Root.Left.Item);
}
示例3: AddingTwo_LargerGoesToRight
public void AddingTwo_LargerGoesToRight()
{
var t = new Tree<int>();
t.Add(23);
t.Add(78);
Assert.AreEqual(78, t.Root.Right.Item);
}
示例4: Initialize
public void Initialize()
{
tree = new Tree<int>();
tree.Add(5);
tree.Add(2);
tree.Add(1);
tree.Add(3);
tree.Add(4);
}
示例5: CheckUnderDirectoriesWithWildcard
public void CheckUnderDirectoriesWithWildcard()
{
var tree = new Tree<bool>();
tree.Add(@"C:\X", true);
tree.Add(@"C:\X\*", false);
Assert.IsTrue(tree.Under(@"C:\X"));
Assert.IsFalse(tree.Under(@"C:\X\foo"));
Assert.IsFalse(tree.Under(@"C:\X\1\foo"));
Assert.IsFalse(tree.Under(@"D:\foo"));
}
示例6: CheckUnderDirectories
public void CheckUnderDirectories()
{
var tree = new Tree<bool>();
tree.Add(@"C:\A\1", true);
tree.Add(@"C:\A\2", true);
tree.Add(@"C:\B", true);
tree.Add(@"C:\B\1", false);
Assert.IsTrue(tree.Under(@"C:\A\1\foo"));
Assert.IsTrue(tree.Under(@"C:\B\2\foo"));
Assert.IsTrue(tree.Under(@"C:\B"));
Assert.IsFalse(tree.Under(@"C:\B\1\foo"));
Assert.IsFalse(tree.Under(@"C:\C\foo"));
Assert.IsFalse(tree.Under(@"D:\foo"));
}
示例7: getTree
public Tree getTree( )
{
Tree tree = new Tree();
tree.Key = "Header";
{
tree.Add("EngineVersion", this._EngineVersion);
tree.Add("Owner", this._Owner);
tree.Add("Version", this._Version);
tree.Add("Time", this._Time);
tree.Add("Title", this._Title);
}
return tree;
}
示例8: ToString_ReturnsBFSString
public void ToString_ReturnsBFSString()
{
var tree = new Tree<int>();
tree.Add(3).Add(2).Add(5).Add(4);
var result = tree.ToString();
Assert.AreEqual("3 2 5 4 ", result);
}
示例9: CheckCaseSensitiveSentence
public void CheckCaseSensitiveSentence()
{
var tree = new Tree<bool>(new char[] { ' ', ',', '.' }, StringComparer.Ordinal);
tree.Add("The quick brown fox jumps.", true);
Assert.IsTrue(tree.Under("The quick brown fox jumps over the lazy dog."));
Assert.IsFalse(tree.Under("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG."));
Assert.IsFalse(tree.Under("A different sentence."));
}
示例10: Main
static void Main()
{
Tree<int> tree = new Tree<int>(10);
for (int i = 0; i < 20; i++)
{
if (i == 10) i++;
tree.Add(i);
}
Console.WriteLine(tree);
Console.WriteLine(tree.HasValue(15));
Console.WriteLine(tree.HasValue(25));
tree.Add(25);
Console.WriteLine(tree);
Console.WriteLine(tree.HasValue(25));
}
示例11: Main
static void Main(string[] args)
{
var tree = new Tree<int>();
tree.Add(30).Add(25).Add(36).Add(12).Add(5);
Console.WriteLine($"There are {tree.Count} elements in the tree");
ITreeBuilder<int> builder = new IntTreeBuilder();
var largeTree = builder.Build(1000000);
Console.WriteLine($"There are {largeTree.Count} elements in the large tree");
}
示例12: MakeRows
void MakeRows(Tree<Cell> table)
{
do {
var row = makeTreeCell(string.Empty);
row.Value.SetAttribute(CellAttribute.StartTag, startTags[1]);
row.Value.SetAttribute(CellAttribute.EndTag, endTags[1]);
table.Add(row);
MakeCells(row);
if (scanner.Current.Type == TokenType.Newline) scanner.MoveNext();
} while (scanner.Current.Type == TokenType.BeginCell || scanner.Current.Type == TokenType.Word);
}
示例13: EnumerateWithNoChildren
public void EnumerateWithNoChildren()
{
var tree = new Tree<int>(7, EnumeratorOrder.DepthFirstSearch);
Assert.AreEqual(7, tree.AsEnumerable().First());
tree.Order = EnumeratorOrder.BreadthFirstSearch;
Assert.AreEqual(7, tree.AsEnumerable().First());
var subtree = new Tree<int>(5, EnumeratorOrder.BreadthFirstSearch);
tree.Add(subtree);
Assert.AreEqual(5, tree.AsEnumerable().Last());
tree.Order = EnumeratorOrder.DepthFirstSearch;
Assert.AreEqual(5, tree.AsEnumerable().Last());
}
示例14: BuildTree
private static Tree BuildTree(IEnumerable<Type> types, string rootName)
{
var nodeFactory = new NodeFactory();
var tree = new Tree(nodeFactory, rootName);
foreach (var type in types)
{
var fullName = type.FullName;
tree.Add(fullName);
}
return tree;
}
示例15: AddSurplusRow
void AddSurplusRow(object surplusValue, Tree<Cell> table) {
var cells = new List<Tree<Cell>>();
foreach (var actualValue in strategy.ActualValues(surplusValue)) {
var cell = processor.Compose(actualValue.IsVoid ? new TypedValue(string.Empty) : actualValue);
if (cells.Count == 0) {
cell.Value.SetAttribute(CellAttribute.Label, "surplus");
}
cells.Add(cell);
}
var row = processor.MakeCell(string.Empty, "tr", cells);
processor.TestStatus.MarkWrong(row.Value);
table.Add(row);
}