{"id":22809155,"url":"https://github.com/wolgemoth/cpp-hashmap","last_synced_at":"2025-03-30T21:18:25.075Z","repository":{"id":216572782,"uuid":"741628957","full_name":"wolgemoth/cpp-hashmap","owner":"wolgemoth","description":"Concurrent multiplatform hashmap with simple API, exception safety, and sequential collision resolution.","archived":false,"fork":false,"pushed_at":"2024-07-27T22:03:33.000Z","size":71,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-06T00:31:48.783Z","etag":null,"topics":["concurrency","concurrent","cpp","cpp17","dictionary","exception-safety","hashmap","initializer-list","modern-cpp","multiplatform","multithreading","sequential-chain","templates"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wolgemoth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-10T19:34:34.000Z","updated_at":"2024-07-30T16:47:04.000Z","dependencies_parsed_at":"2025-02-06T00:39:27.550Z","dependency_job_id":null,"html_url":"https://github.com/wolgemoth/cpp-hashmap","commit_stats":null,"previous_names":["wolgemoth/cpp-hashmap"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolgemoth%2Fcpp-hashmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolgemoth%2Fcpp-hashmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolgemoth%2Fcpp-hashmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolgemoth%2Fcpp-hashmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wolgemoth","download_url":"https://codeload.github.com/wolgemoth/cpp-hashmap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246379362,"owners_count":20767696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","concurrent","cpp","cpp17","dictionary","exception-safety","hashmap","initializer-list","modern-cpp","multiplatform","multithreading","sequential-chain","templates"],"created_at":"2024-12-12T11:13:48.565Z","updated_at":"2025-03-30T21:18:25.041Z","avatar_url":"https://github.com/wolgemoth.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ Hashmap (2.3.0)\n\n## Table of Contents\n\n- [About](#About)\n- [Instructions](#Instructions)\n- [Dependencies](#Dependencies)\n- [References](#References)\n\n### About\n\nThis is a hashmap written in C++.\n\nIt has a similar API to C#'s [Dictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2?view=net-8.0)  and self-initializes like an [std::vector](https://en.cppreference.com/w/cpp/container/vector). Currently, it uses [sequential chaining](https://en.wikipedia.org/wiki/Hash_table#Separate_chaining) for collision resolution. More collision resolution techniques may be added in the future.\n\nThis structure provides robust exception safety, and is suitable for use in a concurrent environment. Furthermore, it supports move semantics and initialiser lists.\n\nExplicit finalization of the hashmap is not necessary. However, if you are storing manually-managed memory, then remember to free any elements before removal.\n\nIf you find a bug or have a feature-request, please raise an issue.\n\nLike hashsets? Check out my other project: [cpp-hashset](https://github.com/wolgemoth/cpp-hashset)!\n\n### Instructions\n\nThe implementation is header-only and written in templated C++17. You should not need to make any adjustments to your project settings or compiler flags. \n\nSimply include it in your project and you are ready to start!\n\n#### Example:\n    \n    #include \u003cstring\u003e\n    \n    #include \"Hashmap.hpp\"\n    \n    LouiEriksson::Hashmap\u003cstd::string, float\u003e hashmap {\n        { \"key1\", 1.0f },\n        { \"key2\", 2.0f },\n        { \"key3\", 3.0f },\n    }\n\n    int main() {\n\n        if (const auto item = hashmap.Get(\"key3\")) {\n            std::cout \u003c\u003c \"Value: \" \u003c\u003c item.value() \u003c\u003c '\\n';\n        }\n        else {\n            std::cout \u003c\u003c \"Key not in Hashmap!\\n\";\n        }\n\n        return 0;\n    }\n\n### Dependencies\n\nThe hashmap was written in C++17 and utilises the following standard headers:\n\n#### \u0026lt;algorithm\u0026gt;\n#### \u0026lt;cstddef\u0026gt;\n#### \u0026lt;functional\u0026gt;\n#### \u0026lt;initializer_list\u0026gt;\n#### \u0026lt;iostream\u0026gt;\n#### \u0026lt;mutex\u0026gt;\n#### \u0026lt;optional\u0026gt;\n#### \u0026lt;stdexcept\u0026gt;\n#### \u0026lt;vector\u0026gt;\n\n### Why not use \u0026lt;unordered_map\u0026gt;?\n\nI find unordered_map to be way too verbose for most situations.\n\nIn this implementation, key existence and value retrieval are merged into a single conditional expression. This allows for simpler, cleaner code that affords better exception handling.\n\n### Note\n\nPlease note that while the hashmap is capable of being used in a concurrent environment, it does not provide a mechanism for synchronising changes to the hashmap which are made in between operations.\n\nTherefore, if you need to perform a synchronous series of operations on the Hashmap while it is being used in a concurrent context, you should lock access to the hashmap to one thread while doing so, otherwise you may encounter race conditions.\n\n### References\n\n- Wang, Q. (Harry) (2020). Implementing Your Own HashMap (Explanation + Code). YouTube. Available at: https://www.youtube.com/watch?v=_Q-eNqTOxlE [Accessed 2021].\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolgemoth%2Fcpp-hashmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwolgemoth%2Fcpp-hashmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolgemoth%2Fcpp-hashmap/lists"}