当前位置: 首页>>代码示例>>C#>>正文


C# BinaryTree.Contains方法代码示例

本文整理汇总了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());
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:14,代码来源:BinaryTreeTests.cs

示例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));
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:11,代码来源:BinaryTreeTests.cs

示例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));
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:15,代码来源:Program.cs

示例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);
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:17,代码来源:BinaryTreeTests.cs

示例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();
 }
开发者ID:dmitriymatus,项目名称:Tasks,代码行数:36,代码来源:Epam_Task_11_1_ConsoleApplication.cs

示例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());
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:27,代码来源:BinaryTreeTests.cs


注:本文中的BinaryTree.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。