C#中不常用的数据结构
C#中不常用的数据结构
锯齿数组
数组片段
IStructuralEquatable和IstructuralComparable
IFormatProvider
调用代码:
SortedList(有序列表)
执行结果:
this is charater A
this is charater B
this is charater C
this is charater D
this is charater E
字典
Lookup(一键多值)
结果:
LiMing
LiXinLiang
LiSiMing
LiMing
LiXinLiang
LiSiMing
SortedDictionary(有序字典)
执行结果:
chapter1:this is chapter 1
chapter2:this is chapter 2
chapter3:this is chapter 3
chapter4:this is chapter 4
chapter5:this is chapter 5
chapter6:this is chapter 6
chapter7:this is chapter 7
chapter8:this is chapter 8
chapter9:this is chapter 9
JianXian:133****1642
JiuXian:137****3215
LiXiaoYao:135****3797
LinYueRu:131****6734
XiaoQiGai:134****4751
ZhaoLinEr:132****8534
Iset接口(HashSet,SortedSet)
Iset接口提供如下方法:创建合集,创建交集,或于一个集合做比较判断是否为其的子集或超集。
执行结果:
Current Collection already have the 'A'
A
B
C
Current Collection already have the 'A'
A
B
C
D
E
F
G
fivetoeight is subset of onetoten.
ontoten is superset of fivetoten
1
2
3
4
9
10
可观察的集合
执行结果:
you add a element in 0,it is value is Jim
you add a element in 1,it is value is Lucy
you add a element in 2,it is value is Alex
you add a element in 3,it is value is Jeff
you remove a element in 0,it is value is Jim
you remove a element in 0,it is value is Lucy
小结:
在日常的开发中,我们主要使用的数据结构并不是很多。它们主要为:值列表,数组,栈,队列或字典。在.Net4版本中又扩展了些数据结构它们分别为:有序队列,存在一对多关系的字典,可观察的集合。也添加了些接口来处理集合对象的值比较问题及集合与集合之间运算的问题。
到目前为止.Net用来处理数据问题的接口如下图:
