NET集合类的复杂性

NET集合类的复杂性

本文介绍了渐近.NET集合类的复杂性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是关于.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<,>
  • List<>
  • SortedList<,> (edit: wrong link; here's the generic version)
  • SortedDictionary<,>

等。例如:

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

排序列表(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).

这篇关于渐近.NET集合类的复杂性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 15:32