且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

队列< T> VS名单< T>

更新时间:2021-12-10 20:25:36

性能可以成型。虽然如此少的项目这种情况下,您可能需要运行code百万次真正得到有价值的差异。

Performance can be profiled. Though in this case of so few items, you may need to run the code millions of times to actually get worthwhile differences.

我要说的是:问答LT; T> 将暴露您的的意图更明确的人都知道如何队列工作。

I will say this: Queue<T> will expose your intent more explicitly, people know how a queue works.

在使用像队列中的列表不清晰,特别是如果你有很多不必要的索引和 RemoveAt(magicNumber) code。 出列是从一个code维修点多了很多易损件。

A list being used like a queue is not as clear, especially if you have a lot of needless indexing and RemoveAt(magicNumber) code. Dequeue is a lot more consumable from a code maintenance point of view.

如果这则让你可衡量的绩效问题,就可以解决这个问题。不要满足每一个的的潜力的性能问题放在首位。

If this then gives you measurable performance issues, you can address it. Don't address every potential performance issue upfront.