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


C# List.RemoveAt方法代码示例

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


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

示例1: sendData

		/**
		 * correlates the data based on timestamps
		 * handling just 2 lists right now.
		 * TODO: eventually we would want to handle all the lists in the directory
		 */

		public List<TransponderData> sendData (List<TransponderData>  dataList )  
		{
			var listToSend = new List<TransponderData> ();
			listToSend.Add (dataList [0]);

			for (int i = 1; i<dataList.Count; i++) 
			{
				if((dataList [0].Timestamp).Equals (dataList [i].Timestamp))
				{
					listToSend.Add (dataList[i]);
					dataList.RemoveAt(i);
				}
				else
				{
					break;
				}
			}

			dataList.RemoveAt(0);

			BroadcastDataEvent (listToSend);
			System.Threading.Thread.Sleep (200);

			return dataList;
		}
开发者ID:dsteeve,项目名称:teamDrei-4250,代码行数:31,代码来源:MockTransponder.cs

示例2: TestRandomAllocation

 public void TestRandomAllocation()
 {
     int repeatCount = 10000;
     int range = 100;
     IList<int> allocated = new List<int>();
     IntAllocator intAllocator = new IntAllocator(0, range);
     Random rand = new Random();
     while (repeatCount-- > 0)
     {
         if (rand.Next(2) == 0)
         {
             int a = intAllocator.Allocate();
             if (a > -1)
             {
                 Assert.False(allocated.Contains(a));
                 allocated.Add(a);
             }
         }
         else if (allocated.Count > 0)
         {
             int a = allocated[0];
             intAllocator.Free(a);
             allocated.RemoveAt(0);
         }
     }
 }
开发者ID:hanxinimm,项目名称:rabbitmq-dotnet-client,代码行数:26,代码来源:TestIntAllocator.cs

示例3: UniqueTreeTest

		public void UniqueTreeTest ()
		{
			// Unique tree
			var expectedRemain = new List<double>();
			var tree = new Tree<double, string>(
				new TreeMemoryNodeManager<double, string>(2, Comparer<double>.Default)
			);

			// Insert random numbers
			for (var i = 0; i < 1000; i++) {
				tree.Insert (i, i.ToString());
				expectedRemain.Add (i);
			}

			// Start deleting randomly
			var rnd = new Random ();
			for (var i = 0; i < 1000; i++) {
				var deleteAt = rnd.Next (0, expectedRemain.Count);
				var keyToDelete = expectedRemain[deleteAt];
				expectedRemain.RemoveAt (deleteAt);
				tree.Delete (keyToDelete);
				var remain = (from entry in tree.LargerThanOrEqualTo(0) select entry.Item1).ToArray();
				Assert.IsTrue (remain.SequenceEqual (expectedRemain));
			}

			Assert.Throws<InvalidOperationException>(delegate {
				tree.Delete (888, "888");
			});
		}
开发者ID:K-Eo,项目名称:FooDB,代码行数:29,代码来源:BTreeDeletionTest.cs

示例4: ListBasics

        public void ListBasics()
        {
            var names =  new List<string>();
            names.Add("fred");
            Assert.AreEqual("fred", names[0]);

            Assert.AreEqual(1, names.Count);
            names.Add("betty");
            Assert.AreEqual(2, names.Count);

            names.RemoveAt(0); // After we remove Fred, we have Bett
            Assert.AreEqual(1, names.Count);
            Assert.AreEqual("betty", names[0]);

            names[0] = "barney";

            //foreach (string name in names)
            //{
            //    Console.WriteLine(name);
            //}

            //var integers = new List<int>(50) {10, 20};
            //Equivalent to:
            var tmp = new List<int>(50);
            tmp.Add(10);
            tmp.Add(20);
            var integers = tmp;

            integers = new List<int>() { integers.Count };
            Assert.AreEqual(2, integers[0]);
        }
开发者ID:Zedronar,项目名称:skeet-csharp4,代码行数:31,代码来源:ListBasics.cs

示例5: FindTop10VideoFriends_CountOfListVideoLess10

 public void FindTop10VideoFriends_CountOfListVideoLess10()
 {
     List<Video> listVideo = new List<Video>();
     listVideo = FillingListVideo(listVideo);
     listVideo.RemoveAt(9);
     Assert.AreEqual(listVideo, control.FindTop10Video(listVideo));
 }
开发者ID:KiraTanaka,项目名称:VK,代码行数:7,代码来源:ControlTests.cs

