{"id":18167165,"url":"https://github.com/laumbourassa/ght","last_synced_at":"2026-02-08T22:33:07.585Z","repository":{"id":260174718,"uuid":"877630966","full_name":"laumbourassa/ght","owner":"laumbourassa","description":"Generic Hash Table (GHT) library in C","archived":false,"fork":false,"pushed_at":"2024-11-21T18:22:09.000Z","size":48,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-21T19:26:08.341Z","etag":null,"topics":["c","dynamic","generic","hash-table"],"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/laumbourassa.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-10-24T01:03:37.000Z","updated_at":"2024-11-21T18:22:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"54431b9c-eac5-44ec-b5c1-6a55100d83e3","html_url":"https://github.com/laumbourassa/ght","commit_stats":{"total_commits":26,"total_committers":2,"mean_commits":13.0,"dds":0.1923076923076923,"last_synced_commit":"351ae9fc5f4612e7448786694e5375e345f883c8"},"previous_names":["laumbourassa/ght"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laumbourassa%2Fght","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laumbourassa%2Fght/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laumbourassa%2Fght/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laumbourassa%2Fght/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laumbourassa","download_url":"https://codeload.github.com/laumbourassa/ght/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230634237,"owners_count":18256834,"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":["c","dynamic","generic","hash-table"],"created_at":"2024-11-02T13:06:45.351Z","updated_at":"2026-02-08T22:33:02.550Z","avatar_url":"https://github.com/laumbourassa.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Generic Hash Table (GHT) Library\n\n## Overview\n\nThe **Generic Hash Table (GHT)** library is a C library that provides a flexible and efficient hash table implementation with support for generic keys and values. It offers a customizable interface for hashing functions, memory management, and resizing, making it suitable for a wide range of applications.\n\n## Features\n- **Generic Key-Value Storage:** Supports different data types (integers, floats, and pointers) for both keys and values using a unified `ght_key_t` and `ght_data_t` type.\n- **Customizable Hashing:** Allows users to define their own hash functions or use the built-in Murmur3 hash.\n- **Automatic Resizing:** Supports automatic resizing based on load factor, optimizing memory usage and lookup efficiency.\n- **Memory Management:** Offers user-defined deallocation functions for managing custom data structures.\n\n## Getting Started\n\n### Prerequisites\nTo use the GHT library, ensure you have a C compiler installed and the necessary tools to compile and link C programs.\n\n### Installation\n\n1. Clone the GHT library source files into your project directory.\n2. Include the **ght.h** header file in your project:\n```c\n#include \"ght.h\"\n```\n\n### Compilation\nTo compile your program with the GHT library, ensure you link both the **ght.c** and **ght.h** files with your program:\n\n```bash\ngcc -o your_program your_program.c ght.c\n```\n\n### Basic Usage Example\n\n```c\n#include \u003cstdio.h\u003e\n#include \"ght.h\"\n\nint main()\n{\n  // Create a hash table\n  ght_table_t* table = ght_create(NULL);\n\n  // Insert key-value pairs\n  ght_insert(table, GHT_KEY(1), GHT_DATA(100));\n  ght_insert(table, GHT_KEY(2), GHT_DATA(200));\n\n  // Search for a value by key\n  printf(\"Value for key 1: %ld\\n\", (long) ght_search(table, GHT_KEY(1)));\n\n  // Get table load and width\n  printf(\"Table load: %zu\\n\", ght_load(table));\n  printf(\"Table width: %zu\\n\", ght_width(table));\n\n  // Delete a key-value pair\n  ght_delete(table, GHT_KEY(1));\n\n  // Destroy the table when done\n  ght_destroy(table);\n\n  return 0;\n}\n```\n\n### API Documentation\n\n#### Table Management\n- `ght_table_t* ght_create(ght_cfg_t* cfg);`  \n  Creates and returns a new hash table.\n\n- `ght_status_t ght_destroy(ght_table_t* table);`  \n  Destroys the table and frees all allocated memory using a custom deallocator if provided.\n\n- `ght_load_t ght_load(ght_table_t* table);`  \n  Returns the number of elements in the table.\n\n- `ght_width_t ght_width(ght_table_t* table);`  \n  Returns the width (number of buckets) of the table.\n\n- `ght_load_factor_t ght_load_factor(ght_table_t* table);`  \n  Returns the load factor of the table.\n\n- `ght_status_t ght_resize(ght_table_t* table, ght_width_t width);`  \n  Resizes the table to the specified width.\n\n#### Data Operations\n- `ght_status_t ght_insert(ght_table_t* table, ght_key_t key, ght_data_t data);`  \n  Inserts a key-value pair into the table.\n\n- `ght_data_t ght_search(ght_table_t* table, ght_key_t key);`  \n  Searches and returns the value associated with the given key, or 0 if not found.\n\n- `ght_status_t ght_delete(ght_table_t* table, ght_key_t key);`  \n  Deletes the key-value pair from the table.\n\n#### Conversion Macros\n- `GHT_DATA(data)`  \n  Converts various data types (integers, floats, pointers) to `ght_data_t`, which is used in the hash table.\n\n- `GHT_KEY(key)`  \n  Converts various data types to `ght_key_t`, which is used as a key in the hash table.\n\n## License\n\nThe GHT library is released under the **MIT License**. You are free to use, modify, and distribute it under the terms of the license. See the [MIT License](https://opensource.org/licenses/MIT) for more details.\n\n## Author\n\nThis library was developed by **Laurent Mailloux-Bourassa**.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaumbourassa%2Fght","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaumbourassa%2Fght","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaumbourassa%2Fght/lists"}