ImmutableHashSet<T> ImmutableHashSet<T> ImmutableHashSet<T> ImmutableHashSet<T> Class

定义

表示不可变未排序哈希集。Represents an immutable, unordered hash set.

NuGet 包System.Collections.Immutable关于不可变集合和安装方法NuGet package: System.Collections.Immutable (about immutable collections and how to install)

generic <typename T>
public ref class ImmutableHashSet sealed : System::Collections::Generic::ICollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::Generic::IReadOnlyCollection<T>, System::Collections::Generic::ISet<T>, System::Collections::ICollection, System::Collections::Immutable::IImmutableSet<T>
public sealed class ImmutableHashSet<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.Generic.ISet<T>, System.Collections.ICollection, System.Collections.Immutable.IImmutableSet<T>
type ImmutableHashSet<'T> = class
    interface ICollection<'T>
    interface seq<'T>
    interface IEnumerable
    interface IReadOnlyCollection<'T>
    interface ISet<'T>
    interface ICollection
    interface IImmutableSet<'T>
Public NotInheritable Class ImmutableHashSet(Of T)
Implements ICollection, ICollection(Of T), IEnumerable(Of T), IImmutableSet(Of T), IReadOnlyCollection(Of T), ISet(Of T)

类型参数

T

哈希集中的元素类型。The type of elements in the hash set.

继承
ImmutableHashSet<T>ImmutableHashSet<T>ImmutableHashSet<T>ImmutableHashSet<T>
实现

字段

Empty Empty Empty Empty

获取此类型的、使用默认 IEqualityComparer<T> 的不可变哈希集。Gets an immutable hash set for this type that uses the default IEqualityComparer<T>.

属性

Count Count Count Count

获取不可变哈希集内的元素数。Gets the number of elements in the immutable hash set.

IsEmpty IsEmpty IsEmpty IsEmpty

获取一个值,该值指示当前不可变哈希集是否为空。Gets a value that indicates whether the current immutable hash set is empty.

KeyComparer KeyComparer KeyComparer KeyComparer

获取用于获得键的哈希代码,以及用于检查不可变哈希集内值的相等性的对象。Gets the object that is used to obtain hash codes for the keys and to check the equality of values in the immutable hash set.

方法

Add(T) Add(T) Add(T) Add(T)

将指定的元素添加到哈希集。Adds the specified element to the hash set.

Clear() Clear() Clear() Clear()

检索排序和顺序语义与此实例相同的空不可变哈希集。Retrieves an empty immutable hash set that has the same sorting and ordering semantics as this instance.

Contains(T) Contains(T) Contains(T) Contains(T)

确定此不可变哈希集是否包含指定的元素。Determines whether this immutable hash set contains the specified element.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Except(IEnumerable<T>) Except(IEnumerable<T>) Except(IEnumerable<T>) Except(IEnumerable<T>)

从当前不可变哈希集内移除指定集合中的元素。Removes the elements in the specified collection from the current immutable hash set.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

返回一个循环访问集合的枚举器。Returns an enumerator that iterates through the collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
Intersect(IEnumerable<T>) Intersect(IEnumerable<T>) Intersect(IEnumerable<T>) Intersect(IEnumerable<T>)

创建一个不可变哈希集,其中包含同时存在于此集和指定集内的元素。Creates an immutable hash set that contains elements that exist in both this set and the specified set.

IsProperSubsetOf(IEnumerable<T>) IsProperSubsetOf(IEnumerable<T>) IsProperSubsetOf(IEnumerable<T>) IsProperSubsetOf(IEnumerable<T>)

确定当前不可变哈希集是否为指定集合的真(严格)子集。Determines whether the current immutable hash set is a proper (strict) subset of a specified collection.

IsProperSupersetOf(IEnumerable<T>) IsProperSupersetOf(IEnumerable<T>) IsProperSupersetOf(IEnumerable<T>) IsProperSupersetOf(IEnumerable<T>)

确定当前不可变哈希集是否为指定集合的真(严格)超集。Determines whether the current immutable hash set is a proper (strict) superset of a specified collection.

IsSubsetOf(IEnumerable<T>) IsSubsetOf(IEnumerable<T>) IsSubsetOf(IEnumerable<T>) IsSubsetOf(IEnumerable<T>)

确定当前不可变哈希集是否为指定集合的子集。Determines whether the current immutable hash set is a subset of a specified collection.

