{"id":30426057,"url":"https://github.com/simpsonresearch/c_array_map","last_synced_at":"2025-08-22T12:09:11.890Z","repository":{"id":182431006,"uuid":"668483612","full_name":"simpsonresearch/c_array_map","owner":"simpsonresearch","description":"Map in C using Arrays","archived":false,"fork":false,"pushed_at":"2023-07-19T23:31:44.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-11T15:30:02.496Z","etag":null,"topics":["arrays","c","map"],"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/simpsonresearch.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}},"created_at":"2023-07-19T23:30:21.000Z","updated_at":"2023-07-19T23:31:13.000Z","dependencies_parsed_at":"2023-07-20T00:39:05.552Z","dependency_job_id":null,"html_url":"https://github.com/simpsonresearch/c_array_map","commit_stats":null,"previous_names":["simpson-computer-technologies-research/c_array_map","simpsonresearch/c_array_map"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/simpsonresearch/c_array_map","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2Fc_array_map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2Fc_array_map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2Fc_array_map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2Fc_array_map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simpsonresearch","download_url":"https://codeload.github.com/simpsonresearch/c_array_map/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2Fc_array_map/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271635949,"owners_count":24794144,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["arrays","c","map"],"created_at":"2025-08-22T12:09:07.111Z","updated_at":"2025-08-22T12:09:11.871Z","avatar_url":"https://github.com/simpsonresearch.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# c_array_map\nMap in C using Arrays\n\n```C\n#include \u003cstdlib.h\u003e\n\ntypedef struct ArrayMap {\n    int size;\n    int *keys;\n    int *values;\n} ArrayMap;\n\n/**\n * Function to set a value in a map\n * @param map The map to set the value in\n * @param key The key to set the value for\n * @param value The value to set\n*/\nvoid set(ArrayMap *map, int key, int value) {\n    // Check if the key exists\n    for (int i = 0; i \u003c map-\u003esize; i++) {\n        if (map-\u003ekeys[i] == key) {\n            map-\u003evalues[i] = value;\n            return;\n        }\n    }\n\n    // Key doesn't exist, add it\n    map-\u003esize++;\n    map-\u003ekeys = realloc(map-\u003ekeys, sizeof(int) * map-\u003esize);\n    map-\u003evalues = realloc(map-\u003evalues, sizeof(int) * map-\u003esize);\n    map-\u003ekeys[map-\u003esize - 1] = key;\n    map-\u003evalues[map-\u003esize - 1] = value;\n}\n\n/**\n * Function to create a new map\n * @return The new map\n*/\nArrayMap *new() {\n    ArrayMap *map = malloc(sizeof(ArrayMap));\n    map-\u003esize = 0;\n    map-\u003ekeys = malloc(sizeof(int) * map-\u003esize);\n    map-\u003evalues = malloc(sizeof(int) * map-\u003esize);\n    return map;\n}\n\n/**\n * Function to get a value from a map\n * @param map The map to get the value from\n * @param key The key to get the value for\n * @return The value for the key\n*/\nint get(ArrayMap *map, int key) {\n    // Check if the key exists\n    for (int i = 0; i \u003c map-\u003esize; i++) {\n        if (map-\u003ekeys[i] == key) {\n            // Key exists, return the value\n            return map-\u003evalues[i];\n        }\n    }\n\n    // Key doesn't exist, return -1\n    return -1;\n}\n\n// Main function\nint main(int argc, char *argv[]) {\n    // Create a new map\n    ArrayMap *map = new();\n\n    // Set some values\n    set(map, 1, 10);\n\n    // Get some values\n    printf(\"%d\\n\", get(map, 1));\n\n    return 0;\n}\n```\n\n# License\nMIT License\n\nCopyright (c) 2023 Simpson Computer Technologies Research\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpsonresearch%2Fc_array_map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimpsonresearch%2Fc_array_map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpsonresearch%2Fc_array_map/lists"}