使用上两者的接口都类似字典,并且SortedList的比如Find,FindIndex,RemoveAll常用方法都没提供。

数据结构上二者差异比较大,SortedList查找数据极快,但添加新元素,删除元素较慢,SortedDictionary查找,添加,删除速度都比较平均。

博友的测试结果:

直接在Unity3D里测一下

public class Test : MonoBehaviour
{
void Start()
{
var sortedDict = new SortedDictionary<string, int>();
sortedDict.Add("a01", );
sortedDict.Add("a10", );
sortedDict.Add("a03", );
sortedDict.Add("a02", ); print(sortedDict["a01"]); foreach (var item in sortedDict)
{
Debug.Log("SortedDictionary: " + item);
} var sortedList = new SortedList<string, int>();
sortedList.Add("a01", );
sortedList.Add("a10", );
sortedList.Add("a03", );
sortedList.Add("a02", ); print(sortedList["a01"]); foreach (var item in sortedList)
{
Debug.Log("SortedList: " + item);
}
}
}

调用结果:

SortedDictionary和SortedList的更多相关文章

  1. 深入解析Hashtable、Dictionary、SortedDictionary、SortedList

    我们先看Hashtable. MSDN的解释:表示键/值对的集合,这些键/值对根据键的哈希代码进行组织. Hash算法是把任意长度的输入(又叫做预映射, pre-image),通过散列算法,变换成固定 ...

  2. C# SortedDictionary以及SortedList的浅谈

    msdn叙述:The SortedDictionary<TKey, TValue> generic class is a binary search tree with O(log n) ...

  3. .net学习笔记----有序集合SortedList、SortedList<TKey,TValue>、SortedDictionary<TKey,TValue>

    无论是常用的List<T>.Hashtable还是ListDictionary<TKey,TValue>,在保存值的时候都是无序的,而今天要介绍的集合类SortedList和S ...

  4. Dictionary<Tkey.TValue>与SortedList

    一.概述 表示Key/Value集合,可以添加删除元素,允许按Key来访问元素.是Hashtable的泛型等效类. 它需要一个相等实现来确定键是否相等,可以使用实现了IEqualityComparer ...

  5. 发布:.NET开发人员必备的可视化调试工具(你值的拥有)

    1:如何使用 1:点击下载:.NET可视化调试工具 (更新于2016-12-29 19:11:00) (终于彻底兼容了部分VS环境下无法使用的问题) 2:解压RAR后执行:CYQ.VisualierS ...

  6. (转).NET开发人员必备的可视化调试工具(你值的拥有)

    1:如何使用 1:点击下载:.NET可视化调试工具 (更新于2016-11-05 20:55:00) 2:解压RAR后执行:CYQ.VisualierSetup.exe 成功后关掉提示窗口即可. PS ...

  7. C#常用集合的使用(转载)

    大多数集合都在System.Collections,System.Collections.Generic两个命名空间.其中System.Collections.Generic专门用于泛型集合. 针对特 ...

  8. C# 各种集合

    大多数集合都在  System.Collections,System.Collections.Generic两个命名空间. 其中System.Collections.Generic专门用于泛型集合. ...

  9. C#常用集合的使用

    大多数集合都在System.Collections,System.Collections.Generic两个命名空间.其中System.Collections.Generic专门用于泛型集合. 针对特 ...

随机推荐

  1. 从零开始攻略PHP(6)——代码重用与函数编写的一些注意事项

    一个新的项目是这样创建的:它将已有的可重新利用的组件进行组合,并将新的开发难度降低到最小. 代码重用的好处:降低成本.提升可靠性和一致性. 1.使用require()和include()函数 使用一条 ...

  2. FlashBuilder 4.7 win64 和 mac版 下载地址

    win64 http://trials3.adobe.com/AdobeProducts/FLBR/4_7/win64/FlashBuilder_4_7_LS10_win64.exe mac http ...

  3. html 字体加粗

    <font style="font-weight: bold;">无敌小昆虫</font> <font>无敌小昆虫</font> f ...

  4. sdutoj 2154 Shopping

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2154 Shopping Time Limit: ...

  5. codevs 1506 传话

    http://codevs.cn/problem/1506/ 1506 传话  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 白银 Silver 题解       题目描述 D ...

  6. struts_23_xwork校验器列表使用例子

    required 必填校验器 <field-validator type="required"> <message>性别不能为空!</message& ...

  7. geotools

    http://blog.tigerlihao.cn/2010/01/geotools-based-web-map-service.html

  8. 为archlinux配置cron

    cron的作用:cron可以用来周期性地自动执行一些命令. cron的实现:cron有很多实现版本,例如:cronie, dcron, fcron, bcron, vixie-cron,我安装的是 c ...

  9. zw版【转发·台湾nvp系列Delphi例程】HALCON AffineTransImage

    zw版[转发·台湾nvp系列Delphi例程]HALCON AffineTransImage unit Unit1;interfaceuses Windows, Messages, SysUtils, ...

  10. 给Debian浏览器安装flash播放插件

    sudo apt-get install flashplugin-nonfree