相关文章推荐
勤奋的手电筒  ·  海岛“吃海”记_ 全省资讯_福建省人民政 ...·  1 年前    · 
奔跑的茄子  ·  林国雄个人资料简介,主演的电视剧电影,图片, ...·  1 年前    · 
重感情的酸菜鱼  ·  “千兆宽带”提升的,其实不仅仅是带宽-讯石光通讯网·  1 年前    · 
儒雅的椅子  ·  南京市人民政府·  1 年前    · 
文雅的海龟  ·  2019年1月8日外交部发言人陆慷主持例行记者会·  1 年前    · 
Code  ›  C# SortedDictionary以及SortedList的浅谈开发者社区
https://cloud.tencent.com/developer/article/2347049
不羁的投影仪
2 周前
Ryan_OVO

C# SortedDictionary以及SortedList的浅谈

腾讯云
开发者社区
文档 建议反馈 控制台
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
发布
Ryan_OVO
社区首页 > 专栏 > C# SortedDictionary以及SortedList的浅谈

C# SortedDictionary以及SortedList的浅谈

作者头像
Ryan_OVO
发布 于 2023-10-19 19:30:03
发布 于 2023-10-19 19:30:03
715 0
举报
文章被收录于专栏: 程序随笔 程序随笔

msdn叙述: The SortedDictionary<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 SortedList<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:

SortedList<TKey, TValue> uses less memory than SortedDictionary<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>.

If the list is populated all at once from sorted data, SortedList<TKey, TValue> is faster than SortedDictionary<TKey, TValue>. SortedDictionary<TKey, TValue>泛型类是检索O(log n)的二叉搜索树,其中n是字典中的元素数。在这里,它类似于SortedList<TKey, TValue>泛型类。这两个类有相似的对象模型,并且都有O(log n)检索。这两个类的不同之处在于内存的使用以及插入和删除的速度: SortedList<TKey, TValue>比SortedDictionary<TKey, TValue >使用更少的内存. SortedDictionary<TKey, TValue>对于未排序的数据O(log n)具有更快的插入和删除操作,而SortedList<TKey, TValue>的插入和删除都是O(n)

 
推荐文章
勤奋的手电筒  ·  海岛“吃海”记_ 全省资讯_福建省人民政府门户网站
1 年前
奔跑的茄子  ·  林国雄个人资料简介,主演的电视剧电影,图片,写真_明星_电视猫
1 年前
重感情的酸菜鱼  ·  “千兆宽带”提升的,其实不仅仅是带宽-讯石光通讯网
1 年前
儒雅的椅子  ·  南京市人民政府
1 年前
文雅的海龟  ·  2019年1月8日外交部发言人陆慷主持例行记者会
1 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号