IsSupersetOf(IEnumerable<T>) IsSupersetOf(IEnumerable<T>) IsSupersetOf(IEnumerable<T>) IsSupersetOf(IEnumerable<T>)

确定当前不可变哈希集是否为指定集合的超集。Determines whether the current immutable hash set is a superset of a specified collection.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
Overlaps(IEnumerable<T>) Overlaps(IEnumerable<T>) Overlaps(IEnumerable<T>) Overlaps(IEnumerable<T>)

确定当前不可变哈希集是否与指定的集合重叠。Determines whether the current immutable hash set overlaps with the specified collection.

Remove(T) Remove(T) Remove(T) Remove(T)

从此不可变哈希集内移除指定的元素。Removes the specified element from this immutable hash set.

SetEquals(IEnumerable<T>) SetEquals(IEnumerable<T>) SetEquals(IEnumerable<T>) SetEquals(IEnumerable<T>)

确定当前不可变哈希集与指定的集合是否包含相同的元素。Determines whether the current immutable hash set and the specified collection contain the same elements.

SymmetricExcept(IEnumerable<T>) SymmetricExcept(IEnumerable<T>) SymmetricExcept(IEnumerable<T>) SymmetricExcept(IEnumerable<T>)

创建一个不可变哈希集,该集仅包含存在于当前集或指定集合(但不同时存在于两者中)中的元素。Creates an immutable hash set that contains only elements that are present either in the current set or in the specified collection, but not both.

ToBuilder() ToBuilder() ToBuilder() ToBuilder()

创建一个其内容与此集相同,并且可使用标准可变接口在多个操作之间有效转变的不可变哈希集。Creates an immutable hash set that has the same contents as this set and can be efficiently mutated across multiple operations by using standard mutable interfaces.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
TryGetValue(T, T) TryGetValue(T, T) TryGetValue(T, T) TryGetValue(T, T)

在集内搜索给定的值,并返回所找到的相等值(如果有)。Searches the set for a given value and returns the equal value it finds, if any.

Union(IEnumerable<T>) Union(IEnumerable<T>) Union(IEnumerable<T>) Union(IEnumerable<T>)

创建一个新的不可变哈希集,该集包含存在于当前集或指定集合中的所有元素。Creates a new immutable hash set that contains all elements that are present in either the current set or in the specified collection.

WithComparer(IEqualityComparer<T>) WithComparer(IEqualityComparer<T>) WithComparer(IEqualityComparer<T>) WithComparer(IEqualityComparer<T>)

获取将指定的相等性比较器用于其搜索方法的不可变哈希集实例。Gets an instance of the immutable hash set that uses the specified equality comparer for its search methods.

显式界面实现

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

从特定的索引开始,将集的元素复制到一个数组中。Copies the elements of the set to an array, starting at a particular index.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

请参阅 ICollection 接口。See the ICollection interface.

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

请参阅 ICollectionSee ICollection.

ICollection<T>.Add(T) ICollection<T>.Add(T) ICollection<T>.Add(T) ICollection<T>.Add(T)

将某项添加到集内。Adds an item to the set.

ICollection<T>.Clear() ICollection<T>.Clear() ICollection<T>.Clear() ICollection<T>.Clear()

从此集内移除所有项。Removes all items from this set.

ICollection<T>.CopyTo(T[], Int32) ICollection<T>.CopyTo(T[], Int32) ICollection<T>.CopyTo(T[], Int32) ICollection<T>.CopyTo(T[], Int32)

从特定的索引开始,将集的元素复制到一个数组中。Copies the elements of the set to an array, starting at a particular index.

ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly

请参阅 ICollection<T> 接口。See the ICollection<T> interface.

ICollection<T>.Remove(T) ICollection<T>.Remove(T) ICollection<T>.Remove(T) ICollection<T>.Remove(T)

从集内移除特定对象的第一个匹配项。Removes the first occurrence of a specific object from the set.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

返回一个循环访问集的枚举器。Returns an enumerator that iterates through a set.

IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator()

返回一个循环访问集合的枚举器。Returns an enumerator that iterates through the collection.

IImmutableSet<T>.Add(T) IImmutableSet<T>.Add(T) IImmutableSet<T>.Add(T) IImmutableSet<T>.Add(T)

将指定的元素添加到此不可变集。Adds the specified element to this immutable set.

IImmutableSet<T>.Clear() IImmutableSet<T>.Clear() IImmutableSet<T>.Clear() IImmutableSet<T>.Clear()

