更新时间:2021-08-04 23:10:56
在List.Clear法源$ C $ C检查:
Inspecting in List.Clear method source code:
Array.Clear(_items, 0, _size);
_size = 0;
Array.Clear是一个外部的方法
了解 Array.Clear和MSDN声明是:
设定数组中的每个元素类型的默认值范围内的元素。
Sets a range of elements in an array to the default value of each element type.
所以它仍然是一个O(n)操作,即使T是值类型。
So it is still an O(n) operation even if T is a value type.