{"id":23617172,"url":"https://github.com/marcos-venicius/clibs","last_synced_at":"2025-11-06T15:30:27.507Z","repository":{"id":269620191,"uuid":"908011246","full_name":"marcos-venicius/clibs","owner":"marcos-venicius","description":"Usefull libraries in C based on my needs.","archived":false,"fork":false,"pushed_at":"2025-01-17T00:06:47.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T01:22:11.700Z","etag":null,"topics":["array","assert","c","clib","clibrary","hash-map","linked-list"],"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/marcos-venicius.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-12-24T21:31:11.000Z","updated_at":"2025-01-17T00:06:00.000Z","dependencies_parsed_at":"2024-12-24T22:22:32.771Z","dependency_job_id":"134fe5d1-4ff0-4d12-aba4-8f964ae0ac5a","html_url":"https://github.com/marcos-venicius/clibs","commit_stats":null,"previous_names":["marcos-venicius/clibs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcos-venicius%2Fclibs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcos-venicius%2Fclibs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcos-venicius%2Fclibs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcos-venicius%2Fclibs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcos-venicius","download_url":"https://codeload.github.com/marcos-venicius/clibs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239494994,"owners_count":19648247,"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":["array","assert","c","clib","clibrary","hash-map","linked-list"],"created_at":"2024-12-27T18:17:51.068Z","updated_at":"2025-11-06T15:30:27.434Z","avatar_url":"https://github.com/marcos-venicius.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLIBS\n\n_**Usefull libraries in C** based on my needs_.\n\n## LL\n\nExtends for (Linked List).\n\nThis DS works like an array.\n\n```c\nLL *ll_new(FreeCallback free_callback, CompareCallback compare_callback);\n```\n\nCreate a new instance of `LL`.\n\n---\n\n```c\nvoid ll_add(LL *ll, void *data, size_t data_size);\n```\n\nAdd any data of any size to the linked list (ideally a Linked List should have only one data type).\n\nTo add a `LL*` as value you can just do something like this:\n\n```c\n    ...\n\n    LL *positions = ll_new((FreeCallback)ll_free, NULL);\n\n    ...\n\n    LL *row = ll_new(NULL, NULL);\n\n    ll_add_i(row, 10);\n\n    ll_add(positions, row, 0); // it's important the size being 0\n\n    ll_free(positions);\n```\n\nYou don't need to free the row, the parent list will do this job for you!\n\n---\n\n```c\nbool int_compare(void *a, void *b);\n```\n\nA built-in int comparer.\n\n---\n\n```c\nbool string_compare(void *a, void *b);\n```\n\nA built-in string comparer.\n\n---\n\n```c\nvoid ll_add_i(LL *ll, int i);\n```\n\nMake the process of adding an integer to the list easy.\n\n---\n\n```c\nvoid ll_add_s(LL *ll, char *s);\n```\n\nMake the process of adding a string to the list easy.\n\n---\n\n```c\nvoid ll_remove_by_value(LL *ll, void *data);\n```\n\nAllows you to remove the first item that matches the data value you pass as argument.\n\n**It's important to notice that to remove by value you should pass a `CompareCallback` in `ll_new`**.\n\n```c\nvoid ll_remove_by_value_i(LL *ll, int i);\n```\n\nMakes removing an integer easy.\n\n---\n\n```c\nvoid ll_remove_by_index(LL *ll, size_t index);\n```\n\nAllows you to remove a value by index.\n\n---\n\n```c\nvoid *ll_find_by_value(LL *ll, void *data);\n```\n\nAllows you to get an item by your value.\n\n**It's important to notice that to find by value you should pass a `CompareCallback` in `ll_new`**.\n\n---\n\n```c\nvoid *ll_find_by_index(LL *ll, size_t index);\n```\n\nAllows you to get an item by your index.\n\n---\n\n```c\nLLIter ll_iter(LL *ll);\n```\n\nCreate a new iterator to allow you easely iterate over your list.\n\nExample:\n\n```c\n    LL *list = ll_new(NULL, NULL);\n\n    LLIter iter = ll_iter(list);\n\n    while (ll_iter_has(\u0026iter)) {\n        LLIterItem item = ll_iter_consume(\u0026iter);\n\n        printf(\"%ld\\n\", item.index);\n    }\n\n    ll_iter_flush(\u0026iter);\n```\n\n---\n\n```c\nbool ll_iter_has(LLIter *iter);\n```\n\nCheck if the iterator is not empty.\n\n---\n\n```c\nLLIterItem ll_iter_consume(LLIter *iter);\n```\n\nConsumes the current item of the iterator.\n\n---\n\n```c\nvoid ll_iter_flush(LLIter *iter);\n```\n\nAllows your to restore the state of the iterator to be able to iterate again.\n\nIf you don't call this function before using it again, it'll crash your program with a message.\n\n**You need to call this flush after all modifications in the list** if you don't do this, it's possible to get wrong addresses after removing it.\n\n---\n\n```c\nvoid ll_free(LL *ll);\n```\n\nFree the instance.\n\n## Map\n\n**WIP**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcos-venicius%2Fclibs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcos-venicius%2Fclibs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcos-venicius%2Fclibs/lists"}