语言

HashSet<T>.IntersectWith(IEnumerable<T>) 方法

定义

修改当前 HashSet<T> 对象以仅包含该对象和指定集合中存在的元素。

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

参数

other
IEnumerable<T>

要与当前 HashSet<T> 对象进行比较的集合。

实现

特性

例外

other 是 null。

注解

如果参数表示 other 的集合是与 HashSet<T> 当前 HashSet<T> 对象相同的相等比较器集合,则此方法为 O(n) 操作。 否则,此方法是一个 O(n + m) 操作,其中n是Count元素m的数目。other

适用于