开发者

Did you know System.Collections.Generic.List is implemented with an array? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

I had a performance problem today that showed up after some profiling. Calls to List<>.RemoveAt(0) were taking a long time. I'd assumed System.Collections.Generic.开发者_如何学编程List would be implemented with a list data structure, but actually its implemented as an array.

Does anyone else find that surprising?


No. It's similar to the C++ standard std::vector type, as well as a generic replacement for the C# ArrayList type, which has "Array" in its name. If you want linked list behavior, use the LinkedList type.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