{"id":19149953,"url":"https://github.com/andreiavrammsd/polymap","last_synced_at":"2025-05-07T04:45:51.268Z","repository":{"id":92015777,"uuid":"332288384","full_name":"andreiavrammsd/polymap","owner":"andreiavrammsd","description":"Map with infinite levels and multiple types for keys and values.","archived":false,"fork":false,"pushed_at":"2024-09-07T10:15:26.000Z","size":65,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T04:45:45.946Z","etag":null,"topics":["cpp","map","polymorphic","recursion","tree"],"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/andreiavrammsd.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,"zenodo":null}},"created_at":"2021-01-23T19:11:21.000Z","updated_at":"2025-04-05T07:26:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"ab14c97a-18ce-448e-a2e2-e584f602af5b","html_url":"https://github.com/andreiavrammsd/polymap","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreiavrammsd%2Fpolymap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreiavrammsd%2Fpolymap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreiavrammsd%2Fpolymap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreiavrammsd%2Fpolymap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreiavrammsd","download_url":"https://codeload.github.com/andreiavrammsd/polymap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252816520,"owners_count":21808702,"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":["cpp","map","polymorphic","recursion","tree"],"created_at":"2024-11-09T08:10:10.007Z","updated_at":"2025-05-07T04:45:51.243Z","avatar_url":"https://github.com/andreiavrammsd.png","language":"C++","readme":"# Poly map\n\n[![test](https://github.com/andreiavrammsd/polymap/workflows/test/badge.svg)](https://github.com/andreiavrammsd/polymap/actions/workflows/cmake.yml)\n\n[![bazel](https://github.com/andreiavrammsd/polymap/workflows/bazel/badge.svg)](https://github.com/andreiavrammsd/polymap/actions/workflows/bazel.yml)\n\n[![codecov](https://codecov.io/github/andreiavrammsd/polymap/graph/badge.svg?token=CKSCACRJXC)](https://codecov.io/github/andreiavrammsd/polymap)\n\n### Polymorphic map container.\n\nA recursive map that can have any shape and can hold multiple types for keys and values.\n\n* Header-only library.\n* Key types are provided at construct time as template arguments. They must meet the type conditions\n  for [std::variant](https://en.cppreference.com/w/cpp/utility/variant).\n* Value types must be copy constructible as the map takes ownership on the objects assigned.\n* Can be visualised as a tree.\n\n## Requirements\n\n* C++17\n* CMake 3.17+ or Bazel\n\n## Usage\n\n```c++\n#include \u003ccassert\u003e\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n#include \u003cutility\u003e\n\n#include \u003cmsd/poly_map.hpp\u003e\n\nstruct visitor {\n    template \u003ctypename V, typename M\u003e\n    bool operator()(const double key, V\u0026, M\u0026)\n    {\n        std::cout \u003c\u003c \"double = \" \u003c\u003c key \u003c\u003c \"\\n\";\n        return true;\n    }\n\n    template \u003ctypename K, typename V, typename M\u003e\n    bool operator()(K\u0026 key, V\u0026, M\u0026)\n    {\n        std::cout \u003c\u003c \"other = \" \u003c\u003c key \u003c\u003c \"\\n\";\n        return true;\n    }\n};\n\nint main() {\n    msd::poly_map\u003cint, double, std::string\u003e map;\n\n    map[1] = 22;\n    map.at(1) = 23;\n    \n    map[1] = std::string{\"a\"};\n    map[1][2] = 9;\n    map.at(1, 2) = 8;\n    map[1][2][3.1] = 1;\n    map[1][2][3.1][\"f\"] = 199;\n    map[1][2][3.1][4.2][\"g\"] = std::make_pair(1, 2);\n\n    assert(map[1][2].get\u003cint\u003e() == 8);\n\n    map.for_each(visitor{});\n\n    assert(!map[1].empty());\n\n    assert(map.size() == 6);\n    assert(map[1].size() == 5);\n\n    assert(map.contains(1, 2, 3.1));\n\n    map[1][2].clear();\n    map.clear();\n}\n```\n\nSee [tests](tests/poly_map_test.cpp).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreiavrammsd%2Fpolymap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreiavrammsd%2Fpolymap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreiavrammsd%2Fpolymap/lists"}