SortedSet<T>.RemoveWhere(Predicate<T>) メソッド

定義

指定の述語によって定義された条件に一致するすべての要素を SortedSet<T> から削除します。

public:
 int RemoveWhere(Predicate<T> ^ match);
public int RemoveWhere (Predicate<T> match);
member this.RemoveWhere : Predicate<'T> -> int
Public Function RemoveWhere (match As Predicate(Of T)) As Integer

パラメーター

match
Predicate<T>

削除する要素の条件を定義するデリゲート。

戻り値

Int32

SortedSet<T> コレクションから削除された要素数。

例外

matchnullです。

次の例では、並べ替えられたセットから不要な要素を削除します。 このコード例は、SortedSet<T> クラスのために提供されている大規模な例の一部です。

// Defines a predicate delegate to use
// for the SortedSet.RemoveWhere method.
private static bool IsDoc(string s)
{
    s = s.ToLower();
    return (s.EndsWith(".txt") ||
        s.EndsWith(".xls") ||
        s.EndsWith(".xlsx") ||
        s.EndsWith(".pdf") ||
        s.EndsWith(".doc") ||
        s.EndsWith(".docx"));
}
' Defines a predicate delegate to use
' for the SortedSet.RemoveWhere method.
Private Function IsDoc(s As String) As Boolean
    s = s.ToLower()
    Return s.EndsWith(".txt") OrElse 
            s.EndsWith(".doc") OrElse 
            s.EndsWith(".xls") OrElse
            s.EndsWith(".xlsx") OrElse
            s.EndsWith(".pdf") OrElse
            s.EndsWith(".doc") OrElse
            s.EndsWith(".docx")
End Function
// Remove elements that have non-media extensions.
// See the 'IsDoc' method.
Console.WriteLine("Remove docs from the set...");
Console.WriteLine($"\tCount before: {mediaFiles1.Count}");
mediaFiles1.RemoveWhere(IsDoc);
Console.WriteLine($"\tCount after: {mediaFiles1.Count}");
' Remove elements that have non-media extensions. See the 'IsDoc' method.
Console.WriteLine("Remove docs from the set...")
Console.WriteLine($"{vbTab}Count before: {mediaFiles1.Count}")
mediaFiles1.RemoveWhere(AddressOf IsDoc)
Console.WriteLine($"{vbTab}Count after: {mediaFiles1.Count}")

注釈

match を変更 SortedSet<T>しないでください。 これを行うと、予期しない結果が発生する可能性があります。

このメソッドのO(n)呼び出しは、操作ですCountn

適用対象