本文整理汇总了C#中BinaryTree.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryTree.Contains方法的具体用法?C# BinaryTree.Contains怎么用?C# BinaryTree.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryTree
的用法示例。
在下文中一共展示了BinaryTree.Contains方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTest
public void AddTest()
{
var tree = new BinaryTree<int>();
Assert.IsTrue(tree.IsEmpty());
tree.Add(3);
Assert.IsFalse(tree.IsEmpty());
tree.Add(1);
tree.Add(4);
Assert.IsTrue(tree.Contains(3));
Assert.IsTrue(tree.Contains(1));
Assert.IsTrue(tree.Contains(4));
Assert.IsFalse(tree.Contains(2));
Assert.IsFalse(tree.IsEmpty());
}
示例2: DeleteTest2
public void DeleteTest2()
{
var tree = new BinaryTree<int>();
tree.Add(4);
tree.Add(1);
tree.Add(3);
tree.Add(2);
tree.Add(5);
tree.Delete(4);
Assert.IsTrue(tree.Contains(3));
}
示例3: Main
/// <summary>
/// Main program method
/// </summary>
/// <param name="args"></param>
private static void Main(string[] args)
{
var tree = new BinaryTree<int>();
tree.Add(5);
tree.Add(3);
tree.Add(6);
tree.Print();
tree.Delete(6);
tree.Print();
Console.WriteLine(tree.Contains(6));
}
示例4: EnumeratorTest
public void EnumeratorTest()
{
var tree = new BinaryTree<string>();
tree.Add("lalal");
tree.Add("dsa");
tree.Add("ololo");
tree.Add("tree.Add");
tree.Add("a");
tree.Add("zzzzzzzzzzzzzzzzzzzzzzzzz");
int count = 0;
foreach (var element in tree)
{
++count;
Assert.IsTrue(tree.Contains(element));
}
Assert.AreEqual(6, count);
}
示例5: Main
static void Main(string[] args)
{
DateTime testdata = new DateTime(2014, 10, 20);
TestInfo a = new TestInfo("dima", "firsttest", testdata, 9);
testdata = new DateTime(2014, 11, 20);
TestInfo b = new TestInfo("oleg", "firsttest", testdata, 4);
BinaryTree<TestInfo> tree = new BinaryTree<TestInfo>();
tree.Add(a);
tree.Add(b);
foreach (TestInfo c in tree)
{
Console.WriteLine(c.ToString());
}
tree.Remove(a);
foreach (TestInfo c in tree)
{
Console.WriteLine(c.ToString());
}
if (!tree.IsReadOnly)
{
Console.WriteLine("not only for reading");
}
testdata = new DateTime(2014, 11, 10);
TestInfo d = new TestInfo("pasha", "secondtest", testdata, 8);
tree.Add(a);
tree.Add(d);
foreach (TestInfo c in tree)
{
Console.WriteLine(c.ToString());
}
if (tree.Contains(a))
{
Console.WriteLine("Tree contains this element");
}
Console.ReadLine();
}
示例6: DeleteTest
public void DeleteTest()
{
var tree = new BinaryTree<float>();
tree.Add(4.21f);
tree.Add(421);
tree.Add(42);
tree.Add(1);
tree.Add(1000.500f);
tree.Delete(4.21f);
Assert.IsFalse(tree.Contains(4.21f));
Assert.IsTrue(tree.Contains(421));
Assert.IsTrue(tree.Contains(42));
Assert.IsTrue(tree.Contains(1));
tree.Delete(421);
Assert.IsFalse(tree.Contains(421));
Assert.IsTrue(tree.Contains(1));
tree.Delete(1);
Assert.IsFalse(tree.Contains(1));
Assert.IsFalse(tree.Contains(421));
Assert.IsTrue(tree.Contains(42));
tree.Delete(42);
Assert.IsFalse(tree.Contains(42));
Assert.IsTrue(tree.Contains(1000.500f));
tree.Delete(1000.500f);
Assert.IsFalse(tree.Contains(1000.500f));
Assert.IsTrue(tree.IsEmpty());
}