• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SortableCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Main

        public static void Main(string[] args)
        {
            const int NumberOfElementsToSort = 22;
            const int MaxValue = 150;

            var array = new int[NumberOfElementsToSort];

            for (int i = 0; i < NumberOfElementsToSort; i++)
            {
                array[i] = Random.Next(MaxValue);
            }

            var collectionToSort = new SortableCollection<int>(array);
            // !!!!!!!!!!!!!! collectionToSort.Sort(new BucketSorter { Max = MaxValue });

            Console.WriteLine(collectionToSort);

            var collection = new SortableCollection<int>(2, -1, 5, 0, -3);
            Console.WriteLine(collection);

            // collection.Sort(new Quicksorter<int>());
            collection.Sort(new InsertionSorter<int>());
            Console.WriteLine(collection);

            Console.WriteLine(collection.InterpolationSearch(0));
        }
开发者ID:flyer87,项目名称:Alghoritms,代码行数:26,代码来源:SortableCollectionPlayground.cs


示例2: 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


示例3: Main

        public static void Main(string[] args)
        {
            const int NumberOfElementsToSort = 22;
            const int MaxValue = 150;

            var array = new int[NumberOfElementsToSort];

            for (int i = 0; i < NumberOfElementsToSort; i++)
            {
                array[i] = Random.Next(MaxValue);
            }

            var collectionToSort = new SortableCollection<int>(array);
            collectionToSort.Sort(new BucketSorter { Max = MaxValue });

            Console.WriteLine(collectionToSort);

            var collectionToShuffle = new SortableCollection<int>(1, 2, 3, 4, 5);
            Console.WriteLine("Before shufflin` " + collectionToShuffle);
            collectionToShuffle.Shuffle();
            Console.WriteLine("After shufflin` " + collectionToShuffle);

            var collection = new SortableCollection<int>(2, -1, 5, 0, -3);
            Console.WriteLine(collection);

            // collection.Sort(new Quicksorter<int>());
            collection.Sort(new InsertionSorter<int>());
            Console.WriteLine(collection);
        }
开发者ID:aanguelov,项目名称:AlgorithmsHomeworks,代码行数:29,代码来源:SortableCollectionPlayground.cs


示例4: 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


示例5: TestSortWithMultipleElementsMultipleTimes

        public void TestSortWithMultipleElementsMultipleTimes()
        {
            const int NumberOfAttempts = 10000;
            const int MaxNumberOfElements = 1000;

            for (int i = 0; i < NumberOfAttempts; i++)
            {
                var numberOfElements = Random.Next(0, MaxNumberOfElements + 1);

                List<int> originalElements = new List<int>(MaxNumberOfElements);

                for (int j = 0; j < numberOfElements; j++)
                {
                    originalElements.Add(Random.Next(int.MinValue, int.MaxValue));
                }

                var collection = new SortableCollection<int>(originalElements);

                originalElements.Sort();
                collection.Sort(TestSorter);

                CollectionAssert.AreEqual(
                    originalElements,
                    collection.ToArray(),
                    "Sort method should sort the elements in ascending order.");
            }
        }
开发者ID:vangelov-i,项目名称:Fundamentals,代码行数:27,代码来源:SortTests.cs


示例6: 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


示例7: 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


示例8: Test2SectionSortMethod

 public void Test2SectionSortMethod()
 {
     var collection1 = new SortableCollection<int>(new[] { 22, 13, 23, 45, -55, 90, 100, 101, -12, 55, 44 });
     collection1.Sort(new SelectionSorter<int>());
     var testCollection = new SortableCollection<int>(new[] { -55, -12, 13, 22, 23, 44, 45, 55, 90, 100, 101 });
     Assert.Equals(testCollection, collection1);
 }
开发者ID:KTsolev,项目名称:SortringAlgoritmsHomework,代码行数:7,代码来源:UnitTest1.cs


示例9: Test3SectionSortMethod

 public void Test3SectionSortMethod()
 {
     var collection1 = new SortableCollection<string>(new[] { "aaaa", "cccc", "dddd", "cccc", "caaa", "aacc", "bbdd", "ccff", "eerr", "rrtt", "assdd" });
     collection1.Sort(new SelectionSorter<string>());
     var testCollection = new SortableCollection<int>(new[] { -55, -12, 13, 22, 23, 44, 45, 55, 90, 100, 101 });
     Assert.Equals(testCollection, collection1);
 }
