地图和字典有什么区别? [英] What is the difference between a map and a dictionary?

查看:18
本文介绍了地图和字典有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道映射是一种将键映射到值的数据结构.字典不一样吗?地图和字典有什么区别1?

I know a map is a data structure that maps keys to values. Isn't a dictionary the same? What is the difference between a map and a dictionary1?

<子>1. 我不是在问它们在语言 X 或 Y 中是如何定义的(这似乎是人们在 SO 上普遍提出的问题),我想知道它们在理论上的区别是什么.

推荐答案

同一事物的两个术语:

  • Map"被Java、C++使用
  • 字典"被 .Net、Python 使用
  • 关联数组"被PHP使用
  • "Map" is used by Java, C++
  • "Dictionary" is used by .Net, Python
  • "Associative array" is used by PHP

Map" 是正确的数学术语,但被避免使用,因为它在 函数式编程.

"Map" is the correct mathematical term, but it is avoided because it has a separate meaning in functional programming.

有些语言还使用其他术语(Javascript 中的Object",Ruby 中的Hash",Lua 中的Table"),但这些在编程中也有不同的含义,所以我会避开它们.

Some languages use still other terms ("Object" in Javascript, "Hash" in Ruby, "Table" in Lua), but those all have separate meanings in programming too, so I'd avoid them.

请参阅此处了解更多信息.

这篇关于地图和字典有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