示例6: GetSiblings

        public void GetSiblings()
        {
            var a = new List<IPAddress> {
                new IPAddress(Ba(192, 168, 178, 0)),
                new IPAddress(Ba(192, 168, 178, 1)),
                new IPAddress(Ba(192, 168, 178, 2)),
                new IPAddress(Ba(192, 168, 178, 3)),
                new IPAddress(Ba(192, 168, 178, 4)),
                new IPAddress(Ba(192, 168, 178, 5)),
                new IPAddress(Ba(192, 168, 178, 6)),
                new IPAddress(Ba(192, 168, 178, 7))
            };
            var ip = new IPAddress(Ba(192, 168, 178, 5));
            var mask = new NetMask(255, 255, 255, 248);

            TestSiblings(a, ip, mask);

            a = new List<IPAddress> {
                new IPAddress(Ba(10, 20, 3, 192)),
             // new IPAddress(Ba(10, 20, 3, 193)),
                new IPAddress(Ba(10, 20, 3, 194)),
                new IPAddress(Ba(10, 20, 3, 195)),
                new IPAddress(Ba(10, 20, 3, 196)),
                new IPAddress(Ba(10, 20, 3, 197)),
                new IPAddress(Ba(10, 20, 3, 198)),
                new IPAddress(Ba(10, 20, 3, 199)),
                new IPAddress(Ba(10, 20, 3, 200)),
                new IPAddress(Ba(10, 20, 3, 201)),
                new IPAddress(Ba(10, 20, 3, 202)),
                new IPAddress(Ba(10, 20, 3, 203)),
                new IPAddress(Ba(10, 20, 3, 204)),
                new IPAddress(Ba(10, 20, 3, 205)),
                new IPAddress(Ba(10, 20, 3, 206)),
                new IPAddress(Ba(10, 20, 3, 207))
            };
            ip = new IPAddress(Ba(10, 20, 3, 193));
            mask = new NetMask(255, 255, 255, 240);

            TestSiblings(a, ip, mask, SiblingOptions.IncludeNetworkIdentifier | SiblingOptions.IncludeBroadcast);

            a.RemoveAt(a.Count - 1);
            TestSiblings(a, ip, mask, SiblingOptions.IncludeNetworkIdentifier);

            a.RemoveAt(0);
            TestSiblings(a, ip, mask, SiblingOptions.ExcludeAll);
        }
开发者ID:MuhammadWaqar,项目名称:wake-on-lan,代码行数:46,代码来源:NetMaskExtensionsTests.cs

示例7: HasSameContentsAs

 public void HasSameContentsAs()
 {
     var listA = new List<string> { "a", "z", "alpha" };
     var listB = new List<string> { "alpha", "a", "z",  };
     Assert.IsTrue(listA.HasSameContentsAs(listB), "same content, diff order");
     listA.RemoveAt(0);
     Assert.IsFalse(listA.HasSameContentsAs(listB), "not the same content");
     listA.Add("b");
     Assert.IsFalse(listA.HasSameContentsAs(listB), "not the same content");
 }
开发者ID:johnmensen,项目名称:TradeSharp,代码行数:10,代码来源:MathExtensions.cs

