{"id":15645151,"url":"https://github.com/barrust/set","last_synced_at":"2025-04-30T11:15:17.610Z","repository":{"id":55418680,"uuid":"58214041","full_name":"barrust/set","owner":"barrust","description":"Simple Set implementation in C","archived":false,"fork":false,"pushed_at":"2021-06-07T14:24:19.000Z","size":62,"stargazers_count":70,"open_issues_count":1,"forks_count":22,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-19T01:31:45.929Z","etag":null,"topics":["c","set"],"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/barrust.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-06T14:46:11.000Z","updated_at":"2025-03-20T22:25:18.000Z","dependencies_parsed_at":"2022-08-14T23:50:53.505Z","dependency_job_id":null,"html_url":"https://github.com/barrust/set","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barrust%2Fset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barrust%2Fset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barrust%2Fset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barrust%2Fset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barrust","download_url":"https://codeload.github.com/barrust/set/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251687609,"owners_count":21627600,"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","set"],"created_at":"2024-10-03T12:04:48.797Z","updated_at":"2025-04-30T11:15:17.578Z","avatar_url":"https://github.com/barrust.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# set\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![GitHub release](https://img.shields.io/github/v/release/barrust/set.svg)](https://github.com/barrust/set/releases)\n[![C/C++ CI](https://github.com/barrust/set/workflows/C/C++%20CI/badge.svg?branch=master)](https://github.com/barrust/set/actions)\n[![codecov](https://codecov.io/gh/barrust/set/branch/master/graph/badge.svg)](https://codecov.io/gh/barrust/set)\n\nA simple set implementation in **C**\n\nSets allow for quick checks for inclusion and exclusion\n\nThis implementation provides a simple and generally quick method to get set functionality into a C program quickly. It was developed to provide a basis for testing and benchmarking performance along with providing a purposeful, low overhead library. Currently only supports strings.\n\nTo use the library, copy the `src/set.h` and `src/set.c` files into your project and include it where needed.\n\n## License\nMIT 2016\n\n# Main Features\n\n* Union, intersection, difference, and semantic difference\n* Standard and Strict subset and superset checks\n* Simple method to change the hashing function if desired\n* Add, check, and remove elements in a the set\n\n## Future Enhancements\n\n* In place union - add to an already created Set\n* Print statistics about the set\n\n\n## Usage:\n``` c\n#include \"set.h\"\n#include \u003cstdio.h\u003e\n\nint main(int argc, char** argv) {\n    SimpleSet set;\n    set_init(\u0026set);\n    set_add(\u0026set, \"orange\");\n    set_add(\u0026set, \"blue\");\n    set_add(\u0026set, \"red\");\n    set_add(\u0026set, \"green\");\n    set_add(\u0026set, \"yellow\");\n\n    if (set_contains(\u0026set, \"yellow\") == SET_TRUE) {\n        printf(\"Set contains 'yellow'!\\n\");\n    } else {\n        printf(\"Set does not contains 'yellow'!\\n\");\n    }\n\n    if (set_contains(\u0026set, \"purple\") == SET_TRUE) {\n        printf(\"Set contains 'purple'!\\n\");\n    } else {\n        printf(\"Set does not contains 'purple'!\\n\");\n    }\n\n    set_destroy(\u0026set);\n}\n```\n\n## Thread safety\n\nDue to the the overhead of enforcing thread safety, it is up to the user to\nensure that each thread has controlled access to the set. For **OpenMP** code,\nthe following should suffice.\n\n``` c\n#include \"set.h\"\n#include \u003comp.h\u003e\n\nint main(int argc, char** argv) {\n    SimpleSet set;\n    set_init(\u0026set);\n    int i;\n    #pragma omp parallel for private(i)\n    for (i = 0; i \u003c 500000; i++) {\n        char key[KEY_LEN] = {0};\n        sprintf(key, \"%d\", i);\n        #pragma omp critical (set_lock)\n        {\n            set_add(\u0026set, key);\n        }\n    }\n    set_destroy(\u0026set);\n}\n```\n\nAll but `set_contains` needs to be guarded against race conditions as the set\nwill grow as needed. Set comparison functions (union, intersect, etc.) should\nbe done on non-changing sets.\n\n## Required Compile Flags:\n   None\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarrust%2Fset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarrust%2Fset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarrust%2Fset/lists"}