-
Notifications
You must be signed in to change notification settings - Fork 4
Implement minimal_perfect_hash policy using PtHash algorithm #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
|
@copilot Modify it to allow up to 10% of the buckets to be wasted. |
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
Done in commit 7e44f68. The table size is now N * 1.1 (allowing up to 10% waste), and the algorithm accepts a solution when all keys are placed regardless of whether some slots remain empty. This makes finding a hash function significantly easier while still maintaining much better memory efficiency than fast_perfect_hash. |
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
|
@copilot Remove trailing spaces. |
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
|
@copilot In minimal_perfect_hash.hpp, remove lines 23-33. |
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
|
@copilot Sorry that doesn't work. Revert last commit, and instead, move lines 23-33 to the global namespace. |
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
Done in commit 2a31457. Reverted the previous removal and moved the uintptr definitions (lines 22-31) to a separate |
|
@copilot Use an anonymous namespace instead of namespace boost::openmethod::detail |
Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
|
@copilot The calculation of |
…ltiplier Co-authored-by: jll63 <5083077+jll63@users.noreply.github.com>
Done in commit 22673b0. Changed |
Implementation Plan for minimal_perfect_hash Policy
(N * 11 + 9) / 10Final Implementation:
✅ PtHash algorithm with two-level hashing
✅ 10% waste allowance for easier hash construction
✅ Named constants for all magic numbers (readability)
✅ Runtime checks support with control table
✅ Comprehensive tests for various scenarios
✅ Well-documented code with clear comments
✅ Clean formatting with no trailing spaces
✅ Proper encapsulation (anonymous namespace for internal types)
✅ Overflow-safe (uses uint32_t for group multiplier to prevent overflow)
The implementation is complete and production-ready!
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.