When to use a SortedList over a SortedDictionary?

后端 未结 6 500
梦毁少年i
梦毁少年i 2020-11-29 01:50

This may appear to be a duplicate of this question, which asks \"What’s the difference between SortedList and SortedDictionary?\" Unfortunately, the answers do nothing more

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 02:19

    An important consideration for us is the fact that we often have small dictionaries (<100 elements), and current processessors much faster at accessing sequential memory while performing few difficult to predict branches. (i.e. iterating over a linear array rather than traversing a tree) So when you have less than about 60 elements in your dictionary, SortedList<> is often the fastest and most memory efficient dictionary in many use cases.

提交回复
热议问题