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


C# SortableCollection.LinearSearch方法代码示例

本文整理汇总了C#中SortableCollection.LinearSearch方法的典型用法代码示例。如果您正苦于以下问题:C# SortableCollection.LinearSearch方法的具体用法?C# SortableCollection.LinearSearch怎么用?C# SortableCollection.LinearSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SortableCollection的用法示例。


在下文中一共展示了SortableCollection.LinearSearch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MethodShouldReturnFalseWhenItemDoesnotExists

        public void MethodShouldReturnFalseWhenItemDoesnotExists()
        {
            var collection = new SortableCollection<int>(new[] { 52, 111, 33, 33, 46, 1125, 1 });

            Assert.IsFalse(collection.LinearSearch(1111));
            Assert.IsFalse(collection.LinearSearch(-52));
            Assert.IsFalse(collection.LinearSearch(0));
        }
开发者ID:NikitoG,项目名称:TelerikAcademyHomeworks,代码行数:8,代码来源:LineraSearchTests.cs

示例2: TesLinearSearchtWithEmptyCollection

 public void TesLinearSearchtWithEmptyCollection()
 {
     SortableCollection<int> collection = new SortableCollection<int>();
     bool result = collection.LinearSearch(15);
     Assert.IsFalse(result);
     result = collection.LinearSearch(0);
     Assert.IsFalse(result);
     result = collection.LinearSearch(-1);
     Assert.IsFalse(result);
 }
开发者ID:bahtev,项目名称:TelerikAcademy,代码行数:10,代码来源:LinearSearchTest.cs

示例3: Main

        internal static void Main(string[] args)
        {
            var collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
            Console.WriteLine("All items before sorting:");
            collection.PrintAllItemsOnConsole();
            Console.WriteLine();

            collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
            Console.WriteLine("SelectionSorter result:");
            collection.Sort(new SelectionSorter<int>());
            collection.PrintAllItemsOnConsole();
            Console.WriteLine();

            collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
            Console.WriteLine("BubbleSorter result:");
            collection.Sort(new BubbleSorter<int>());
            collection.PrintAllItemsOnConsole();
            Console.WriteLine();

            collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
            Console.WriteLine("InsertionSorter result:");
            collection.Sort(new InsertionSorter<int>());
            collection.PrintAllItemsOnConsole();
            Console.WriteLine();

            collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
            Console.WriteLine("Quicksorter result:");
            collection.Sort(new QuickSorter<int>());
            collection.PrintAllItemsOnConsole();
            Console.WriteLine();

            collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
            Console.WriteLine("MergeSorter result:");
            collection.Sort(new MergeSorter<int>());
            collection.PrintAllItemsOnConsole();
            Console.WriteLine();

            Console.WriteLine("Linear search 101:");
            Console.WriteLine(collection.LinearSearch(101));
            Console.WriteLine();

            Console.WriteLine("Binary search 101:");
            Console.WriteLine(collection.LinearSearch(101));
            Console.WriteLine();

            Console.WriteLine("Shuffle:");
            collection.Shuffle();
            collection.PrintAllItemsOnConsole();
            Console.WriteLine();

            Console.WriteLine("Shuffle again:");
            collection.Shuffle();
            collection.PrintAllItemsOnConsole();
        }
开发者ID:bahtev,项目名称:TelerikAcademy,代码行数:54,代码来源:Program.cs

示例4: TestForSingleItem

 public void TestForSingleItem()
 {
     SortableCollection<string> collection = new SortableCollection<string>(
         new List<string>() { "1" });
     Assert.IsTrue(collection.LinearSearch("1"), "Linear search failed on single item collection");
     Assert.IsTrue(collection.BinarySearch("1"), "Binary search failed on single item collection");
     Assert.IsFalse(collection.LinearSearch("2"),
         "Linear search failed on single item collection - non-existing item");
     Assert.IsFalse(collection.BinarySearch("2"),
         "Binary search failed on single item collection - non-existing item");
 }
开发者ID:psotirov,项目名称:TelerikAcademyProjects,代码行数:11,代码来源:TestSearches.cs

示例5: TesLinearSearchtWithOneMissingElement

        public void TesLinearSearchtWithOneMissingElement()
        {
            SortableCollection<int> collection = new SortableCollection<int>(
                new int[] { 3 });

            bool result = collection.LinearSearch(15);
            Assert.IsFalse(result);
            result = collection.LinearSearch(0);
            Assert.IsFalse(result);
            result = collection.LinearSearch(-1);
            Assert.IsFalse(result);
        }
开发者ID:bahtev,项目名称:TelerikAcademy,代码行数:12,代码来源:LinearSearchTest.cs

示例6: TestForOddItems

 public void TestForOddItems()
 {
     SortableCollection<string> collection = new SortableCollection<string>(
         new List<string>() { "5", "1", "4", "1", "6" });
     Assert.IsTrue(collection.LinearSearch("1"), "Linear search failed on odd items collection");
     collection.Sort(new SelectionSorter<string>());
     Assert.IsTrue(collection.BinarySearch("1"), "Binary search failed on odd items collection");
     Assert.IsFalse(collection.LinearSearch("2"),
         "Linear search failed on odd items collection - non-existing item");
     Assert.IsFalse(collection.BinarySearch("2"),
         "Binary search failed on odd items collection - non-existing item");
 }
