| Crates.io | hashmap-mem |
| lib.rs | hashmap-mem |
| version | 0.2.0 |
| created_at | 2025-06-14 20:17:20.174606+00 |
| updated_at | 2025-07-02 19:50:24.584455+00 |
| description | Fast, low-overhead in-memory hashmap implementation optimized for performance using fxhash |
| homepage | |
| repository | https://github.com/swamp/swamp |
| max_upload_size | |
| id | 1712636 |
| size | 29,358 |
A memory-efficient hashmap implementation designed for Virtual Machine implementations (specifically the Swamp VM) and similar low-level use cases.
hashmap-mem is a specialized hashmap implementation designed primarily for use
in Virtual Machine implementations, particularly the
Swamp VM environment, following the Swamp VM
collection standard.
This is not a general-purpose hashmap with all the safety guarantees you'd expect from a standard Rust collection. Instead, it's a memory-optimized implementation. For a more "normal" hashmap implementation with the rust security guarantees, please checkout my seq-map crate:
FxHasher64 for efficient hashingThis crate uses unsafe code extensively and expects you to manage memory
correctly.
The hashmap consists of a header followed by buckets:
+-------------+
| MapHeader |
+-------------+
| Bucket 0 |
| Bucket 1 |
| ... |
| Bucket N-1 |
+-------------+
Each bucket has:
layout: Calculate memory layout for the mapinit: Initialize a new map in pre-allocated memoryget_or_reserve_entry: Find or create an entry for a keylookup: Find an existing entryhas: Check if a key existsremove: Remove an entryoverwrite: Copy all entries from one map to anotherfind_next_valid_entry: Iterator-like functionalityThis is my personal open source project. While you can use the code under the LICENSE, I'm not accepting pull requests at this time.
Feel free to:
If you have ideas or find bugs, open an issue and I'll check it out. Though I can't merge external code right now, your input is always appreciated!
Thanks for understanding! 🙏
Copyright (c) 2025 Peter Bjorklund. All rights reserved