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>

제거할 요소의 조건을 정의하는 대리자입니다.

반환

SortedSet<T> 컬렉션에서 제거된 요소 수입니다.

예외

match이(가) null인 경우

예제

다음 예제에서는 정렬된 집합에서 원치 않는 요소를 제거합니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 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) 작업은 입니다. 여기서 n 는 입니다 Count.

적용 대상