检索排序和顺序语义与此实例相同的空集。Retrieves an empty set that has the same sorting and ordering semantics as this instance.

IImmutableSet<T>.Except(IEnumerable<T>) IImmutableSet<T>.Except(IEnumerable<T>) IImmutableSet<T>.Except(IEnumerable<T>) IImmutableSet<T>.Except(IEnumerable<T>)

从当前集内移除指定集合中的元素。Removes the elements in the specified collection from the current set.

IImmutableSet<T>.Intersect(IEnumerable<T>) IImmutableSet<T>.Intersect(IEnumerable<T>) IImmutableSet<T>.Intersect(IEnumerable<T>) IImmutableSet<T>.Intersect(IEnumerable<T>)

创建一个不可变集,其中包含同时存在于此集和指定集内的元素。Creates an immutable set that contains elements that exist in both this set and the specified set.

IImmutableSet<T>.Remove(T) IImmutableSet<T>.Remove(T) IImmutableSet<T>.Remove(T) IImmutableSet<T>.Remove(T)

从此不可变集内移除指定的元素。Removes the specified element from this immutable set.

IImmutableSet<T>.SymmetricExcept(IEnumerable<T>) IImmutableSet<T>.SymmetricExcept(IEnumerable<T>) IImmutableSet<T>.SymmetricExcept(IEnumerable<T>) IImmutableSet<T>.SymmetricExcept(IEnumerable<T>)

创建一个不可变集,该集仅包含存在于当前集或指定集合(但不同时存在于两者中)中的元素。Creates an immutable set that contains only elements that are present either in the current set or in the specified collection, but not both.

IImmutableSet<T>.Union(IEnumerable<T>) IImmutableSet<T>.Union(IEnumerable<T>) IImmutableSet<T>.Union(IEnumerable<T>) IImmutableSet<T>.Union(IEnumerable<T>)

创建一个新的不可变集,该集包含存在于当前集或指定集合中的所有元素。Creates a new immutable set that contains all elements that are present in either the current set or in the specified collection.

ISet<T>.Add(T) ISet<T>.Add(T) ISet<T>.Add(T) ISet<T>.Add(T)

向当前集内添加元素,并返回一个指示是否已成功添加元素的值。Adds an element to the current set and returns a value that indicates whether the element was successfully added.

ISet<T>.ExceptWith(IEnumerable<T>) ISet<T>.ExceptWith(IEnumerable<T>) ISet<T>.ExceptWith(IEnumerable<T>) ISet<T>.ExceptWith(IEnumerable<T>)

从当前集内移除指定集合中的所有元素。Removes all elements in the specified collection from the current set.

ISet<T>.IntersectWith(IEnumerable<T>) ISet<T>.IntersectWith(IEnumerable<T>) ISet<T>.IntersectWith(IEnumerable<T>) ISet<T>.IntersectWith(IEnumerable<T>)

修改当前集,使该集仅包含也存在在指定集合中的元素。Modifies the current set so that it contains only elements that are also in a specified collection.

ISet<T>.SymmetricExceptWith(IEnumerable<T>) ISet<T>.SymmetricExceptWith(IEnumerable<T>) ISet<T>.SymmetricExceptWith(IEnumerable<T>) ISet<T>.SymmetricExceptWith(IEnumerable<T>)

修改当前集,使该集仅包含存在于当前集或指定集合中的元素(但不同时存在于两者中)。Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both.

ISet<T>.UnionWith(IEnumerable<T>) ISet<T>.UnionWith(IEnumerable<T>) ISet<T>.UnionWith(IEnumerable<T>) ISet<T>.UnionWith(IEnumerable<T>)

修改当前集,使该集包含当前集或指定集合中存在的所有元素。Modifies the current set so that it contains all elements that are present in either the current set or in the specified collection.

扩展方法

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

在给定其泛型参数 TDataTable 的输入 DataRow 对象的情况下,返回包含 IEnumerable<T> 对象副本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个节点的上级。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个节点的上级。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子代节点的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>)

返回源集合中每个元素和文档的子元素的集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName)

返回源集合中经过筛选的每个元素和文档的子元素集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>)

返回节点集合(其中包含源集合中的所有节点),并按文档顺序排列。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子节点集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

将源集合中的每个节点从其父节点中移除。Removes every node in the source collection from its parent node.

适用于

线程安全性

此类型是线程安全的。This type is thread safe.