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


C# List.RemoveRange方法代码示例

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


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

示例1: GetClosest

    /// <summary>Returns at most the 4 closest addresses in order.</summary>
    protected List<Connection> GetClosest(List<Connection> cons)
    {
      List<Connection> closest = new List<Connection>(cons);

      // Since MeasuredLatency could change the duration of our sorting we make
      // a copy as necessary
      Dictionary<Connection, double> latencies = new Dictionary<Connection, double>();

      Comparison<Connection> comparer = delegate(Connection x, Connection y) {
        double lat_x, lat_y;
        if(!latencies.TryGetValue(x, out lat_x)) {
          lat_x = _ncservice.GetMeasuredLatency(x.Address);
          latencies[x] = lat_x;
        }
        if(!latencies.TryGetValue(y, out lat_y)) {
          lat_y = _ncservice.GetMeasuredLatency(y.Address);
          latencies[y] = lat_y;
        }

        // Remember that smaller is better but -1 is bad...
        // If either is smaller than 0 invert the comparison..
        if(lat_x < 0 || lat_y < 0) {
          return lat_y.CompareTo(lat_x);
        } else {
          return lat_x.CompareTo(lat_y);
        }
      };

      closest.Sort(comparer);
      if(closest.Count > 4) {
        closest.RemoveRange(4, closest.Count - 4);
      }
      return closest;
    }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:35,代码来源:NCTunnelOverlap.cs

示例2: GetOldest

    protected List<Connection> GetOldest(List<Connection> cons)
    {
      List<Connection> oldest = new List<Connection>(cons);
      Comparison<Connection> comparer = delegate(Connection x, Connection y) {
        return x.CreationTime.CompareTo(y.CreationTime);
      };

      oldest.Sort(comparer);
      if(oldest.Count > 4) {
        oldest.RemoveRange(0, oldest.Count - 4);
      }
      return oldest;
    }
开发者ID:pstjuste,项目名称:brunet,代码行数:13,代码来源:RelayOverlap.cs

示例3: Listen

 private static List<LogLine> Listen(ILogFile logFile)
 {
     var data = new List<LogLine>();
     var listener = new Mock<ILogFileListener>();
     listener.Setup(x => x.OnLogFileModified(It.IsAny<ILogFile>(), It.IsAny<LogFileSection>()))
             .Callback((ILogFile file, LogFileSection section) =>
                 {
                     if (section.IsReset)
                     {
                         data.Clear();
                     }
                     else if (section.InvalidateSection)
                     {
                         data.RemoveRange((int) section.Index, section.Count);
                     }
                     else
                     {
                         data.AddRange(file.GetSection(section));
                     }
                 });
     logFile.AddListener(listener.Object, TimeSpan.Zero, 1);
     return data;
 }
开发者ID:Kittyfisto,项目名称:Tailviewer,代码行数:23,代码来源:MergedLogFileTest.cs

