ImmutableDictionary<TKey,TValue>.Builder 类

定义

表示一个只需少量或者无需内存分配就能转变,并且可以有效生成不可变哈希映射实例或者构建于此类实例之上的哈希映射。Represents a hash map that mutates with little or no memory allocations and that can produce or build on immutable hash map instances very efficiently.

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

public: ref class ImmutableDictionary<TKey, TValue>::Builder sealed : System::Collections::Generic::ICollection<System::Collections::Generic::KeyValuePair<TKey, TValue>>, System::Collections::Generic::IDictionary<TKey, TValue>, System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>>, System::Collections::Generic::IReadOnlyCollection<System::Collections::Generic::KeyValuePair<TKey, TValue>>, System::Collections::Generic::IReadOnlyDictionary<TKey, TValue>, System::Collections::IDictionary
public sealed class ImmutableDictionary<TKey,TValue>.Builder : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>, System.Collections.Generic.IDictionary<TKey,TValue>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>>, System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>, System.Collections.Generic.IReadOnlyDictionary<TKey,TValue>, System.Collections.IDictionary
type ImmutableDictionary<'Key, 'Value>.Builder = class
    interface ICollection<KeyValuePair<'Key, 'Value>>
    interface seq<KeyValuePair<'Key, 'Value>>
    interface IEnumerable
    interface IDictionary<'Key, 'Value>
    interface IReadOnlyCollection<KeyValuePair<'Key, 'Value>>
    interface IReadOnlyDictionary<'Key, 'Value>
    interface ICollection
    interface IDictionary
Public NotInheritable Class ImmutableDictionary(Of TKey, TValue).Builder
Implements ICollection(Of KeyValuePair(Of TKey, TValue)), IDictionary, IDictionary(Of TKey, TValue), IEnumerable(Of KeyValuePair(Of TKey, TValue)), IReadOnlyCollection(Of KeyValuePair(Of TKey, TValue)), IReadOnlyDictionary(Of TKey, TValue)

类型参数

TKey
TValue
继承
ImmutableDictionary<TKey,TValue>.Builder
实现

注解

尽管ImmutableDictionary<TKey,TValue>.AddRange和其他方法已为集合提供快速的批量更改操作ImmutableDictionary<TKey,TValue>.Builder ,但该类允许对具有相同效率的集进行多个更改组合。Although ImmutableDictionary<TKey,TValue>.AddRange and other methods already provide fast bulk change operations on a collection, the ImmutableDictionary<TKey,TValue>.Builder class allows multiple combinations of changes to be made to a set with equal efficiency.

属性

Count

获取不可变字典中包含的元素数。Gets the number of elements contained in the immutable dictionary.

Item[TKey]

获取或设置具有指定键的元素。Gets or sets the element with the specified key.

KeyComparer

获取或设置键比较器。Gets or sets the key comparer.

Keys

获取包含不可变字典中的键的集合。Gets a collection that contains the keys of the immutable dictionary.

ValueComparer

获取或设置值比较器。Gets or sets the value comparer.

Values

获取包含不可变字典值的集合。Gets a collection that contains the values of the immutable dictionary.

方法

Add(KeyValuePair<TKey,TValue>)

将指定项添加到不可变字典。Adds the specified item to the immutable dictionary.

Add(TKey, TValue)

将具有指定键和值的元素添加到不可变字典。Adds an element that has the specified key and value to the immutable dictionary.

AddRange(IEnumerable<KeyValuePair<TKey,TValue>>)

将值序列添加到此集合中。Adds a sequence of values to this collection.

Clear()

从不可变字典中移除所有项。Removes all items from the immutable dictionary.

Contains(KeyValuePair<TKey,TValue>)

确定不可变字典是否包含特定值。Determines whether the immutable dictionary contains a specific value.

ContainsKey(TKey)

确定不可变字典是否包含具有指定键的元素。Determines whether the immutable dictionary contains an element that has the specified key.

ContainsValue(TValue)

确定不可变字典是否包含具有指定值的元素。Determines whether the immutable dictionary contains an element that has the specified value.

Equals(Object)

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

(继承自 Object)
GetEnumerator()

返回一个循环访问不可变字典的枚举器。Returns an enumerator that iterates through the immutable dictionary.

GetHashCode()

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

(继承自 Object)
GetType()

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

(继承自 Object)
GetValueOrDefault(TKey)

如果字典中存在匹配的键,则获取给定键的值。Gets the value for a given key if a matching key exists in the dictionary.

GetValueOrDefault(TKey, TValue)

如果字典中存在匹配的键,则获取给定键的值。Gets the value for a given key if a matching key exists in the dictionary.

