difference in implementation of map and dictionary
I know what the difference is in terms of where a map or where a dictionary is used, but what I wondered is why a Dictionary<TKey, TValue>
in .NET supposedly uses, from what I've read here, a linked list under the covers and I know that a std::map<K,T>
(C++) is implemented as a red-black tree.
Why aren't they the same under the covers, is there some difference in performance, (which I know that a C++ data structure is optimized for) or why would the .NET dictionary actually be a linked list under the covers and the C++ std::map then a red-black tree, which to my knowledge are completely different data s开发者_如何学运维tructures, used for entirely different purposes mostly.
Perhaps these two things serve a different purpose and maybe I just don't know.
Can anybody clarify?
Dictionary<>
is a hash table, akin to std::unordered_map<>
.
SortedDictionary<>
is a red-black tree, akin to std::map<>
.
精彩评论