磁盘阵列/列表VS词典(为什么我们有他们在首位) [英] Array/list vs Dictionary (why we have them at first place)
问题描述
要我,他们都是一样的,这就是为什么我想知道为什么我们有字典的数据结构时,我们可以用数组/列表的一切吗?什么是字典那么花哨?
To me they are both same and that is why i am wondering why we have dictionary data structure when we can do everything with arrays/list? What is so fancy in dictionaries?
推荐答案
阵列提供一个顺序组数据的随机访问。字典(或关联数组的)提供了从一组键映射到一组值。
Arrays provide random access of a sequential set of data. Dictionaries (or associative arrays) provide a map from a set of keys to a set of values.
我相信你是比较苹果和桔子 - 他们有两个完全不同的目的,都是有用的数据结构
I believe you are comparing apples and oranges - they serve two completely different purposes and are both useful data structures.
大多数的字典样型被构建为哈希表的时候 - 这种类型的很的,因为它提供关于平均(取决于散列算法的质量)。
Most of the time a dictionary-like type is built as a hash table - this type is very useful as it provides very fast lookups on average (depending on the quality of the hashing algorithm).
这篇关于磁盘阵列/列表VS词典(为什么我们有他们在首位)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!