跳转至

CloneCollection<T>

  • 种类: struct
  • 命名空间: Runestone.AesirArchitecture.Internal
  • 程序集: Runestone.AesirArchitecture

继承链: System.Object → System.ValueType → CloneCollection<T>

实现接口: System.IDisposable

类型参数

  • T — 元素类型。

声明

[NullableContext]
[Nullable]
internal struct CloneCollection<T> : System.ValueType, 
System.IDisposable 

只读克隆集合:把源序列物化为租借数组的临时快照, 供批量操作在写入自身前先完成拷贝(如源序列传入集合自身时避免"枚举中修改"异常)。

备注

数组经 Shared 租借、Dispose 时归还; 上游 Cysharp.ObservableCollections 经 CollectionsMarshal 零拷贝取 List{T} 内部数组, Unity netstandard2.1 参考程序集无该 API,本项目以逐项物化作语义等价的降级实现。

构造方法

名称 描述
CloneCollection(IEnumerable<T>) 从可枚举源物化克隆。源可提供非枚举计数(TryGetNonEnumeratedCount)时按计数一次性租借, 否则从 16 起步倍增扩容。
CloneCollection(List<T>, int, int) 从 List{T} 区间物化克隆(Unity 无 CollectionsMarshal,逐项拷贝替代零拷贝)。

CloneCollection(IEnumerable)

从可枚举源物化克隆。源可提供非枚举计数(TryGetNonEnumeratedCount)时按计数一次性租借, 否则从 16 起步倍增扩容。

public CloneCollection<T>(IEnumerable<T> source)

参数

名称 类型 说明
source IEnumerable<T> 要克隆的源序列。

CloneCollection(List, int, int)

从 List{T} 区间物化克隆(Unity 无 CollectionsMarshal,逐项拷贝替代零拷贝)。

public CloneCollection<T>(List<T> source, int index, int count)

参数

名称 类型 说明
source List<T> 源列表。
index int 区间起始索引。
count int 区间元素数。

属性

名称 描述
Span —

Span

[Nullable]
public ReadOnlySpan<T> Span { get; }

方法

声明的方法

名称 描述
AsEnumerable() 以 IEnumerable{T} 形态暴露已物化元素(供按接口消费的批量方法使用)。
Dispose() 归还租借数组;重复调用幂等。

继承的方法

名称 描述 声明类型
GetType() — object
Equals(object) — ValueType
GetHashCode() — ValueType
ToString() — ValueType
MemberwiseClone() — object
Finalize() — object

AsEnumerable()

以 IEnumerable{T} 形态暴露已物化元素(供按接口消费的批量方法使用)。

public IEnumerable<T> AsEnumerable()

返回值

类型 说明
IEnumerable<T> —

Dispose()

归还租借数组;重复调用幂等。

public void Dispose()

Additional Notes

首个 ## Additional Notes 是增量生成文档标识符,请勿修改标题级别和内容!本文档由 Script Doc Generator 辅助生成。