{"id":24351224,"url":"https://github.com/theobori/tinyhash","last_synced_at":"2026-07-01T12:31:16.186Z","repository":{"id":271027400,"uuid":"848848586","full_name":"theobori/tinyhash","owner":"theobori","description":"Hashmap multiple implementations library for C","archived":false,"fork":false,"pushed_at":"2025-01-04T21:41:36.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-31T09:46:30.556Z","etag":null,"topics":["api","c","hashmap","interface","library","open-addressing","separate-chaining"],"latest_commit_sha":null,"homepage":"https://theobori.github.io/tinyhash","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/theobori.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-08-28T14:13:55.000Z","updated_at":"2025-01-04T21:41:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"e035a115-be83-469d-96c3-f0062a59dbaf","html_url":"https://github.com/theobori/tinyhash","commit_stats":null,"previous_names":["theobori/tinyhash"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/theobori/tinyhash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theobori%2Ftinyhash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theobori%2Ftinyhash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theobori%2Ftinyhash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theobori%2Ftinyhash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theobori","download_url":"https://codeload.github.com/theobori/tinyhash/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theobori%2Ftinyhash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35007274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-01T02:00:05.325Z","response_time":130,"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":["api","c","hashmap","interface","library","open-addressing","separate-chaining"],"created_at":"2025-01-18T14:59:31.790Z","updated_at":"2026-07-01T12:31:16.179Z","avatar_url":"https://github.com/theobori.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C hashmap implementations\n\n[![build](https://github.com/theobori/tinyhash/actions/workflows/build.yml/badge.svg)](https://github.com/theobori/tinyhash/actions/workflows/build.yml) [![lint](https://github.com/theobori/tinyhash/actions/workflows/lint.yml/badge.svg)](https://github.com/theobori/tinyhash/actions/workflows/lint.yml)\n\n[![built with nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org)\n\nThis is a library containing multiple C implementations of hashmap. The public API is deliberately simple and user-friendly.\n\nHere are the different methods implemented:\n- [Separate chaining](./src/separate_chaining/)\n- [Open addressing](./src/open_addressing/)\n\n## 📖 Build and run\n\nFor the build, you only need the following requirements:\n\n- [CMake](https://cmake.org/download/) minimum 3.10\n\nTo build the library, you can run the following commands.\n```sh\nmkdir build\ncd build\ncmake ..\nmake\n```\n\nIf you want to install the library, you can run the following command.\n```sh\nmake install\n```\n\nThe following CMake build arguments are available to enable or disable options.\n\n\n| Name | Description | Default value |\n| -- | -- | -- |\n| `-DBUILD_TESTS` | Compile the test files | **`ON`**\n| `-DBUILD_STATIC` | Link as a static library (instead of a shared library) | **`OFF`**\n| `-DBUILD_DOC` | Build the documentation | **`OFF`**\n\n## 🤝 Contribute\n\nIf you want to help the project, you can follow the guidelines in [CONTRIBUTING.md](./CONTRIBUTING.md).\n\n## 🧪 Tests\n\nMake sure you run CMake with the `-DBUILD_TESTS=ON` flag.\nThe generated Makefile will contain a special `test` target, so you can run the tests with the following command:\n\n```bash\nmake test\n```\n\n## 📝 Documentation\n\nJust make sure you run CMake with the `-DBUILD_DOC=ON` flag.\n\nThe Makefile `all` target will automatically build the documentation.\n\n## 📎 Some examples\n\nHere is a basic example of how you could use the hashmap.\n\n### With the root controller (high level)\n\n```c\n#include \u003cstdint.h\u003e\n#include \u003cstdio.h\u003e\n#include \u003cstring.h\u003e\n\n#include \u003ctinyhash/tinyhash.h\u003e\n\ntypedef struct {\n  char name[10];\n  bool is_hydrated;\n} person_t;\n\nint main(int argc, const char *argv[]) {\n  bool success;\n  person_t person = {\"James\", true};\n\n  // Create a controller with the open addressing method\n  th_t th = th_create(TH_OPEN_ADRESSING);\n\n  // Insert a new key value pair\n  success = th_put(\u0026th, \"key_1\", strlen(\"key_1\"), \u0026person);\n  if (success == false) {\n    fprintf(stderr, \"Unable to insert\\n\");\n    return 1;\n  }\n\n  // Get the last inserted value\n  person_t *james;\n  james = th_get(\u0026th, \"key_1\", strlen(\"key_1\"));\n  if (success == false) {\n    fprintf(stderr, \"It does not exist\\n\");\n    return 1;\n  }\n\n  printf(\"name -\u003e %s, is_hydrated -\u003e %d, hashmap length -\u003e %d\\n\", james-\u003ename,\n         james-\u003eis_hydrated, th_len(\u0026th));\n\n  // Quick multiple insert with the same value (not important here)\n  th_put(\u0026th, \"key_2\", strlen(\"key_2\"), \u0026person);\n  th_put(\u0026th, \"key_3\", strlen(\"key_3\"), \u0026person);\n  th_put(\u0026th, \"key_4\", strlen(\"key_4\"), \u0026person);\n\n  printf(\"hashmap length -\u003e %d\\n\", th_len(\u0026th));\n\n  th_iterator_t *it;\n  person_t *p;\n\n  // Iterate with a for loop\n  for (it = th_begin_iterator(\u0026th); it != NULL; th_iterator_next(\u0026it)) {\n    p = it-\u003evalue;\n    printf(\"[for] key -\u003e %s, name -\u003e %s\\n\", it-\u003ekey-\u003edata, p-\u003ename);\n  }\n\n  // Iterate with a while loop\n  it = th_empty_iterator(\u0026th);\n  while (th_iterator_next(\u0026it) == true) {\n    p = it-\u003evalue;\n    printf(\"[while] key -\u003e %s, name -\u003e %s\\n\", it-\u003ekey-\u003edata, p-\u003ename);\n  }\n\n  // Delete an entry\n  success = th_delete(\u0026th, \"key_1\", strlen(\"key_1\"));\n  if (success == false) {\n    fprintf(stderr, \"Unable to delete\\n\");\n    return 1;\n  }\n\n  // Verify that it doesnt exist anymore\n  james = th_get(\u0026th, \"key_1\", strlen(\"key_1\"));\n  if (james != NULL) {\n    fprintf(stderr, \"The entry still exists\\n\");\n    return 1;\n  }\n\n  // Free the allocated memory\n  th_free(\u0026th);\n\n  return 0;\n}\n```\n\n### Without the root controller (lower level)\n\nThis is exactly the same logic as using the root controller, although the prefix of functions and types will change.\n\nFor example, to use the ‘separate chaining’ method, the prefix will be `th_sc_table`.f\n\n```c\n#include \u003cstring.h\u003e\n\n#include \u003ctinyhash/separate_chaining/table.h\u003e\n\nint main(int argc, const char *argv[]) {\n  th_sc_table_t table;\n\n  th_sc_table_init(\u0026table);\n  th_sc_table_put(\u0026table, \"hello\", strlen(\"hello\"), (th_any_t)0);\n  // etc..\n\n  return 0;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheobori%2Ftinyhash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheobori%2Ftinyhash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheobori%2Ftinyhash/lists"}