渐近.NET集合类的复杂性渐近、复杂性、NET

由网友(伱侑ζ。莪乜侑)分享简介:是关于.NET集合类的方法(渐近复杂性(大O,其余)有什么资源词典< K,V> ,列表< T> 等...)Are there any resources about the asymptotic complexity (big-O and the rest) of methods of .NE...

是关于.NET集合类的方法(渐近复杂性(大O,其余)有什么资源词典< K,V> 列表< T> 等...)

Are there any resources about the asymptotic complexity (big-O and the rest) of methods of .NET collection classes (Dictionary<K,V>, List<T> etc...)?

我知道,C5库的文档包含一些关于它的信息(的例如),但我感兴趣的是标准的.NET集合太...(和PowerCollections的信息也将是不错的)。

I know that the C5 library's documentation includes some information about it (example), but I'm interested in standard .NET collections too... (and PowerCollections' information would also be nice).

推荐答案

MSDN列出了这些:

MSDN Lists these:

Dictionary<,> 名单,其中;&GT; SortedList<,> (编辑:错误的链接;这里的通用版) SortedDictionary<,> Dictionary<,> List<> SortedList<,> (edit: wrong link; here's the generic version) SortedDictionary<,>

等。例如:

的排序列表(TKEY的,TValue)通用   类是用二进制搜索树   O(log n)的检索,其中n是   在字典中的元素数目。   在此,它是类似于   SortedDictionary(TKEY的,TValue)通用   类。这两个类具有相似的   对象模型,并且都为O(log n)的   检索。其中,这两个类   不同之处在于内存使用和速度   插入和删除:

The SortedList(TKey, TValue) 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 SortedDictionary(TKey, TValue) 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:

排序列表(TKEY的,TValue)使用较少   内存比SortedDictionary(TKEY的,   TValue)。

SortedList(TKey, TValue) uses less memory than SortedDictionary(TKey, TValue).

SortedDictionary(TKEY的,TValue)有   更快的插入和移除   对于未排序的数据操作,O(log n)的   而不是为O(n),用于   排序列表(TKEY的,TValue)。

SortedDictionary(TKey, TValue) has faster insertion and removal operations for unsorted data, O(log n) as opposed to O(n) for SortedList(TKey, TValue).

如果该列表中填充一次全部   从排序的数据,排序列表(TKEY的,   TValue)比快   SortedDictionary(TKEY的,TValue)。

If the list is populated all at once from sorted data, SortedList(TKey, TValue) is faster than SortedDictionary(TKey, TValue).

阅读全文

相关推荐

最新文章