哈希表到底是什么? [英] What exactly are hashtables?

查看:81
本文介绍了哈希表到底是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 它们是什么以及它们如何工作?
  • 它们在哪里使用?
  • 我什么时候(不)应该使用它们?

我一次又一次听到这个词,但我不知道它的确切含义.

I've heard the word over and over again, yet I don't know its exact meaning.

我听到的是,它们通过散列函数发送数组键来允许关联数组,散列函数将其转换为int然后使用常规数组.我对吗?

What I heard is that they allow associative arrays by sending the array key through a hash function that converts it into an int and then uses a regular array. Am I right with that?

(注意:这不是我的功课;我也上过学,但他们只教我们信息学中的BASIC)

(Notice: This is not my homework; I go too school but they teach us only the BASICs in informatics)

推荐答案

维基百科似乎有一个很好的答案.

Wikipedia seems to have a pretty nice answer to what they are.

当您想通过某个索引查找值时应使用它们.

You should use them when you want to look up values by some index.

关于何时不应该使用它们……当您不想按某个索引查找值时(例如,如果您想做的就是遍历它们).

As for when you shouldn't use them... when you don't want to look up values by some index (for example, if all you want to ever do is iterate over them.)

这篇关于哈希表到底是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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