MemberwiseClone()

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

(继承自 Object)
Remove(KeyValuePair<TKey,TValue>)

从不可变字典中移除特定对象的第一个匹配项。Removes the first occurrence of a specific object from the immutable dictionary.

Remove(TKey)

从不可变字典中移除具有指定键的元素。Removes the element with the specified key from the immutable dictionary.

RemoveRange(IEnumerable<TKey>)

从不可变字典中移除其键与指定序列中找到的键相匹配的所有条目。Removes any entries with keys that match those found in the specified sequence from the immutable dictionary.

ToImmutable()

基于此实例的内容创建一个不可变字典。Creates an immutable dictionary based on the contents of this instance.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
TryGetKey(TKey, TKey)

确定此字典是否包含指定的键。Determines whether this dictionary contains a specified key.

TryGetValue(TKey, TValue)

返回与指定键关联的值。Returns the value associated with the specified key.

显式界面实现

ICollection.CopyTo(Array, Int32)

从指定的数组索引开始,将字典中的元素复制到 KeyValuePair<TKey,TValue> 类型的数组中。Copies the elements of the dictionary to an array of type KeyValuePair<TKey,TValue>, starting at the specified array index.

ICollection.IsSynchronized

获取一个值,该值指示对 ICollection 的访问是否同步(线程安全)。Gets a value that indicates whether access to the ICollection is synchronized (thread safe).

ICollection.SyncRoot

获取可用于同步对 ICollection的访问的对象。Gets an object that can be used to synchronize access to the ICollection.

ICollection<KeyValuePair<TKey,TValue>>.CopyTo(KeyValuePair<TKey,TValue>[], Int32)
ICollection<KeyValuePair<TKey,TValue>>.IsReadOnly
IDictionary.Add(Object, Object)

将具有所提供键和值的元素添加到字典对象。Adds an element with the provided key and value to the dictionary object.

IDictionary.Contains(Object)

确定字典对象是否包含具有指定键的元素。Determines whether the dictionary object contains an element with the specified key.

IDictionary.GetEnumerator()

返回字典的 IDictionaryEnumerator 对象。Returns an IDictionaryEnumerator object for the dictionary.

IDictionary.IsFixedSize

获取一个值,该值指示 IDictionary 对象是否具有固定大小。Gets a value that indicates whether the IDictionary object has a fixed size.

IDictionary.IsReadOnly

获取一个值,该值指示 ICollection<T> 是否为只读。Gets a value that indicates whether the ICollection<T> is read-only.

IDictionary.Item[Object]

获取或设置具有指定键的元素。Gets or sets the element with the specified key.

IDictionary.Keys

获取包含 ICollection<T> 的键的 IDictionary<TKey,TValue>Gets an ICollection<T> containing the keys of the IDictionary<TKey,TValue>.

IDictionary.Remove(Object)

从字典中移除具有指定键的元素。Removes the element with the specified key from the dictionary.

IDictionary.Values

获取一个 ICollection<T>,它包含 IDictionary<TKey,TValue> 中的值。Gets an ICollection<T> containing the values in the IDictionary<TKey,TValue>.

IDictionary<TKey,TValue>.Keys
IDictionary<TKey,TValue>.Values
IEnumerable.GetEnumerator()

返回循环访问集合的枚举数。Returns an enumerator that iterates through a collection.

IEnumerable<KeyValuePair<TKey,TValue>>.GetEnumerator()

扩展方法

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey)

尝试获取与 dictionary 中的指定 key 相关联的值。Tries to get the value associated with the specified key in the dictionary.

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue)

尝试获取 dictionary 中与指定键相关联的值。Tries to get the value associated with the specified key in the dictionary.

Remove<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue)

尝试从 dictionary 中删除具有指定的 key 的值。Tries to remove the value with the specified key from the dictionary.

TryAdd<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue)

尝试将指定的 keyvalue 添加到 dictionaryTries to add the specified key and value to the dictionary.

ToImmutableDictionary<TKey,TValue>(ImmutableDictionary<TKey,TValue>)

从生成器字典的当前内容创建不可变字典。Creates an immutable dictionary from the current contents of the builder's dictionary.

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)

在给定其泛型参数 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)

在给定其泛型参数 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)

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

OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable)

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

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

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)

返回经过筛选的元素集合,其中包含源集合中每个节点的上级。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>)

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

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)

返回经过筛选的元素集合,其中包含源集合中每个元素和文档的子代元素。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>)

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

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>)

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

Nodes<T>(IEnumerable<T>)

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

Remove<T>(IEnumerable<T>)

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

适用于