开发者

Accessing built-in string hash functions of Lua

开发者 https://www.devze.com 2022-12-15 00:33 出处:网络
Lua has built-in string hashing functionality for storage of strings inside its maps.It is possible to access it?

Lua has built-in string hashing functionality for storage of strings inside its maps. It is possible to access it?

Or is there another string hash function already available in the l开发者_JAVA百科ua language/libraries?


The hash function is not exposed. By hiding the hash function, the Lua designers reserve the right to change it out from under you. For example, they may one day try "cuckoo hashing", which may work better with a different hash function.

If you want a hash function for storage into a hash table, you will be better off just using a Lua table as your data structure. If you want a hash function to serialize something to disk, you might consider the Kepler project's implementation of MD5 hashing for Lua.


There's no API for direct access to the internal hash function in the Lua core. Why can't you use a Lua table instead?

0

精彩评论

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