arrays - C# Is clearing a List<T> with value types still an O(n) operation? -


according microsoft documentation, calling clear() on list o(n) operation. i'm guessing because if list hold references, need null them. wondering if clear() still o(n) operation if list has value types, since capacity not changed. shouldn't enough reset index pointer , count?

i'm asking because in current application we're using lists cleared hundreds of thousands of times in short time span, , wanted know if there different implementation makes faster.

inspecting in list.clear method source code:

array.clear(_items, 0, _size); _size = 0; 

array.clear extern method , msdn statement array.clear is:

sets range of elements in array default value of each element type.

so still o(n) operation if t value type.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -