ImmutableSortedSet<T>.ToBuilder 方法


创建一个其内容与此不可变排序集相同,并且可使用标准可变接口有效操作的集合。Creates a collection that has the same contents as this immutable sorted set that can be efficiently manipulated by using standard mutable interfaces.

 System::Collections::Immutable::ImmutableSortedSet<T>::Builder ^ ToBuilder();
public System.Collections.Immutable.ImmutableSortedSet<T>.Builder ToBuilder ();
member this.ToBuilder : unit -> System.Collections.Immutable.ImmutableSortedSet<'T>.Builder
Public Function ToBuilder () As ImmutableSortedSet(Of T).Builder


排序集生成器。The sorted set builder.


如果需要对不可变集合执行多个操作,为了提高效率,您可以使用 ToBuilder 方法将 ImmutableSortedSet<T> 复制到 ImmutableSortedSet<T>.Builder,并使用 ToImmutable 方法对其进行操作并使其再次成为不可变的。If you need to perform multiple operations on an immutable collection, to increase efficiency you can copy the ImmutableSortedSet<T> to a ImmutableSortedSet<T>.Builder, using the ToBuilder method, manipulate the set and make it immutable again using the ToImmutable method. 这不会更改原始的不可变排序集。This will not change the original immutable sorted set.

这是一项 O (1)操作,只会导致一个(小)内存分配。This is an O(1) operation and results in only a single (small) memory allocation. 返回的可变集合不是线程安全的。The mutable collection that is returned is not thread safe.

System.object NuGet 包System.Collections.Immutable NuGet package

关于不可变集合以及如何安装About immutable collections and how to install