示例8: TestMultipleWriterReader

        public virtual void TestMultipleWriterReader()
        {
            Counter bytesUsed = Util.Counter.NewCounter();
            IntBlockPool pool = new IntBlockPool(new ByteTrackingAllocator(bytesUsed));
            for (int j = 0; j < 2; j++)
            {
                IList<StartEndAndValues> holders = new List<StartEndAndValues>();
                int num = AtLeast(4);
                for (int i = 0; i < num; i++)
                {
                    holders.Add(new StartEndAndValues(Random().Next(1000)));
                }
                IntBlockPool.SliceWriter writer = new IntBlockPool.SliceWriter(pool);
                IntBlockPool.SliceReader reader = new IntBlockPool.SliceReader(pool);

                int numValuesToWrite = AtLeast(10000);
                for (int i = 0; i < numValuesToWrite; i++)
                {
                    StartEndAndValues values = holders[Random().Next(holders.Count)];
                    if (values.ValueCount == 0)
                    {
                        values.Start = writer.StartNewSlice();
                    }
                    else
                    {
                        writer.Reset(values.End);
                    }
                    writer.WriteInt(values.NextValue());
                    values.End = writer.CurrentOffset;
                    if (Random().Next(5) == 0)
                    {
                        // pick one and reader the ints
                        AssertReader(reader, holders[Random().Next(holders.Count)]);
                    }
                }

                while (holders.Count > 0)
                {
                    int randIndex = Random().Next(holders.Count);
                    StartEndAndValues values = holders[randIndex];
                    holders.RemoveAt(randIndex);
                    AssertReader(reader, values);
                }
                if (Random().NextBoolean())
                {
                    pool.Reset(true, false);
                    Assert.AreEqual(0, bytesUsed.Get());
                }
                else
                {
                    pool.Reset(true, true);
                    Assert.AreEqual(IntBlockPool.INT_BLOCK_SIZE * RamUsageEstimator.NUM_BYTES_INT, bytesUsed.Get());
                }
            }
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:55,代码来源:TestIntBlockPool.cs

示例9: TestModifyMaster

        public void TestModifyMaster()
        {
            List<string> strings = new List<string>(new string[] { "a", "b", "c" });
            ReadOnlyList<String> read = new ReadOnlyList<string>(strings, false);

            Assert.AreEqual(3, read.Count);
            strings.RemoveAt(2);
            Assert.AreEqual(2, read.Count);
            Assert.AreEqual("a", read[0]);
            Assert.AreEqual("b", read[1]);

            Assert.AreEqual("a,b", String.Join(",", read.Clone().ToArray()));
        }
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:13,代码来源:TestReadOnlyList.cs

示例10: List_Has_Dynamic_Size

        public void List_Has_Dynamic_Size()
        {
            var names = new List<string>();

            names.Add("fred");
            Assert.That(names.Count, Is.EqualTo(1));

            names.Add("betty");
            Assert.That(names.Count, Is.EqualTo(2));

            names.RemoveAt(0);
            Assert.That(names.Count, Is.EqualTo(1));
        }
开发者ID:xianxingg,项目名称:JonSkeetCSharp4Examples,代码行数:13,代码来源:ListAndDictionaryExample.cs

示例11: TestExecute

        public void TestExecute()
        {
            var list = new List<int> ();
            Action<int,int> exeAction = (i, v) => list.Insert (i, v);
            Action<int,int> undoAction = (i, v) => list.RemoveAt (i);

            var command = new Command<int,int>(0,4,exeAction, undoAction);
            command.Execute ();
            Assert.AreEqual (1, list.Count);
            Assert.AreEqual (list[0],4);

            command.Undo ();
            Assert.AreEqual (0, list.Count);
        }
开发者ID:magerate,项目名称:Commands,代码行数:14,代码来源:Command2Test.cs

示例12: Test

        public void Test()
        {
            var rand = new Random(3);

            List<string> list1 = new List<string>();
            WeakList<string> list2 = new WeakList<string>();

            for (int x = 0; x < 1000; x++)
            {
                var str = x.ToString();
                list1.Add(str);
                list2.Add(str);

                if (!list1.SequenceEqual(list2))
                    throw new Exception("Lists are not the same.");
            }

            for (int x = 1000; x < 2000; x++)
            {
                var str = x.ToString();
                var removeItem = list1[rand.Next(list1.Count)];
                list1.Remove(removeItem);
                list2.Remove(removeItem);

                if (!list1.SequenceEqual(list2))
                    throw new Exception("Lists are not the same.");

                list1.Add(str);
                list2.Add(str);

                if (!list1.SequenceEqual(list2))
                    throw new Exception("Lists are not the same.");
            }

            for (int x = 0; x < 100; x++)
            {
                list1.RemoveAt(rand.Next(list1.Count));
                GC.Collect();

                if (!list1.SequenceEqual(list2))
                    throw new Exception("Lists are not the same.");
            }


            list2.Clear();
            foreach (var data in list2)
                throw new Exception();
        }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:48,代码来源:WeakListTest.cs

示例13: Matches_ActualMoreThanExpectation_Failure

        public void Matches_ActualMoreThanExpectation_Failure()
        {
            var discovery = new DiscoveryRequestFactory().BuildDirect(
                        ConnectionStringReader.GetAdomd()
                        , DiscoveryTarget.Perspectives
                        , new List<IFilter>());

            var expectedStrings = new string[] { "Adventure Works", "Channel Sales", "Direct Sales", "Finance", "Sales Summary", "Sales Targets" };
            var expected = new List<string>();
            expected.AddRange(expectedStrings);
            expected.RemoveAt(0);
            var ctr = new EquivalentToConstraint(expected);

            //Method under test
            Assert.That(ctr.Matches(discovery), Is.False);
        }
开发者ID:zyh329,项目名称:nbi,代码行数:16,代码来源:EquivalentToConstraintTest.cs

示例14: MergeKLists

        public ListNode MergeKLists(ListNode[] lists)
        {
            if (lists == null || lists.Length == 0) return null;
            if (lists.Length == 1) return lists[0];

            ListNode head = null;
            ListNode current = null;

            var toManipulate = new List<ListNode>(lists.Where(l => l != null));
            while (toManipulate.Count > 0)
            {
                int lowestValue = int.MaxValue;
                int lowestIdx = 0;
                for (var idx = 0; idx < toManipulate.Count; ++idx)
                {
                    if (toManipulate[idx].val < lowestValue)
                    {
                        lowestValue = toManipulate[idx].val;
                        lowestIdx = idx;
                    }
                }

                if (head == null)
                {
                    head = toManipulate[lowestIdx];
                    current = head;
                }
                else
                {
                    current.next = toManipulate[lowestIdx];
                    current = current.next;
                }

                var next = toManipulate[lowestIdx].next;
                if (next == null)
                {
                    toManipulate.RemoveAt(lowestIdx);
                }
                else
                {
                    toManipulate[lowestIdx] = next;
                }
            }

            return head;
        }
开发者ID:kajones,项目名称:Puzzles,代码行数:46,代码来源:Problem_0023_MergeKSortedLists.cs

示例15: AllNodesAreCoveredDuringIteration

        public void AllNodesAreCoveredDuringIteration()
        {
            var nodeArray = new List<Node>();
            for (var i = 0; i < 5; ++i)
            {
                var node = new MockNode();
                nodeArray.Add(node);
                _nodes.Add(node);
            }

            for (var node = _nodes.Head; node != null; node = node.Next)
            {
                var index = nodeArray.IndexOf(node);
                nodeArray.RemoveAt(index);
            }
            Assert.AreEqual(0, nodeArray.Count);
        }
开发者ID:kinlam,项目名称:RUN-SHOOT,代码行数:17,代码来源:NodeListTests.cs


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