博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SortedDictionary和SortedList
阅读量:6909 次
发布时间:2019-06-27

本文共 966 字,大约阅读时间需要 3 分钟。

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

 

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

 

博友的测试结果:

 

直接在Unity3D里测一下

public class Test : MonoBehaviour{    void Start()    {        var sortedDict = new SortedDictionary
(); sortedDict.Add("a01", 10); sortedDict.Add("a10", 2); sortedDict.Add("a03", 5); sortedDict.Add("a02", 1); print(sortedDict["a01"]); foreach (var item in sortedDict) { Debug.Log("SortedDictionary: " + item); } var sortedList = new SortedList
(); sortedList.Add("a01", 10); sortedList.Add("a10", 2); sortedList.Add("a03", 5); sortedList.Add("a02", 1); print(sortedList["a01"]); foreach (var item in sortedList) { Debug.Log("SortedList: " + item); } }}
View Code

 

调用结果:

 

转载于:https://www.cnblogs.com/hont/p/5420060.html

你可能感兴趣的文章
CentOS7.x配置bond0
查看>>
vue随记
查看>>
Quick-cocos2d-x3.3 Study (十一)--------- 让物体从屏幕的外边移动到屏幕中指定位置...
查看>>
[转] 数据挖掘中易犯的几大错误
查看>>
select函数用法详解
查看>>
本地jar包添加到maven仓库
查看>>
ROS学习网址【原创】
查看>>
Linux 2440 LCD 控制器【转】
查看>>
Daily Scrum – 1/18
查看>>
Tomcat配置管理员账号
查看>>
centos FTP服务器的架设和配置
查看>>
深度:ARC会导致的内存泄露
查看>>
内存泄漏和内存溢出
查看>>
设计模式——初步学习
查看>>
metabase实施文档
查看>>
10.3 定位连续值范围的开始点和结束点
查看>>
解析iscroll-小demo
查看>>
基站定位接口说明文档
查看>>
java实现邮件定时发送
查看>>
差分约束 【bzoj2330】[SCOI2011]糖果
查看>>