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


C# List.RemoveAt方法代码示例

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


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

示例1: TestAdd

        public void TestAdd()
        {
            const int SampleSize = 1000000;

            Random Generator = new Random();

            SortedList<int> Tested = new SortedList<int>();
            List<int> Original = new List<int>();

            for (int x = 0; x < SampleSize; x++)
            {
                Original.Add(x);
            }
            List<int> OriginalClone = new List<int>(Original.ToArray());
            while (OriginalClone.Count > 0)
            {
                int Position = Generator.Next(0, OriginalClone.Count);
                Tested.Add(OriginalClone[Position]);
                OriginalClone.RemoveAt(Position);
            }

            if (Tested.Count != Original.Count)
            {
                throw new Exception("Count mismatch.");
            }

            for (int x = 0; x < Tested.Count; x++)
            {
                if (Tested[x] != Original[x])
                {
                    throw new Exception("Order mismatch.");
                }
            }
        }
开发者ID:hnefatl,项目名称:Driver,代码行数:34,代码来源:SortedListTest.cs

示例2: TestAdjacent

        public void TestAdjacent()
        {
            IMatrix<string> matrix = new Matrix<string>(3, 3);
            List<string> items = new List<string>(9);
            for (int i = 0; i < items.Capacity; i++)
            {
                items.Add(string.Format("{0}", i));
            }

            var index = 0;
            for (int y = 0; y < matrix.Rows; y++)
            {
                int x;
                for (x = 0; x < matrix.Columns; x++)
                {
                    matrix[x, y] = items[index++];
                }
            }

            var middleCell = matrix[1, 1];
            int middleIndex = matrix.IndexOf(middleCell);
            items.RemoveAt(middleIndex);

            var adjacentCells = matrix.GetAdjacentCells(middleCell);
            Assert.IsTrue(items.SequenceEqual(adjacentCells));
        }
开发者ID:mattmemmesheimer,项目名称:minesearch-reboot,代码行数:26,代码来源:MatrixTest.cs

示例3: TestPartialSortAdd_GrabTopValues

        public void TestPartialSortAdd_GrabTopValues()
        {
            Random random = new Random();

            // build a list
            var list = new List<int>(100);
            Sublist.Generate(100, i => random.Next(100)).AddTo(list.ToSublist());

            // create a list to hold the top three
            const int numberOfItems = 10;
            var destination = new List<int>(numberOfItems);

            // store the top three results
            Func<int, int, int> comparison = (x, y) => Comparer<int>.Default.Compare(y, x);
            list.ToSublist().PartialSort(numberOfItems, comparison).AddTo(destination.ToSublist());

            // grab the three largest values from largest to smallest
            var expected = new List<int>(numberOfItems);
            for (int round = 0; round != numberOfItems; ++round)
            {
                int maxIndex = list.ToSublist().Maximum();
                expected.Add(list[maxIndex]);
                list.RemoveAt(maxIndex);
            }

            Assert.IsTrue(expected.ToSublist().IsEqualTo(destination.ToSublist()), "The top values weren't grabbed.");
        }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:27,代码来源:PartialSortAddTester.cs

示例4: TestBinarySearch

		public void TestBinarySearch()
		{
			List<string> animalsUnordered = new List<string>(
				new[] { "Cat", "Dog", "Elephant", "Eagle", "Eel", "Zebra", "Yak", "Monkey", "Meerkat" });

			WordList words;

			while (animalsUnordered.Count > 0)
			{	
				words = new WordList(animalsUnordered);
				
				Assert.AreEqual(-1, words.BinarySearch("Unicorn", false, false), "Wrong index for: Unicorn");

				string[] animalsOrdered = animalsUnordered.OrderBy(a => a).ToArray();

				Assert.AreEqual(-1, words.BinarySearch("Dragon", false, false), "Wrong index for: Dragon");

				for (int expectedIndex = 0; expectedIndex < animalsOrdered.Length; expectedIndex++)
				{
					string word = animalsOrdered[expectedIndex];
					Assert.AreEqual(expectedIndex, words.BinarySearch(word, false, false), "Wrong index for: " + word);
				}

				animalsUnordered.RemoveAt(0);
			}

			words = new WordList(new[] { "Heaven", "Hell", "Hello", "Zebra", "ZOO" });

			Assert.AreEqual(0, words.BinarySearch("H", false, true), "Wrong index for: H");
			Assert.AreEqual(1, words.BinarySearch("HELL", false, true), "Wrong index for: H");
			Assert.AreEqual(3, words.BinarySearch("M", true, false), "Wrong index for: M");
			Assert.AreEqual(-1, words.BinarySearch("M", false, false), "Wrong index for: M");
		}
开发者ID:macintoxic,项目名称:Wordament-Solver,代码行数:33,代码来源:WordListTests.cs

