Is ConcurrentDictionary, a “concurrent” version of SortedList?

不羁岁月 提交于 2019-12-24 02:20:11

问题


I would like to understand the Computational Complexity of a ConcurrentDictionary vers SortedList (Which is O(logarithmic(n))), is a ConcurrentDictionary just a concurrent synchronized implementation of a SortedList? or do these data structures vary? among one another?


回答1:


ConcurrentDictionary<T,U> is a concurrent version of a Dictionary<T,U>. It does not sort by keys like a SortedList<T,U>. The complexity is closely related to a Dictionary<T,U>'s complexity, so fetches approach O(1).

SortedList<T,U> has O(log n) complexity for most fetch operations since it's walking the internal sorted structure.




回答2:


I believe that ConcurrentDictionary<K,V> is a thread-safe analog of Dictionary<K,V> and both should have complexity O(1). They don't provide key sorting, order is not guaranteed.



来源:https://stackoverflow.com/questions/15511394/is-concurrentdictionary-a-concurrent-version-of-sortedlist

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