开发者ID:psotirov,项目名称:TelerikAcademyProjects,代码行数:12,代码来源:TestSearches.cs

示例7: Main

        public static void Main()
        {
            List<int> numbers = new List<int>() { 1,3,5,6,7,3,32,3,5,67,7,4,34,3};

            SortableCollection<int> collection = new SortableCollection<int>(numbers);
            Console.WriteLine(collection.LinearSearch(7));
        }
开发者ID:hristo-iliev,项目名称:TelerikHW,代码行数:7,代码来源:LinearSearch.cs

示例8: Main

    static void Main()
    {
        var collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });
        Console.WriteLine("All items before sorting:");
        Console.WriteLine(collection);

        Console.WriteLine("SelectionSorter result:");
        collection.Sort(new SelectionSorter<int>());
        Console.WriteLine(collection);

        Console.WriteLine("Quicksorter result:");
        collection.Sort(new Quicksorter<int>());
        Console.WriteLine(collection);

        Console.WriteLine("MergeSorter result:");
        collection.Sort(new MergeSorter<int>());
        Console.WriteLine(collection);

        Console.WriteLine("Linear search 101:");
        Console.WriteLine(collection.LinearSearch(101));

        Console.WriteLine("Binary search 101:");
        Console.WriteLine(collection.BinarySearch(101));

        Console.WriteLine("Shuffle:");
        collection.Shuffle();
        Console.WriteLine(collection);

        Console.WriteLine("Shuffle again:");
        collection.Shuffle();
        Console.WriteLine(collection);
    }
开发者ID:dgrigorov,项目名称:TelerikAcademy-1,代码行数:32,代码来源:Program.cs

示例9: TestLinearSearchWithExistingElementInMiddlePositionOddCountOfElements

        public void TestLinearSearchWithExistingElementInMiddlePositionOddCountOfElements()
        {
            var collection = new SortableCollection<int>(new[] { 49, 101, 33, 22, 11, 0, 17 });
            var result = collection.LinearSearch(22);

            Assert.IsTrue(result, "Element not found");
        }
开发者ID:zdzdz,项目名称:Data-Structures-and-Algorithms-HW,代码行数:7,代码来源:LinearSearchTests.cs

示例10: TestLinearSearchWithExistingRepeatingElementInCollection

        public void TestLinearSearchWithExistingRepeatingElementInCollection()
        {
            var collection = new SortableCollection<int>(new[] { 101, 101, 33, 22, 11, 0 });
            var result = collection.LinearSearch(101);

            Assert.IsTrue(result, "Element not found");
        }
开发者ID:zdzdz,项目名称:Data-Structures-and-Algorithms-HW,代码行数:7,代码来源:LinearSearchTests.cs

示例11: TestLinearSearchWithEmptyCollection

        public void TestLinearSearchWithEmptyCollection()
        {
            var collection = new SortableCollection<int>();
            var result = collection.LinearSearch(101);

            Assert.IsFalse(result, "Element found in empty collection");
        }
开发者ID:zdzdz,项目名称:Data-Structures-and-Algorithms-HW,代码行数:7,代码来源:LinearSearchTests.cs

示例12: TestLinearSearchWithExistingElementInFirstPositionEvenCountOfElements

        public void TestLinearSearchWithExistingElementInFirstPositionEvenCountOfElements()
        {
            var collection = new SortableCollection<int>(new[] { 49, 101, 33, 22, 11, 0 });
            var result = collection.LinearSearch(49);

            Assert.IsTrue(result, "Element not found");
        }
开发者ID:zdzdz,项目名称:Data-Structures-and-Algorithms-HW,代码行数:7,代码来源:LinearSearchTests.cs

示例13: TestBinarySearch_WithNonExistingItem

        public void TestBinarySearch_WithNonExistingItem()
        {
            var collection = new SortableCollection<int>(new[] { 22, 11, 101, 33, 0, 101 });

            var result = collection.LinearSearch(-11);
            Assert.AreNotEqual(true, result);
        }
开发者ID:Cecosam,项目名称:Csharp-Projects,代码行数:7,代码来源:SortableCollectionTest.cs

示例14: TestLinearSearchWithCollectionOfEqualElements

        public void TestLinearSearchWithCollectionOfEqualElements()
        {
            var collection = new SortableCollection<int>(new[] { 101, 101, 101, 101, 101 });
            var result = collection.LinearSearch(101);

            Assert.IsTrue(result, "Element not found");
        }
开发者ID:zdzdz,项目名称:Data-Structures-and-Algorithms-HW,代码行数:7,代码来源:LinearSearchTests.cs

示例15: TestWithMultipleItemsNotFound

        public void TestWithMultipleItemsNotFound()
        {
            SortableCollection<int> collection = new SortableCollection<int>(new int[] { 4, 11, -3, 7, 9, 23 });

            bool isFound = collection.LinearSearch(235);
            Assert.IsFalse(isFound);
        }
开发者ID:PetarPenev,项目名称:Telerik,代码行数:7,代码来源:UnitTestingLinearSearch.cs


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