示例5: CompareTo_ValidateSortingForAllPerms_Passes

        public void CompareTo_ValidateSortingForAllPerms_Passes()
        {
            List<StartingHandCombo> copy = new List<StartingHandCombo>();
            List<StartingHandCombo> sorted = new List<StartingHandCombo>();
            List<StartingHandCombo> shuffled = new List<StartingHandCombo>();

            foreach (StartingHandCombo h in _startingHandPermutations.Values)
            {
                copy.Add(h);
                sorted.Add(h);
            }

            Random iRand = new Random();
            do{
                int i = iRand.Next(copy.Count - 1);
                shuffled.Add(copy[i]);
                copy.RemoveAt(i);
            }while(copy.Count > 0);

            Assert.IsFalse(EqualLists(sorted, shuffled));

            shuffled.Sort();
            sorted.Sort();

            Assert.IsTrue(EqualLists(sorted, shuffled));
        }
开发者ID:KevinDKoch,项目名称:Poker,代码行数:26,代码来源:StartingHandComboTests.cs

示例6: TestHeap_PriorityQueue

        public void TestHeap_PriorityQueue()
        {
            Random random = new Random();

            // build a random list
            var list = new List<int>(100);
            Sublist.Generate(100, i => random.Next(100)).AddTo(list.ToSublist());

            // make a heap
            list.ToSublist().MakeHeap().InPlace();
            Assert.IsTrue(list.ToSublist().IsHeap(), "The list is not a heap."); // confirm we have a heap

            // let's push a value onto the heap and make it the highest priority
            list.Add(100);
            list.ToSublist().HeapAdd();
            Assert.AreEqual(100, list[0], "The value was not moved to the top of the heap.");
            Assert.IsTrue(list.ToSublist().IsHeap(), "The list is not a heap.");

            // now let's remove it
            list.ToSublist().HeapRemove();
            Assert.AreEqual(100, list[list.Count - 1], "The value not moved to the bottom of the heap.");
            Assert.AreEqual(list.Count - 1, list.ToSublist().IsHeap(), "Could not find the end of the heap.");
            list.RemoveAt(list.Count - 1);
            Assert.IsTrue(list.ToSublist().IsHeap(), "The list is not a heap.");

            // we can sort a heap
            list.ToSublist().HeapSort();
            Assert.IsTrue(list.ToSublist().IsSorted(), "The list was not sorted.");
        }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:29,代码来源:HeapTester.cs

示例7: FailedCallbackFires

        public void FailedCallbackFires()
        {
            List<int> order = new List<int> { 1, 2, 3, 4, 5 };
            List<int> errors = new List<int>();

            ThrottledProcessor<int> queue = new ThrottledProcessor<int>(
                100,
                (int value) => { throw new InvalidOperationException("This is the message"); },
                (int value) => Assert.Fail("The success path should never be called"),
                (int value, Exception ex) =>
                    {
                        Assert.AreEqual("This is the message", ex.Message);
                        errors.Add(value);
                    });

            foreach (int i in order)
            {
                queue.Add(i);
            }

            while (queue.Length > 0)
            {
                Thread.Sleep(100);
            }

            foreach (int expected in order)
            {
                int actual = errors.First();
                errors.RemoveAt(0);

                Assert.AreEqual(expected, actual, "The items were failed in the wrong order");
            }
        }
开发者ID:bubbafat,项目名称:TellHer,代码行数:33,代码来源:ThrottledProcessorTests.cs

示例8: ToArray

        private static int[] ToArray(int[] x, int[] y)
        {
            if(x.Length == 0 || y.Length == 0)
                return new int[] { };

            bool negative = (x[0] > 0) ^ (y[0] > 0);
            x[0] = Math.Abs(x[0]);
            y[0] = Math.Abs(y[0]);

            List<int> result = new List<int>(new int[x.Length + y.Length]);

            for(int i = x.Length - 1; i >= 0; i--)
            {
                for(int j = y.Length - 1; j >= 0; j--)
                {
                    result[i + j + 1] += x[i] * y[j];
                    result[i + j] += result[i + j + 1] / 10;
                    result[i + j + 1] %= 10;
                }
            }

            while (result.Count > 0 && result[0] == 0)
                result.RemoveAt(0);

            if (negative && result.Count > 0)
                result[0] *= -1;

            return result.ToArray();
        }
开发者ID:mmoroney,项目名称:Algorithms,代码行数:29,代码来源:MultiplyInteger.cs

示例9: PokerHandsChecker_HandWithLessThanFiveCardsShouldBeInvalid_False

        public void PokerHandsChecker_HandWithLessThanFiveCardsShouldBeInvalid_False()
        {
            IList<ICard> currentCards = new List<ICard>(this.cards);
            currentCards.RemoveAt(0);
            var currentHand = new Hand(currentCards);

            Assert.IsFalse(this.checker.IsValidHand(currentHand));
        }
开发者ID:VDGone,项目名称:TelerikAcademy-1,代码行数:8,代码来源:PokerHandsCheckerIsValidHandTests.cs

