第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

SortedList和SortedDictionary有什么區(qū)別?

SortedList和SortedDictionary有什么區(qū)別?

烙印99 2019-08-30 16:22:31
a SortedList<TKey,TValue>和a 之間是否有任何實際的區(qū)別SortedDictionary<TKey,TValue>?在任何情況下你會專門使用一個而不是另一個嗎?
查看完整描述

3 回答

?
三國紛爭

TA貢獻1804條經驗 獲得超7個贊

如果它有幫助,這是一個表格視圖...


從績效角度來看:


+------------------+---------+----------+--------+----------+----------+---------+

| Collection       | Indexed | Keyed    | Value  | Addition |  Removal | Memory  |

|                  | lookup  | lookup   | lookup |          |          |         |

+------------------+---------+----------+--------+----------+----------+---------+

| SortedList       | O(1)    | O(log n) | O(n)   | O(n)*    | O(n)     | Lesser  |

| SortedDictionary | n/a     | O(log n) | O(n)   | O(log n) | O(log n) | Greater |

+------------------+---------+----------+--------+----------+----------+---------+


* Insertion is O(1) for data that are already in sort order, so that each 

  element is added to the end of the list (assuming no resize is required).

從實施角度來看:


+------------+---------------+----------+------------+------------+------------------+

| Underlying | Lookup        | Ordering | Contiguous | Data       | Exposes Key &    |

| structure  | strategy      |          | storage    | access     | Value collection |

+------------+---------------+----------+------------+------------+------------------+

| 2 arrays   | Binary search | Sorted   | Yes        | Key, Index | Yes              |

| BST        | Binary search | Sorted   | No         | Key        | Yes              |

+------------+---------------+----------+------------+------------+------------------+

要大致套用,如果您需要原始性能SortedDictionary可能是一個更好的選擇。如果您需要較少的內存開銷,索引檢索SortedList更適合。有關何時使用哪個,請參閱此問題。


查看完整回答
反對 回復 2019-08-30
  • 3 回答
  • 0 關注
  • 1025 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號