字典
使用对值进行索引的键映射数据
字典是一种将每个键与对应的值相关联的数据结构体。键和值可以采用任何数据类型,为数据访问提供优于数组索引的灵活性,并能提高性能。
推荐使用 dictionary
而不是 containers.Map
,因为它支持更多数据类型作为键和值,并能提供更好的性能。 (自 R2022b 起)
函数
dictionary | 将唯一键映射到值的对象 (自 R2022b 起) |
entries | Key-value pairs of dictionary (自 R2022b 起) |
keys | 字典的键 (自 R2022b 起) |
values | Values of dictionary (自 R2022b 起) |
types | Types of dictionary keys and values (自 R2022b 起) |
numEntries | Number of key-value pairs in dictionary (自 R2022b 起) |
isConfigured | Determine if dictionary has types assigned to keys and values (自 R2022b 起) |
isKey | Determine if dictionary contains key (自 R2022b 起) |
keyHash | Generate hash code for dictionary key (自 R2022b 起) |
keyMatch | Determine if two dictionary keys are the same (自 R2022b 起) |
类
主题
- Map Data with Dictionaries
Use dictionaries to store key-value pairs of different data types. (自 R2022b 起)
- Dictionaries and Custom Classes
Modify custom classes for expected behavior in dictionaries.