ImmutableList<T>.Builder 类

定义

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

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

public: ref class ImmutableList<T>::Builder sealed : System::Collections::Generic::ICollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::Generic::IList<T>, System::Collections::Generic::IReadOnlyCollection<T>, System::Collections::Generic::IReadOnlyList<T>, System::Collections::IList
public sealed class ImmutableList<T>.Builder : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.Generic.IReadOnlyList<T>, System.Collections.IList
type ImmutableList<'T>.Builder = class
    interface ICollection<'T>
    interface seq<'T>
    interface IEnumerable
    interface IList<'T>
    interface IReadOnlyCollection<'T>
    interface IReadOnlyList<'T>
    interface ICollection
    interface IList
Public NotInheritable Class ImmutableList(Of T).Builder
Implements ICollection(Of T), IEnumerable(Of T), IList, IList(Of T), IReadOnlyCollection(Of T), IReadOnlyList(Of T)

类型参数

T
继承
ImmutableList<T>.Builder
实现

注解

尽管 @no__t 0 和其他方法已对列表提供快速批量更改操作,但 @no__t 1 类允许对具有相同效率的列表进行多项更改组合。Although ImmutableList<T>.AddRange and other methods already provide fast bulk change operations on the list, the ImmutableList<T>.Builder class allows multiple combinations of changes to be made to a list with equal efficiency.

属性

Count

获取此不可变列表中的元素数。Gets the number of elements in this immutable list.

Item[Int32]

获取或设置列表中给定索引的值。Gets or sets the value for a given index in the list.

方法

Add(T)

将项添加到不可变列表。Adds an item to the immutable list.

AddRange(IEnumerable<T>)

将一系列元素添加到此列表的末尾。Adds a series of elements to the end of this list.

BinarySearch(Int32, Int32, T, IComparer<T>)

使用指定的比较器在 ImmutableList<T>.Builder 的指定范围内搜索元素,并返回该元素从零开始的索引。Searches the specified range of the ImmutableList<T>.Builder for an element using the specified comparer and returns the zero-based index of the element.

BinarySearch(T)

使用默认比较器在整个 ImmutableList<T>.Builder 中搜索元素,并返回该元素的从零开始的索引。Searches the entire ImmutableList<T>.Builder for an element using the default comparer and returns the zero-based index of the element.

BinarySearch(T, IComparer<T>)

使用指定的比较器在整个 ImmutableList<T>.Builder 中搜索元素,并返回该元素从零开始的索引。Searches the entire ImmutableList<T>.Builder for an element using the specified comparer and returns the zero-based index of the element.

Clear()

从不可变列表中移除所有项。Removes all items from the immutable list.

Contains(T)

确定不可变列表是否包含特定值。Determines whether the immutable list contains a specific value.

ConvertAll<TOutput>(Func<T,TOutput>)

使用转换器函数从此生成器表示的列表创建一个新的不可变列表。Creates a new immutable list from the list represented by this builder by using the converter function.

CopyTo(Int32, T[], Int32, Int32)

从目标数组的指定索引处开始,将整个不可变列表复制到兼容的一维数组。Copies the entire immutable list to a compatible one-dimensional array, starting at the specified index of the target array.

CopyTo(T[])

从目标数组的开头开始,将整个不可变列表复制到兼容的一维数组。Copies the entire immutable list to a compatible one-dimensional array, starting at the beginning of the target array.

CopyTo(T[], Int32)

从目标数组的指定索引处开始,将整个不可变列表复制到兼容的一维数组。Copies the entire immutable list to a compatible one-dimensional array, starting at the specified index of the target array.

Equals(Object)

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

(继承自 Object)
Exists(Predicate<T>)

确定不可变列表是否包含与指定谓词定义的条件匹配的元素。Determines whether the immutable list contains elements that match the conditions defined by the specified predicate.

Find(Predicate<T>)

搜索与指定谓词所定义的条件相匹配的元素,并返回整个不可变列表中的第一个匹配元素。Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire immutable list.

FindAll(Predicate<T>)

检索与指定谓词定义的条件匹配的所有元素。Retrieves all the elements that match the conditions defined by the specified predicate.

FindIndex(Int32, Int32, Predicate<T>)

搜索与指定谓词所定义的条件相匹配的一个元素,并返回不可变列表中从指定的索引开始、包含指定元素个数的元素范围内第一个匹配项的从零开始的索引。Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the immutable list that starts at the specified index and contains the specified number of elements.

FindIndex(Int32, Predicate<T>)

搜索与指定谓词所定义的条件相匹配的元素,并返回不可变列表中从指定索引到最后一个元素的元素范围内第一个匹配项的从零开始的索引。Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the immutable list that extends from the specified index to the last element.

FindIndex(Predicate<T>)

搜索与指定谓词所定义的条件相匹配的元素,并返回整个不可变列表中第一个匹配元素的从零开始的索引。Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire immutable list.

FindLast(Predicate<T>)

搜索与指定谓词所定义的条件相匹配的元素,并返回整个不可变列表中的最后一个匹配元素。Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire immutable list.

FindLastIndex(Int32, Int32, Predicate<T>)

搜索与指定谓词所定义的条件相匹配的元素,并返回不可变列表中包含指定元素个数、到指定索引结束的元素范围内最后一个匹配项的从零开始的索引。Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the immutable list that contains the specified number of elements and ends at the specified index.

FindLastIndex(Int32, Predicate<T>)

搜索与指定谓词所定义的条件相匹配的元素,并返回不可变列表中从第一个元素到指定索引的元素范围内最后一个匹配项的从零开始的索引。Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the immutable list that extends from the first element to the specified index.

FindLastIndex(Predicate<T>)

搜索与指定谓词所定义的条件相匹配的元素,并返回整个不可变列表中最后一个匹配元素的从零开始的索引。Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire immutable list.

ForEach(Action<T>)

对列表的每个元素执行指定操作。Performs the specified action on each element of the list.

GetEnumerator()

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

GetHashCode()

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

(继承自 Object)
GetRange(Int32, Int32)

在源不可变列表中创建元素范围的浅表复制。Creates a shallow copy of a range of elements in the source immutable list.

GetType()

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

(继承自 Object)
IndexOf(T)

搜索指定的对象,并返回不可变列表中元素范围内第一个匹配项的从零开始的索引。Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the immutable list.

IndexOf(T, Int32)

搜索指定对象并返回不可变列表中从指定索引到最后一个元素这部分元素中第一个匹配项的从零开始索引。Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the immutable list that extends from the specified index to the last element.

IndexOf(T, Int32, Int32)

搜索指定对象并返回不可变列表中从指定索引开始并包含指定元素数的这部分元素中第一个匹配项的从零开始的索引。Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the immutable list that starts at the specified index and contains the specified number of elements.

IndexOf(T, Int32, Int32, IEqualityComparer<T>)

搜索指定对象并返回 ImmutableList<T>.Builder 中从指定索引开始并包含指定元素数的这部分元素中第一个匹配项的从零开始索引。Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the ImmutableList<T>.Builder that starts at the specified index and contains the specified number of elements.

Insert(Int32, T)

将项插入到不可变列表中的指定索引处。Inserts an item to the immutable list at the specified index.

InsertRange(Int32, IEnumerable<T>)

将集合的元素插入不可变列表的指定索引处。Inserts the elements of a collection into the immutable list at the specified index.

ItemRef(Int32)

获取对列表中给定 index 的值的只读引用。Gets a read-only reference to the value for a given index into the list.

LastIndexOf(T)

搜索指定的对象,并返回整个不可变列表中最后一个匹配项的从零开始的索引。Searches for the specified object and returns the zero-based index of the last occurrence within the entire immutable list.

LastIndexOf(T, Int32)

搜索指定对象并返回不可变列表中从第一个元素到指定索引这部分元素中最后一个匹配项的从零开始的索引。Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the immutable list that extends from the first element to the specified index.

LastIndexOf(T, Int32, Int32)

搜索指定对象并返回不可变列表中到指定索引为止包含指定元素数的这部分元素中最后一个匹配项的从零开始的索引。Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the immutable list that contains the specified number of elements and ends at the specified index.

LastIndexOf(T, Int32, Int32, IEqualityComparer<T>)

搜索指定对象并返回不可变列表中到指定索引为止包含指定元素数的这部分元素中最后一个匹配项的从零开始的索引。Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the immutable list that contains the specified number of elements and ends at the specified index.

MemberwiseClone()

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

(继承自 Object)
Remove(T)

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

RemoveAll(Predicate<T>)

移除与指定的谓词所定义的条件相匹配的所有元素。Removes all the elements that match the conditions defined by the specified predicate.

RemoveAt(Int32)

移除不可变列表中指定索引处的项。Removes the item at the specified index of the immutable list.

Reverse()

将整个不可变列表中元素的顺序反转。Reverses the order of the elements in the entire immutable list.

Reverse(Int32, Int32)

将不可变列表的指定范围中元素的顺序反转。Reverses the order of the elements in the specified range of the immutable list.

Sort()

使用默认比较器对整个不可变列表中的元素进行排序。Sorts the elements in the entire immutable list by using the default comparer.

Sort(Comparison<T>)

使用指定的比较对象对整个不可变列表中的元素进行排序。Sorts the elements in the entire immutable list by using the specified comparison object.

Sort(IComparer<T>)

使用指定的比较器对整个不可变列表中的元素进行排序。Sorts the elements in the entire immutable list by using the specified comparer.

Sort(Int32, Int32, IComparer<T>)

使用指定的比较器对不可变列表中某个范围内的元素进行排序。Sorts the elements in a range of elements in the immutable list by using the specified comparer.

ToImmutable()

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

ToString()

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

(继承自 Object)
TrueForAll(Predicate<T>)

确定不可变列表中的每个元素是否都与指定谓词定义的条件匹配。Determines whether every element in the immutable list matches the conditions defined by the specified predicate.

显式界面实现

ICollection.CopyTo(Array, Int32)

从特定的数组索引开始,将列表的元素复制到一个数组中。Copies the elements of the list to an array, starting at a particular 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<T>.IsReadOnly

获取一个值,该值指示此实例是否为只读。Gets a value that indicates whether this instance is read-only.

IEnumerable.GetEnumerator()

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

IEnumerable<T>.GetEnumerator()

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

IList.Add(Object)

将某项添加到列表中。Adds an item to the list.

IList.Clear()

从列表中移除所有项。Removes all items from the list.

IList.Contains(Object)

确定列表是否包含特定值。Determines whether the list contains a specific value.

IList.IndexOf(Object)

确定列表中特定项的索引。Determines the index of a specific item in the list.

IList.Insert(Int32, Object)

将某项插入列表中指定的索引处。Inserts an item to the list at the specified index.

IList.IsFixedSize

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

IList.IsReadOnly

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

IList.Item[Int32]

获取或设置指定索引处的 ObjectGets or sets the Object at the specified index.

IList.Remove(Object)

从列表中移除特定对象的第一个匹配项。Removes the first occurrence of a specific object from the list.

扩展方法

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.

适用于