示例10: PokerHandsChecker_HandWithRepeatCardShouldBeInvalid_False

        public void PokerHandsChecker_HandWithRepeatCardShouldBeInvalid_False()
        {
            IList<ICard> currentCards = new List<ICard>(this.cards);
            currentCards.RemoveAt(0);
            currentCards.Add(new Card(currentCards[0].Face, currentCards[0].Suit));
            var currentHand = new Hand(currentCards);

            Assert.IsFalse(this.checker.IsValidHand(currentHand));
        }
开发者ID:VDGone,项目名称:TelerikAcademy-1,代码行数:9,代码来源:PokerHandsCheckerIsValidHandTests.cs

示例11: SetMazeConfigurationsTest

        public void SetMazeConfigurationsTest()
        {
            // Setup constant parameters
            const int maxTimesteps = 300;
            const int minSuccessDistance = 5;

            // Create some dummy structures/walls
            IList<MazeStructure> mazeStructures = new List<MazeStructure>
            {
                new MazeStructure(300, 300, 1)
                {
                    Walls = {new MazeStructureWall(5, 5, 10, 10), new MazeStructureWall(6, 6, 11, 11)}
                },
                new MazeStructure(300, 300, 1)
                {
                    Walls = {new MazeStructureWall(7, 7, 12, 12), new MazeStructureWall(8, 8, 13, 13)}
                },
                new MazeStructure(300, 300, 1)
                {
                    Walls = {new MazeStructureWall(9, 9, 14, 14), new MazeStructureWall(10, 10, 15, 15)}
                },
                new MazeStructure(300, 300, 1)
                {
                    Walls = {new MazeStructureWall(11, 11, 16, 16), new MazeStructureWall(12, 12, 17, 17)}
                },
                new MazeStructure(300, 300, 1)
                {
                    Walls = {new MazeStructureWall(13, 13, 18, 18), new MazeStructureWall(14, 14, 19, 19)}
                }
            };

            // Create the factory
            MultiMazeNavigationWorldFactory<BehaviorInfo> factory =
                new MultiMazeNavigationWorldFactory<BehaviorInfo>(maxTimesteps, minSuccessDistance);

            // Attempt setting the configurations
            factory.SetMazeConfigurations(mazeStructures);

            // Ensure number of mazes is 2
            Debug.Assert(factory.NumMazes == 5);

            // Remove one of the dummy structures
            mazeStructures.RemoveAt(0);

            // Call again with one of the mazes removed
            factory.SetMazeConfigurations(mazeStructures);

            // Ensure that no longer extant maze was removed
            Debug.Assert(factory.NumMazes == 4);
        }
开发者ID:jbrant,项目名称:SharpNoveltyNeat,代码行数:50,代码来源:MultiMazeNavigationWorldFactoryTests.cs

示例12: Get6Clock

        //        private int[] Get6Clock(int i)
        //      {
        //        return Permutation(i).
        //  }
        private int[] Get6Clock(int n)
        {
            int[] dividors = { 720, 120, 24, 6, 2, 1, 1 };
            List<int> numbers = new List<int>(new int[] {1,2,3,4,5,6});
            int[] result = new int[5];
            int index;

            for (int i = 0; i < 5; i++)
            {
                index = (n%dividors[i])/dividors[i+1];
                result[i] = numbers[index];
                numbers.RemoveAt(index);
            }
            return result;
        }
开发者ID:jpuchta,项目名称:Algorithmics,代码行数:19,代码来源:FourClocksTests.cs

示例13: getTask

        public string getTask(string[] list, int n)
        {
            List<string> tasks = new List<string>();
            foreach (string task in list)
                tasks.Add(task);

            int index = 0;

            while(tasks.Count > 1)
            {
                index = (index + n - 1) % (tasks.Count);
                tasks.RemoveAt(index);
            }

            return tasks[0];
        }
开发者ID:mmoroney,项目名称:TopCoder,代码行数:16,代码来源:BusinessTasks.cs

示例14: MakeRandomInsertList

 public static IEnumerable<int> MakeRandomInsertList(int count)
 {
     List<int> ret = new List<int>(count);
     List<int> sorted = new List<int>(count);
     var rng = new Random();
     for (int i = 0; i < count; i++)
     {
         sorted.Add(i);
     }
     while (sorted.Count > 0)
     {
         var sampleIx = rng.Next(sorted.Count);
         ret.Add(sorted[sampleIx]);
         sorted.RemoveAt(sampleIx);
     }
     return ret;
 }
开发者ID:Garwin4j,项目名称:BrightstarDB,代码行数:17,代码来源:TestUtils.cs

示例15: GenerateAnswer

 private void GenerateAnswer(bool[,] dp, List<string[]> result, int start, List<string> cur, string input)
 {
     for (int end = start; end < input.Length; end++)
     {
         if (dp[start, end])
         {
             cur.Add(input.Substring(start, end - start + 1));
             if (end == input.Length - 1)
             {
                 result.Add(cur.ToArray());
             }
             else
             {
                 GenerateAnswer(dp, result, end + 1, cur, input);
             }
             cur.RemoveAt(cur.Count - 1);
         }
     }
 }
开发者ID:dullcat,项目名称:leetcode_csharp,代码行数:19,代码来源:Q131_PalindromePartitioning.cs


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