示例4: NextUnusedInUnchartedThreeParaText

		public void NextUnusedInUnchartedThreeParaText()
		{
			const int kmaxAnnotations = 20;
			StTxtPara para1 = MakeParagraph();
			StTxtPara para2 = MakeParagraph();
			StTxtPara para3 = MakeParagraph();
			List<int> wfics1 = MakeNWfics(para1, null, 3);
			List<int> wfics2 = MakeNWfics(para2, null, 2);
			List<int> wfics3 = MakeNWfics(para3, null, 4);

			// Make another annotation on the text that is NOT a wfic.
			MakeAnnotation(para2, CmBaseAnnotation.CreateFromDBObject(Cache, wfics2[wfics2.Count - 1]),
				CmAnnotationDefn.TextSegment(Cache));

			// And make an indirect annotation on some of them that is NOT a CCA.
			MakeIndirectAnnotation(wfics2.ToArray(), CmAnnotationDefn.Punctuation(Cache));

			List<int> expected = new List<int>(9);
			expected.AddRange(wfics1);
			expected.AddRange(wfics2);
			expected.AddRange(wfics3);
			int[] result = m_ccl.NextUnchartedInput(kmaxAnnotations);
			Assert.AreEqual(expected.ToArray(), result);

			// OK, two things in this test :-)
			int[] result2 = m_ccl.NextUnchartedInput(7);
			expected.RemoveRange(7, 2);
			Assert.AreEqual(expected.ToArray(), result2, "length limit failed");
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:29,代码来源:ConstituentChartDatabaseTests.cs

示例5: FEvaluate

        /* F  E V A L U A T E */
        /*----------------------------------------------------------------------------
            %%Function: FEvaluate
            %%Qualified: AzLog.AzLogFilter.FEvaluate
            %%Contact: rlittle

            Evaluate the item against the filter, return true if it matches
        ----------------------------------------------------------------------------*/
        public bool FEvaluate(ILogFilterItem ilf)
        {
            // evaluate the list using a stack...
            List<bool> plfStack = new List<bool>();

            for (int i = 0; i < m_plazlfo.Count; i++)
                {
                AzLogFilterOperation azlfo = m_plazlfo[i];

                switch (azlfo.Op)
                    {
                    case AzLogFilterOperation.OperationType.Value:
                        plfStack.Add(azlfo.Condition.FEvaluate(ilf));
                        break;
                    case AzLogFilterOperation.OperationType.And:
                        {
                        bool f1 = plfStack[plfStack.Count - 1];
                        bool f2 = plfStack[plfStack.Count - 2];
                        plfStack.RemoveRange(plfStack.Count - 2, 2);
                        plfStack.Add(f1 && f2);
                        break;
                        }
                    case AzLogFilterOperation.OperationType.Or:
                        {
                        bool f1 = plfStack[plfStack.Count - 1];
                        bool f2 = plfStack[plfStack.Count - 2];
                        plfStack.RemoveRange(plfStack.Count - 2, 2);
                        plfStack.Add(f1 || f2);
                        break;
                        }
                    }
                }
            if (plfStack.Count > 1)
                throw new Exception("expression did not reduce");

            return plfStack[0];
        }
开发者ID:rlittletht,项目名称:AzLog,代码行数:45,代码来源:AzLogFilter.cs

示例6: NextUnusedInUnchartedThreeParaText

		public void NextUnusedInUnchartedThreeParaText()
		{
			var para1 = MakeParagraphSpecificContent("Two segments. Here.");
			var para2 = MakeParagraphSpecificContent("Two words.");
			var para3 = MakeParagraphSpecificContent("We want four words.");
			var seg1 = para1.SegmentsOS[0];
			var seg2 = para1.SegmentsOS[1];
			var seg3 = para2.SegmentsOS[0];
			var seg4 = para3.SegmentsOS[0];

			var expected = new List<AnalysisOccurrence>(9)
							{
								new AnalysisOccurrence(seg1, 0), // Two
								new AnalysisOccurrence(seg1, 1), // segments
								new AnalysisOccurrence(seg2, 0), // Here
								new AnalysisOccurrence(seg3, 0), // Two
								new AnalysisOccurrence(seg3, 1), // words
								new AnalysisOccurrence(seg4, 0), // We
								new AnalysisOccurrence(seg4, 1), // want
								new AnalysisOccurrence(seg4, 2), // four
								new AnalysisOccurrence(seg4, 3)  // words
							};
			// SUT
			var result = m_ccl.NextUnchartedInput(kmaxWords);
			Assert.AreEqual(expected.ToArray(), result);

			// OK, two things in this test :-)
			expected.RemoveRange(7, 2);
			// SUT2
			var result2 = m_ccl.NextUnchartedInput(7);
			Assert.AreEqual(expected.ToArray(), result2, "length limit failed");
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:32,代码来源:ConstituentChartDatabaseTests.cs

示例7: TestInstanceTracking

        public void TestInstanceTracking()
        {
            TestViewModel rootViewModel = new TestViewModel ();
            bridge.ShowView ("TestView.html", rootViewModel);
            int numRootViewModels = 0;
            int numChildViewModels = 0;
            CountInstances (out numRootViewModels, out numChildViewModels);
            Assert.AreEqual (1, numRootViewModels, "Should have been aware of exactly 1 root view model");
            Assert.AreEqual (0, numChildViewModels, "Should not have been aware of ANY child view models yet");

            Assert.AreEqual (1, webBrowser.GetNumScriptFunctionInvocations ("createInstance"));
            Assert.AreEqual (0, webBrowser.GetNumScriptFunctionInvocations ("releaseInstance"));

            rootViewModel.ChildViewModel = new TestChildViewModel ();
            CountInstances (out numRootViewModels, out numChildViewModels);
            Assert.AreEqual (1, numRootViewModels, "Should have been aware of exactly 1 root view model");
            Assert.AreEqual (1, numChildViewModels, "Should have been aware of exactly 1 child view model");
            Assert.AreEqual (2, webBrowser.GetNumScriptFunctionInvocations ("createInstance"));
            Assert.AreEqual (0, webBrowser.GetNumScriptFunctionInvocations ("releaseInstance"));

            rootViewModel.ChildViewModel = new TestChildViewModel ();
            CountInstances (out numRootViewModels, out numChildViewModels);
            Assert.AreEqual (1, numRootViewModels, "Should have been aware of exactly 1 root view model");
            Assert.AreEqual (1, numChildViewModels, "Should have been aware of exactly 1 child view model");

            rootViewModel.ChildViewModel = null;
            CountInstances (out numRootViewModels, out numChildViewModels);
            Assert.AreEqual (1, numRootViewModels, "Should have been aware of exactly 1 root view model");
            Assert.AreEqual (0, numChildViewModels, "Should no longer have been aware of any child view models");

            List<TestChildViewModel> childCollection = new List<TestChildViewModel> ();
            for (int i = 0; i < 100; i++)
                childCollection.Add (new TestChildViewModel ());
            rootViewModel.ChildViewModels = childCollection;
            rootViewModel.ChildViewModel = new TestChildViewModel ();
            foreach (ViewModelInstance instance in SpinnakerConfiguration.CurrentConfig.ViewModelManager.CurrentInstances)
                Assert.AreEqual (1, instance.RefCount, "Initial ref count of child should be 1");

            CountInstances (out numRootViewModels, out numChildViewModels);
            Assert.AreEqual (1, numRootViewModels, "Should have been aware of exactly 1 root view model");
            Assert.AreEqual (101, numChildViewModels, "Should have been aware of all child view models");

            childCollection.RemoveRange (0, 50);
            rootViewModel.ChildViewModels = childCollection;
            CountInstances (out numRootViewModels, out numChildViewModels);
            Assert.AreEqual (1, numRootViewModels, "Should have been aware of exactly 1 root view model");
            Assert.AreEqual (51, numChildViewModels, "Should have let go of 50 child view models");
            foreach (ViewModelInstance instance in SpinnakerConfiguration.CurrentConfig.ViewModelManager.CurrentInstances)
                Assert.AreEqual (1, instance.RefCount, "Ref count of child should still be 1");

            childCollection.Add (rootViewModel.ChildViewModel);
            rootViewModel.ChildViewModels = childCollection;
            CountInstances (out numRootViewModels, out numChildViewModels);
            Assert.AreEqual (51, numChildViewModels, "Should have realized a collection member and a root member were the same view model");
            rootViewModel.ChildViewModel = null;
            CountInstances (out numRootViewModels, out numChildViewModels);
            Assert.AreEqual (51, numChildViewModels, "Should have realized a collection member and a root member were the same view model");
            childCollection.RemoveAt (childCollection.Count - 1);
            rootViewModel.ChildViewModels = childCollection;
            CountInstances (out numRootViewModels, out numChildViewModels);
            Assert.AreEqual (1, numRootViewModels, "Should have been aware of exactly 1 root view model");
            Assert.AreEqual (50, numChildViewModels, "Should have released child via ref counting");

            foreach (ViewModelInstance instance in SpinnakerConfiguration.CurrentConfig.ViewModelManager.CurrentInstances)
                Assert.AreEqual (1, instance.RefCount, "Ref count of child should be 1");
        }
开发者ID:Claytonious,项目名称:spinnaker,代码行数:66,代码来源:BrowserBridgeTests.cs

示例8: RemoveRange_negative_index

        public void RemoveRange_negative_index()
        {
            IList<int> list = new List<int>();

            list.RemoveRange(-1);

            Assert.AreEqual(0, list.Count);
        }
开发者ID:muxa,项目名称:Soyuz5.Extensions,代码行数:8,代码来源:CollectionExtensionsTests.cs

示例9: RemoveRange_outside

        public void RemoveRange_outside()
        {
            IList<int> list = new List<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);

            list.RemoveRange(4, 1);

            Assert.AreEqual(4, list.Count);
        }
开发者ID:muxa,项目名称:Soyuz5.Extensions,代码行数:12,代码来源:CollectionExtensionsTests.cs

示例10: RemoveRange_middle

        public void RemoveRange_middle()
        {
            IList<int> list = new List<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);

            list.RemoveRange(1, 2);

            Assert.AreEqual(2, list.Count);
            Assert.AreEqual(1, list[0]);
            Assert.AreEqual(4, list[1]);
        }
