{"id":23508752,"url":"https://github.com/lovasko/m_int_combo","last_synced_at":"2025-06-11T19:37:22.482Z","repository":{"id":78821003,"uuid":"50121473","full_name":"lovasko/m_int_combo","owner":"lovasko","description":"Integer Combinations for C89","archived":false,"fork":false,"pushed_at":"2016-03-13T06:55:59.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-13T15:57:01.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lovasko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2016-01-21T16:45:08.000Z","updated_at":"2016-02-17T15:46:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"4dbe35e5-f634-40c5-a39e-8eaf85de5044","html_url":"https://github.com/lovasko/m_int_combo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lovasko/m_int_combo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Fm_int_combo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Fm_int_combo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Fm_int_combo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Fm_int_combo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovasko","download_url":"https://codeload.github.com/lovasko/m_int_combo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Fm_int_combo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259325565,"owners_count":22841058,"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":[],"created_at":"2024-12-25T11:31:58.494Z","updated_at":"2025-06-11T19:37:22.464Z","avatar_url":"https://github.com/lovasko.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# m_intcombo\nGeneral-purpose integer combinations library in the C89 language that runs\non all POSIX-compatible systems.\n\n## Introduction\nThe `m_intcombo` library implements the idea of all possible combinations\nwhere each element of the combination is drawn from a different set. To\nsimplify the idea and create an easy understandable abstraction\n(homomorphism), the sets are not real object, only mere `intmax_t`\ninstances.\n\n## Usage\n### Initialization\nThe internal state of the combination is stored in a `struct m_intcombo`\ninstance. Before using any other functions, it is necessary to call the\n`m_intcombo_init` function to properly initialise the data structure.\n\n### Source set addition\nIn order to add a source set for the combination, use the `m_intcombo_add`\nfunction. The source set is always an interval, specified by its low and\nhigh bounds.\n\n### Finalization \nAfter adding all source sets, the `m_intcombo_finalize` function needs to\nbe called. This function also returns (via an argument) a pointer to the\narray of `intmax_t` variables that will contain the combination.\n\n### Advancing \u0026 reset\nIn order to advance to the next combination, use the `m_intcombo_next`\nfunction. Upon reaching the last combination, the function returns an\nappropriate value. All further calls to the `m_intcombo_next` function\nwill not advance the combination. In order to reset the internal state,\nuse the `m_intcombo_reset` function.\n\n### Resource freeing\nAfter being finished with the combination, call the `m_intcombo_free` to\nfree the internal resources held by the internal data structures.\n\n## Example\nThe following example reads the command line arguments in a form of\n`L..H`, where L is the lower and H is the higher bound of the internal.\nThe example program prints all possible combinations that arise from the\nspecified source sets.\n\n```c\n#include \u003cstdlib.h\u003e\n#include \u003cstdio.h\u003e\n#include \u003cm_intcombo.h\u003e\n\nint\nmain(int argc, char** argv)\n{\n  int i;\n  int ret;\n  struct m_intcombo ic;\n  char* err_str;\n  intmax_t* next;\n  intmax_t lo;\n  intmax_t hi;\n\n  m_intcombo_init(\u0026ic);\n\n  for (i = 1; i \u003c argc; i++) {\n    sscanf(argv[i], \"%lld..%lld\", \u0026lo, \u0026hi);\n    m_intcombo_add(\u0026ic, lo, hi);\n  }\n\n  m_intcombo_finalize(\u0026ic, \u0026next);\n\n  while ((ret = m_intcombo_next(\u0026ic)) == M_INTCOMBO_OK) {\n    for (i = 0; i \u003c (argc-1); i++)\n      printf(\"%lld \", next[i]);\n    printf(\"\\n\");\n  }\n\n  m_intcombo_free(\u0026ic);\n\n  if (ret != M_INTCOMBO_END) {\n    m_intcombo_error_string(ret, \u0026err_str);\n    fprintf(stderr, \"ERROR: %s\\n\", err_str);\n    return EXIT_FAILURE;\n  }\n\n  return EXIT_SUCCESS;\n}\n```\n\nCompile \u0026 run:\n```sh\n$ clang -o example example.c -lmintcombo\n$ ./example 0..1 0..1 0..1\n0 0 0 \n1 0 0 \n0 1 0 \n1 1 0 \n0 0 1 \n1 0 1 \n0 1 1 \n1 1 1 \n```\n\n## Supported platforms\n * FreeBSD 10.0 with Clang 3.3\n\nIf a platform does not appear to be in the previous list, it does not\nmean that `m_set` will not work in such environment. It only means that\nnobody tested it - you are encouraged to do so and report either success\nor failure.\n\n## Build \u0026 install\n```\n$ ninja\n$ sudo ./install.sh\n```\n\n## License\n2-clause BSD license. For more information please consult the\n[LICENSE](LICENSE.md) file. In the case that you need a different license,\nfeel free to contact me.\n\n## Author\nDaniel Lovasko (daniel.lovasko@gmail.com)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasko%2Fm_int_combo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovasko%2Fm_int_combo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasko%2Fm_int_combo/lists"}