如何哈希表中流行的语言内部实现的? [英] How are hash tables implemented internally in popular languages?

查看:195
本文介绍了如何哈希表中流行的语言内部实现的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人请阐明如何流行的语言如Python一些光,红宝石实现哈希表内的符号查找?他们使用的方法了经典的用链表阵,或使用一个平衡树?

Can someone please shed some light on how popular languages like Python, Ruby implements hash tables internally for symbol lookup? Do they use the classic "array with linked-list" method, or use a balanced tree?

我需要一个简单的(更少的LOC)和快速的方法在索引用C编写的一个DSL符号想知道其他人发现最有效和实用的。

I need a simple (fewer LOC) and fast method for indexing the symbols in a DSL written in C. Was wondering what others have found most efficient and practical.

推荐答案

经典的散列桶阵你提到在每个我见过的实现中使用。

The classic "array of hash buckets" you mention is used in every implementation I've seen.

其中最教育性的版本是Tcl语言的哈希实施,文件<一个href=\"http://tcl.cvs.sourceforge.net/viewvc/tcl/tcl/generic/tclHash.c?revision=1.38&view=markup\">tcl/generic/tclHash.c.超过一半的文件中的行被注释解释的所有的细节:分配,搜索,不同的哈希表类型,策略等旁注:在code implementating Tcl语言中的真正的可读性。

One of the most educative versions is the hash implementation in the Tcl language, in file tcl/generic/tclHash.c. More than half of the lines in the file are comments explaining everything in detail: allocation, search, different hash table types, strategies, etc. Sidenote: the code implementating the Tcl language is really readable.

这篇关于如何哈希表中流行的语言内部实现的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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