Repository navigation
Conversation
- IntMap stores int keys and values in cell buffers with one occupancy byte per slot; linear probing plus tombstones handle collisions and deletion. - Constructor parameters: initial capacity, growth ratio, load factor, hash seed and hash kind. Kinds include a murmur-style finalizer, a golden-ratio mix, identity-xor and a deliberately weak 7-bucket mode for collision tests. - Probe helpers are free functions because nested methods currently fault in the backend; methods call only free helpers, never another method on the same receiver. - test_intmap.py drives 500 deterministic LCG operations against a Python dict oracle and checks capacity growth plus every lookup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
新增
src/stdlib/hashmap.cr:开放寻址的IntMap(int → int)。initial_capgrowth_num/growth_den(扩容比例)load_num/load_den(装填因子)seedhash_kind(0 murmur 风格、1 golden-ratio、2 identity-xor、3 故意只有 7 桶的弱哈希,用于碰撞测试)intMap():cap 16 / 2x 增长 / 3/4 装填 / seed 0 / kind 0。put/get/has/remove/size/capacity/clear。验证
selfhost-tests全绿(新增test_intmap.py)bootstrap-tests全绿check全绿canary5/5,值不变test_intmap.py:默认 map、参数化增长(cap 4 / growth 3:2 / load 1:1)、弱哈希碰撞表、清空;以及 500 次确定性 LCG 操作与 Python dict 对拍(size、最终 capacity、100 个 key 的 get)。
备注
探测 helper 是自由函数(按值接收
IntMap),方法只调用 helper:嵌套
&self方法调用目前在 backend 段错误(已用最小 probe 复现),本批绕开该路径,不改语言/后端。