當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。