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

定義

修改目前的 HashSet<T> 物件,以便僅包含該物件和指定之集合中同時出現的項目。Modifies the current HashSet<T> object to contain only elements that are present in that object and in the specified collection.

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> 物件比較的集合。The collection to compare to the current HashSet<T> object.

實作

屬性

例外狀況

othernullother is null.

備註

如果參數所代表的集合 other 是具有與 HashSet<T> 目前物件相同之相等比較子的集合 HashSet<T> ,則這個方法是 () 作業的 O nIf the collection represented by the other parameter is a HashSet<T> collection with the same equality comparer as the current HashSet<T> object, this method is an O(n) operation. 否則,這個方法是 (的 n + m) 作業,其中 nCount ,而 m 是中的元素數目 otherOtherwise, this method is an O(n + m) operation, where n is Count and m is the number of elements in other.

適用於