{"id":21586056,"url":"https://github.com/magiclen/leveled-hash-map","last_synced_at":"2025-04-10T20:15:05.831Z","repository":{"id":62441994,"uuid":"156960708","full_name":"magiclen/leveled-hash-map","owner":"magiclen","description":"A structure to separate values into different levels with keys. Every key-value entry which is not at the top level has a parent key at the superior level. Keys at the same level are unique, no matter what parent keys they have.","archived":false,"fork":false,"pushed_at":"2023-09-09T08:39:37.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T17:55:18.276Z","etag":null,"topics":["rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/magiclen.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":"2018-11-10T08:06:31.000Z","updated_at":"2022-12-14T22:54:48.000Z","dependencies_parsed_at":"2024-11-24T18:01:15.654Z","dependency_job_id":null,"html_url":"https://github.com/magiclen/leveled-hash-map","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"d9d6027d33144a2c4fb919ca182dc9d2e4fca55c"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fleveled-hash-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fleveled-hash-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fleveled-hash-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fleveled-hash-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiclen","download_url":"https://codeload.github.com/magiclen/leveled-hash-map/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247997936,"owners_count":21030703,"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":["rust"],"created_at":"2024-11-24T15:12:30.769Z","updated_at":"2025-04-10T20:15:05.807Z","avatar_url":"https://github.com/magiclen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Leveled HashMap\n====================\n\n[![CI](https://github.com/magiclen/leveled-hash-map/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/leveled-hash-map/actions/workflows/ci.yml)\n\n`LeveledHashMap` is a structure to separate values into different levels with keys. Every key-value entry which is not at the top level has a parent key at the superior level. Keys at the same level are unique, no matter what parent keys they have.\n\n## Example\n\n```rust\nuse std::sync::Arc;\nuse std::collections::HashMap;\n\nuse leveled_hash_map::LeveledHashMap;\n\n#[derive(Debug)]\nstruct MultiName {\n    us: \u0026'static str,\n    tw: \u0026'static str,\n    cn: \u0026'static str,\n}\n\nfn main() {\n    let earth_map: LeveledHashMap\u003c\u0026'static str, MultiName\u003e = {\n        let mut map = LeveledHashMap::new();\n\n        map.insert(\u0026[Arc::new(\"US\")], MultiName {\n            us: \"United States of America\",\n            tw: \"美國\",\n            cn: \"美国\",\n        }).unwrap();\n\n        let mut us_states = HashMap::new();\n\n        us_states.insert(\"New York\", MultiName {\n            us: \"New York\",\n            tw: \"紐約州\",\n            cn: \"纽约州\",\n        });\n        us_states.insert(\"Utah\", MultiName {\n            us: \"Utah\",\n            tw: \"猶他州\",\n            cn: \"犹他州\",\n        });\n\n        map.insert_many(\u0026[Arc::new(\"US\")], us_states, 0).unwrap();\n\n        map.insert(\u0026[Arc::new(\"CN\")], MultiName {\n            us: \"China\",\n            tw: \"中國\",\n            cn: \"中国\",\n        }).unwrap();\n\n        let mut cn_provinces = HashMap::new();\n\n        cn_provinces.insert(\"Guangdong\", MultiName {\n            us: \"Guangdong\",\n            tw: \"廣東省\",\n            cn: \"广东省\",\n        });\n        cn_provinces.insert(\"Fujian\", MultiName {\n            us: \"Fujian\",\n            tw: \"福建省\",\n            cn: \"福建省\",\n        });\n\n        map.insert_many(\u0026[Arc::new(\"CN\")], cn_provinces, 0).unwrap();\n\n        map.insert(\u0026[Arc::new(\"TW\")], MultiName {\n            us: \"Taiwan\",\n            tw: \"臺灣\",\n            cn: \"臺湾\",\n        }).unwrap();\n\n        let mut tw_counties = HashMap::new();\n\n        tw_counties.insert(\"Taipei\", MultiName {\n            us: \"Taipei\",\n            tw: \"台北\",\n            cn: \"台北\",\n        });\n\n        tw_counties.insert(\"Taichung\", MultiName {\n            us: \"Taichung\",\n            tw: \"台中\",\n            cn: \"台中\",\n        });\n\n        map.insert_many(\u0026[Arc::new(\"TW\")], tw_counties, 0).unwrap();\n\n        map\n    };\n\n    println!(\"{:?}\", earth_map);\n\n    let countries = earth_map.keys(0).unwrap();\n\n    println!(\"{:?}\", countries); // {\"CN\": {\"Fujian\", \"Guangdong\"}, \"US\": {\"Utah\", \"New York\"}, \"TW\": {\"Taichung\", \"Taipei\"}}\n\n    let new_york = earth_map.get(\u0026[Arc::new(\"US\"), Arc::new(\"New York\")]).unwrap();\n\n    println!(\"{:?}\", new_york); // MultiName { us: \"New York\", tw: \"紐約州\", cn: \"纽约州\" }\n\n    let new_york = earth_map.get_advanced(\u0026[Arc::new(\"New York\")], 1).unwrap();\n\n    println!(\"{:?}\", new_york); // MultiName { us: \"New York\", tw: \"紐約州\", cn: \"纽约州\" }\n\n    let new_york_suspicion = earth_map.get(\u0026[Arc::new(\"TW\"), Arc::new(\"New York\")]);\n\n    println!(\"{:?}\", new_york_suspicion); // None\n}\n```\n\n## Crates.io\n\nhttps://crates.io/crates/leveled-hash-map\n\n## Documentation\n\nhttps://docs.rs/leveled-hash-map\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fleveled-hash-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclen%2Fleveled-hash-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fleveled-hash-map/lists"}