What is the complexity of OrderedDictionary?

人盡茶涼 提交于 2019-12-18 03:06:23

问题


No one said that OrderedDictionary is having two copies of elements, one in a hashtable and other in a list, I can't find complexity measurements at MSDN for OrderedList.

thanks


回答1:


Have a look at

OrderedDictionary: A generic implementation of IOrderedDictionary

This implementation of an ordered dictionary is very good at lookup operations: the array allows O(1) lookups by index, and the hashtable allows O(1) lookups by key. However, the necessity of keeping the array synchronized with the hashtable means that insert/delete operations have the performance disadvantage of performing those operations on an array (O(n) at worst). There is also, of course, the extra memory requirement of storing both data structures. Because of these disadvantages, OrderedDictionary should only be used when insert/delete operations will be minimal and there is a need to efficiently access elements by index and/or key.



来源:https://stackoverflow.com/questions/2565455/what-is-the-complexity-of-ordereddictionary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!