SortedSet<T>.ExceptWith(IEnumerable<T>) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从当前 SortedSet<T> 对象中删除指定集合中的所有元素。
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))
参数
- other
- IEnumerable<T>
要从对象中删除的 SortedSet<T> 项的集合。
实现
例外
other 是 null。
示例
以下示例从另一个排序集中重复的排序集中删除元素。 该代码示例是 SortedSet<T> 类中的一个较大示例的一部分。
// 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}")
注解
此方法删除当前 SortedSet<T> 中也位于 other的任何元素。 将忽略重复 other 值。
此方法是一个O(n log m)操作,其中mCount是和n其中元素other的数目。