天天看點

SortedList<TKey,TValue> 和 SortedDictionary<TKey,TValue>

the <code>sortedlist&lt;tkey, tvalue&gt;</code> generic class is a binary search tree with o(log n) retrieval, where n is the number of elements in the dictionary. in this, it is similar to the <code>sorteddictionary&lt;tkey, tvalue&gt;</code> generic class. the two classes have similar object models, and both have o(log n) retrieval. where the two classes differ is in memory use and speed of insertion and removal: <code>1.sortedlist&lt;tkey, tvalue&gt;</code> uses less memory than <code>sorteddictionary&lt;tkey, tvalue&gt;</code>. <code>2.sorteddictionary&lt;tkey, tvalue&gt;</code> has faster insertion and removal operations for unsorted data, o(log n) as opposed to o(n) for <code>sortedlist&lt;tkey, tvalue&gt;</code>. 3.if the list is populated all at once from sorted data, <code>sortedlist&lt;tkey, tvalue&gt;</code> is faster than <code>sorteddictionary&lt;tkey, tvalue&gt;</code>.

歡迎轉載,轉載請注明:

繼續閱讀