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


C# List.RemoveAll方法代码示例

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


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

示例1: PickRemaining

        public void PickRemaining()
        {
            other.BitField.SetAll(true);
            other.IsChoking = false;
            List<Block> allBlocks = new List<Block>();
            pieces.ForEach(delegate(Piece p) { allBlocks.AddRange(p.Blocks); });
            allBlocks.RemoveAll(delegate(Block b){ return alreadyGot.Contains(b);});
            RequestMessage m;
            while ((m = picker.PickPiece(other, new List<PeerId>())) != null)
            {
                if(alreadyGot.Exists(delegate(Block b){
                    return b.PieceIndex == m.PieceIndex &&
                           b.StartOffset == m.StartOffset &&
                           b.RequestLength == m.RequestLength;}))
                {
                    Assert.AreEqual(0, allBlocks.Count, "#1");
                    break;
                }
                int ret = allBlocks.RemoveAll(delegate (Block b) {
                    return b.PieceIndex == m.PieceIndex &&
                           b.StartOffset == m.StartOffset &&
                           b.RequestLength == m.RequestLength;
                });
                Assert.AreEqual(1, ret, "#2");

            }
        }
开发者ID:burris,项目名称:monotorrent,代码行数:27,代码来源:EndGamePickerTests.cs

示例2: CalculatePopulateWithHiddenObject

        /// <summary>
        /// Calculates the nodes that should be visible in the main window tree view when the specified xen object is hidden.
        /// </summary>
        /// <param name="hiddenObject">The hidden object.</param>
        private ComparableList<IXenObject> CalculatePopulateWithHiddenObject(IXenObject hiddenObject)
        {
            VirtualTreeNode rootNode = MW(() => new MainWindowTreeBuilder(new FlickerFreeTreeView()).CreateNewRootNode(new NavigationPane().Search, NavigationPane.NavigationMode.Infrastructure));

            List<VirtualTreeNode> nodes = new List<VirtualTreeNode>(rootNode.Descendants);

            nodes.RemoveAll(n => hiddenObject.Equals(n.Tag));
            nodes.RemoveAll(n => new List<VirtualTreeNode>(n.Ancestors).Find(nn => hiddenObject.Equals(nn.Tag)) != null);
            return new ComparableList<IXenObject>(nodes.ConvertAll(n => (IXenObject)n.Tag));
        }
开发者ID:robhoes,项目名称:xenadmin,代码行数:14,代码来源:ShowHideTests.cs

示例3: RemoveAll

        public void RemoveAll()
        {
            ICollection<int> col = new List<int> { 1, 2, 3, 4, 5 };

            col.RemoveAll(x => x % 2 == 0);
            Assert.IsTrue(col.SequenceEqual(new [] { 1, 3, 5 }));
        }
开发者ID:shchimisyaotsel,项目名称:iSynaptic.Commons,代码行数:7,代码来源:CollectionExtensionsTests.cs

示例4: AttributeStatement_Element

        public void AttributeStatement_Element()
        {
            Predicate<StatementAbstract> findAttributeStatement =
                delegate(StatementAbstract stmnt) { return stmnt is AttributeStatement; };
            Assertion saml20Assertion = AssertionUtil.GetBasicAssertion();

            AttributeStatement attributeStatement =
                (AttributeStatement) Array.Find(saml20Assertion.Items, findAttributeStatement);

            // Add an encrypted attribute.
            EncryptedElement encAtt = new EncryptedElement();
            encAtt.encryptedData = new EncryptedData();
            encAtt.encryptedData.CipherData = new CipherData();
            encAtt.encryptedData.CipherData.Item = string.Empty;
            encAtt.encryptedKey = new EncryptedKey[0];
            attributeStatement.Items = new object[] { encAtt };
            TestAssertion(saml20Assertion, "The DK-SAML 2.0 profile does not allow encrypted attributes.");

            // Add an attribute with the wrong nameformat.
            //            Attribute att = DKSaml20EmailAttribute.create("[email protected]");
            //            att.NameFormat = "http://example.com";
            //            attributeStatement.Items = new object[] { att };
            //            testAssertion(saml20Assertion, "The DK-SAML 2.0 profile requires that an attribute's \"NameFormat\" element is urn:oasis:names:tc:SAML:2.0:attrname-format:uri.");

            // Clear all the attributes.
            attributeStatement.Items = new object[0];
            TestAssertion(saml20Assertion, "AttributeStatement MUST contain at least one Attribute or EncryptedAttribute");

            // Remove it.
            saml20Assertion = AssertionUtil.GetBasicAssertion();
            List<StatementAbstract> statements = new List<StatementAbstract>(saml20Assertion.Items);
            statements.RemoveAll(findAttributeStatement);
            saml20Assertion.Items = statements.ToArray();
            TestAssertion(saml20Assertion, "The DK-SAML 2.0 profile requires exactly one \"AuthnStatement\" element and one \"AttributeStatement\" element.");
        }
开发者ID:kiniry-supervision,项目名称:OpenNemID,代码行数:35,代码来源:DKSAML20ProfileValidationTest.cs