开发者ID:muxa,项目名称:Soyuz5.Extensions,代码行数:14,代码来源:CollectionExtensionsTests.cs

示例11: RemoveRange_last

        public void RemoveRange_last()
        {
            IList<int> list = new List<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);

            list.RemoveRange(3, 1);

            Assert.AreEqual(3, list.Count);
            Assert.AreEqual(3, list.Last());
        }
开发者ID:muxa,项目名称:Soyuz5.Extensions,代码行数:13,代码来源:CollectionExtensionsTests.cs

示例12: RemoveRange_first

        public void RemoveRange_first()
        {
            IList<int> list = new List<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);

            list.RemoveRange(0, 1);

            Assert.AreEqual(3, list.Count);
            Assert.AreEqual(2, list[0]);
        }
开发者ID:muxa,项目名称:Soyuz5.Extensions,代码行数:13,代码来源:CollectionExtensionsTests.cs

示例13: RemoveRange_all_2

        public void RemoveRange_all_2()
        {
            IList<int> list = new List<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);

            list.RemoveRange(0, 4);

            Assert.AreEqual(0, list.Count);
        }
开发者ID:muxa,项目名称:Soyuz5.Extensions,代码行数:12,代码来源:CollectionExtensionsTests.cs

示例14: RemoveRange_empty_list_1

        public void RemoveRange_empty_list_1()
        {
            IList<int> list = new List<int>();

            list.RemoveRange(0, 1);

            Assert.AreEqual(0, list.Count);
        }
开发者ID:muxa,项目名称:Soyuz5.Extensions,代码行数:8,代码来源:CollectionExtensionsTests.cs

示例15: CreateAndGCAnchors

		public void CreateAndGCAnchors()
		{
			List<TextAnchor> anchors = new List<TextAnchor>();
			List<int> expectedOffsets = new List<int>();
			document.Text = new string(' ', 1000);
			for (int t = 0; t < 250; t++) {
				int c = rnd.Next(50);
				if (rnd.Next(2) == 0) {
					for (int i = 0; i < c; i++) {
						int offset = rnd.Next(1000);
						anchors.Add(document.CreateAnchor(offset));
						expectedOffsets.Add(offset);
					}
				} else if (c <= anchors.Count) {
					anchors.RemoveRange(0, c);
					expectedOffsets.RemoveRange(0, c);
					GC.Collect();
				}
				for (int j = 0; j < anchors.Count; j++) {
					Assert.AreEqual(expectedOffsets[j], anchors[j].Offset);
				}
			}
			GC.KeepAlive(anchors);
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:24,代码来源:TextAnchorTest.cs


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