开发者

Do we use hash tables in practise?

I just read about Hash tables and am curious if we use it in practise because if I write a program that stores data in a Hash table, the 开发者_运维知识库storage will only be temporary. So, why not use a database to store it ?

In other words, what kinds of real world programs use hash tables for their functioning?


You would use hash tables to store data while you are working. Using the database for that would in many cases be orders of magnitude slower then using in-memory hash tables. See for example:

  • http://en.wikipedia.org/wiki/Caching

Hash maps are about speed, not persistence.

Take a look at the other uses in the Uses section of Hash table entry on Wikipedia:

  • http://en.wikipedia.org/wiki/Hash_table


There is such a thing as an on-disk hash table, e.g. Tokyo Cabinet's hash database.


hash table is for fast access, let's say that you need to search a lot of records, that will be very expensive. Using a hash function will take you almost directly to the portion you want to search. And you may implement a data base schema hash table alike, so they are not necessarily temporary storage.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