开发者ID:KTsolev,项目名称:SortringAlgoritmsHomework,代码行数:7,代码来源:UnitTest1.cs


示例10: SelectionSorterTestWithOneElement

 public void SelectionSorterTestWithOneElement()
 {
     SortableCollection<int> collection = new SortableCollection<int>(new int[] { 5 });
     collection.Sort(new SelectionSorter<int>());
     Assert.AreEqual(1, collection.Items.Count);
     Assert.AreEqual(5, collection.Items[0]);
 }
开发者ID:bahtev,项目名称:TelerikAcademy,代码行数:7,代码来源:SelectionSorterTest.cs


示例11: Test1SectionSortMethod

 public void Test1SectionSortMethod()
 {
     var collection = new SortableCollection<int>(new[] { 22, 13 });
     collection.Sort(new SelectionSorter<int>());
     var testCollection = new SortableCollection<int>(new[] { 13, 22 });
     Assert.Equals(collection,testCollection);
 }
开发者ID:KTsolev,项目名称:SortringAlgoritmsHomework,代码行数:7,代码来源:UnitTest1.cs


示例12: Main

        public static void Main(string[] args)
        {
            const int NumberOfElementsToSort = 22;
            const int MaxValue = 150;

            var array = new int[NumberOfElementsToSort];

            for (int i = 0; i < NumberOfElementsToSort; i++)
            {
                array[i] = Random.Next(MaxValue);
            }

            var collectionToSort = new SortableCollection<int>(array);

            collectionToSort.Sort(new BucketSorter { Max = MaxValue });
            Console.WriteLine(collectionToSort);

            var collection = new SortableCollection<int>(2, -1, 5, 0, -3);
            collection = new SortableCollection<int>(3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48);
            Console.WriteLine(collection);

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

            //collection.Sort(new Quicksorter<int>());
            //Console.WriteLine(collection);
        }
开发者ID:ttitto,项目名称:DataStructuresAndAlgorithms,代码行数:27,代码来源:SortableCollectionPlayground.cs


示例13: 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


示例14: TestWithASingleItemNotFound

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

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


示例15: MergeSortShouldWorkCorrectlyWithEmptyCollection

        public void MergeSortShouldWorkCorrectlyWithEmptyCollection()
        {
            var collection = new SortableCollection<int>();
            collection.Sort(new MergeSorter<int>());

            Assert.AreEqual(0, collection.Items.Count, "Collection is not empty after sorting!");
        }
开发者ID:MarinaGeorgieva,项目名称:TelerikAcademy,代码行数:7,代码来源:MergeSorterTests.cs


示例16: TestBinarySearchWithExistingElementInMiddlePositionEvenCountOfElements

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

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


示例17: Main

        public static void Main()
        {
            List<int> numbers = new List<int>() {1,3,4,6,7,8,9,10,23,42};

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


示例18: BinarySearchShouldWorkCorrectlyWithEmptyCollection

        public void BinarySearchShouldWorkCorrectlyWithEmptyCollection()
        {
            var collection = new SortableCollection<int>();
            var found = collection.BinarySearch(21);

            Assert.IsFalse(found, "Element is found in empty collection!");
        }
开发者ID:MarinaGeorgieva,项目名称:TelerikAcademy,代码行数:7,代码来源:BinarySearchTests.cs


示例19: 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


示例20: TestSelectionSortingWithEmptyCollection

        public void TestSelectionSortingWithEmptyCollection()
        {
            var collection = new SortableCollection<int>();
            collection.Sort(new SelectionSorter<int>());

            Assert.AreEqual(0, collection.Items.Count, "Collection is not empty after sorting");
        }
开发者ID:kiko81,项目名称:Teleric-Academy-Homeworks,代码行数:7,代码来源:SelectionSortTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SortedDictionary类代码示例发布时间:2022-05-24
下一篇:
C# SortableBindingList类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap