SortedSet<T>.ExceptWith(IEnumerable<T>) Metoda

Definicja

Usuwa wszystkie elementy znajdujące się w określonej kolekcji z bieżącego SortedSet<T> obiektu.

public:
 virtual void ExceptWith(System::Collections::Generic::IEnumerable<T> ^ other);
public void ExceptWith (System.Collections.Generic.IEnumerable<T> other);
abstract member ExceptWith : seq<'T> -> unit
override this.ExceptWith : seq<'T> -> unit
Public Sub ExceptWith (other As IEnumerable(Of T))

Parametry

other
IEnumerable<T>

Kolekcja elementów do usunięcia z SortedSet<T> obiektu.

Implementuje

Wyjątki

other to null.

Przykłady

Poniższy przykład usuwa elementy z posortowanego zestawu, który jest zduplikowany w innym posortowanym zestawie. Ten przykład kodu jest częścią większego przykładu podanego SortedSet<T> dla klasy.

// Remove elements in mediaFiles1 that are also in mediaFiles2.
Console.WriteLine("Remove duplicates (of mediaFiles2) from the set...");
Console.WriteLine($"\tCount before: {mediaFiles1.Count}");
mediaFiles1.ExceptWith(mediaFiles2);
Console.WriteLine($"\tCount after: {mediaFiles1.Count}");
' Remove elements in mediaFiles1 that are also in mediaFiles2.
Console.WriteLine("Remove duplicates (of mediaFiles2) from the set...")
Console.WriteLine($"{vbTab}Count before: {mediaFiles1.Count}")
mediaFiles1.ExceptWith(mediaFiles2)
Console.WriteLine($"{vbTab}Count after: {mediaFiles1.Count}")

Uwagi

Ta metoda usuwa dowolny element w bieżącym elemencie SortedSet<T> , który znajduje się również w otherelemencie . Zduplikowane wartości w pliku other są ignorowane.

Ta metoda jest operacją O(n) , gdzie n jest liczbą elementów w parametrze other .

Dotyczy