示例5: ShowLogosAndWait

		public void ShowLogosAndWait()
		{
			var screen = Resolve<ScreenSpace>();
			var factory = new LogoFactory(screen);
			var logos = new List<Logo>();
			var n = 10; // randomizer.Get(10, 100);
			for (int i = 0; i < n; i++)
			{
				var logo = factory.Create();
				if (logo != null)
					logos.Add(logo);
			}
			Assert.IsTrue(logos.Count == n);
			if (!IsMockResolver)
				return;
			while (GlobalTime.Current.Milliseconds < 10000)
			{
				var mouse = Resolve<MockMouse>();
				mouse.SetButtonState(MouseButton.Left, State.Releasing);
				AdvanceTimeAndUpdateEntities(1);
				if (Time.CheckEvery(1))
				{
					Resolve<Window>().Title = "Logo count: " + logos.Count;
					logos.RemoveAll(x => x.IsOutside(screen.Viewport));
				}
			}
			Assert.IsTrue(logos.Count == 0);	
		}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:28,代码来源:LogoTests.cs

示例6: RemoveAll_List_NotFound

        public void RemoveAll_List_NotFound()
        {
            IList<int> list = new List<int> { 1, 3 };
            Assert.IsFalse (list.RemoveAll (i => i == 2));

            Assert.AreEqual (2, list.Count);
        }
开发者ID:cadenza,项目名称:cadenza,代码行数:7,代码来源:CollectionCodaTests.cs

示例7: RemoveAll_MultipleList

        public void RemoveAll_MultipleList()
        {
            IList<int> list = new List<int> { 1, 2, 3, 4, 1, 2, 5 };
            list.RemoveAll (i => i == 2);

            Assert.AreEqual (5, list.Count);
            Assert.IsFalse (list.Contains (2), "List still contains removed items");
        }
开发者ID:rikkus,项目名称:cadenza,代码行数:8,代码来源:CollectionCodaTests.cs

示例8: remove_all

 public void remove_all()
 {
     var list = new List<string> { "a", "c", "b" };
     list.ShouldHaveCount(3);
     Func<string, bool> whereEvaluator = item => item.CompareTo("c") < 0;
     list.RemoveAll(whereEvaluator);
     list.ShouldHaveCount(1).ShouldContain("c");
 }
开发者ID:bobpace,项目名称:fubucore,代码行数:8,代码来源:GenericEnumerableExtensionsTester.cs

示例9: RemoveAll

        public void RemoveAll()
        {
            IList<int> iList = new List<int> { 3, 3, 3, 3 };

            var iListRemovedCount = iList.RemoveAll(Match3);

            Assert.AreEqual(4, iListRemovedCount);
            Assert.AreEqual(0, iList.Count);
        }
开发者ID:havok,项目名称:ngenerics,代码行数:9,代码来源:Remove.cs

示例10: RemoveFirst

        public void RemoveFirst()
        {
            IList<int> iList = new List<int> { 3, 2, 4, 2 };

            var iListRemovedCount = iList.RemoveAll(Match3);

            Assert.AreEqual(1, iListRemovedCount);
            EnsureListsAreTheSame(new List<int> { 2, 4, 2 }, iList);
        }
开发者ID:havok,项目名称:ngenerics,代码行数:9,代码来源:Remove.cs

示例11: RemoveMultiple

        public void RemoveMultiple()
        {
            IList<int> iList = new List<int> { 1, 2, 3, 4, 3 };

            var iListRemovedCount = iList.RemoveAll(Match3);

            Assert.AreEqual(2, iListRemovedCount);
            EnsureListsAreTheSame(new List<int> { 1, 2, 4 }, iList);
        }
开发者ID:havok,项目名称:ngenerics,代码行数:9,代码来源:Remove.cs

示例12: RemoveNone

        public void RemoveNone()
        {
            IList<int> iList = new List<int> { 1, 1, 1, 1 };

            var iListRemovedCount = iList.RemoveAll(Match3);

            Assert.AreEqual(0, iListRemovedCount);
            EnsureListsAreTheSame(new List<int> { 1, 1, 1, 1 }, iList);
        }
开发者ID:havok,项目名称:ngenerics,代码行数:9,代码来源:Remove.cs

示例13: RemoveAll

        public void RemoveAll()
        {
            var list = new List<string>
            {
                "a1", "z1", "a2", "z2", "a3", "z3"
            };

            list.RemoveAll(x => x.StartsWith("a"));
            
            Assert.AreEqual(3, list.Count);
            Assert.IsTrue(list.TrueForAll(x => x.StartsWith("z")));
        }
开发者ID:nul800sebastiaan,项目名称:Zbu.ModelsBuilder,代码行数:12,代码来源:ExtensionsTests.cs

示例14: NUGetProductListTestFailure

        public void NUGetProductListTestFailure()
        {
            //Arrange
            List<Products> productList = new List<Products>();

            //Act
            productList = Products.getGenericProductList(true);
            productList.RemoveAll(null);
            //Assert

            Assert.AreNotEqual(0, productList.Count);
        }
开发者ID:garaydev,项目名称:CarboIOProducts,代码行数:12,代码来源:TestProductsNU.cs

示例15: ShouldSomethingWithLambdasssss

        public void ShouldSomethingWithLambdasssss()
        {
            //User user = new User(new UserPrinciple());
            //System.Console.WriteLine( (User user) => user.EmailAddress.Length > 0 );

            List<string> strings = new List<string>();
            strings.Add("fuck you microsoft");
            strings.Add("fuck again");

            strings.RemoveAll((string s) => s.Contains("again"));
            Console.WriteLine(strings.Count);
        }
开发者ID:kaiwren,项目名称:shaker,代码行数:12,代码来源:NotATest.cs


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