{"id":16209280,"url":"https://github.com/gilzoide/betterclist","last_synced_at":"2026-01-21T21:32:53.728Z","repository":{"id":70590091,"uuid":"323077794","full_name":"gilzoide/betterclist","owner":"gilzoide","description":"A -betterC compatible dynamic list backed by array for D","archived":false,"fork":false,"pushed_at":"2021-02-06T20:34:55.000Z","size":17,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T20:50:13.245Z","etag":null,"topics":["betterc","data-structures","dlang","meson"],"latest_commit_sha":null,"homepage":"","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gilzoide.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-12-20T13:26:09.000Z","updated_at":"2023-04-24T21:09:27.000Z","dependencies_parsed_at":"2023-04-11T10:30:57.575Z","dependency_job_id":null,"html_url":"https://github.com/gilzoide/betterclist","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/gilzoide/betterclist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fbetterclist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fbetterclist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fbetterclist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fbetterclist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gilzoide","download_url":"https://codeload.github.com/gilzoide/betterclist/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fbetterclist/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28644065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T21:29:11.980Z","status":"ssl_error","status_checked_at":"2026-01-21T21:24:31.872Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["betterc","data-structures","dlang","meson"],"created_at":"2024-10-10T10:29:00.611Z","updated_at":"2026-01-21T21:32:53.712Z","avatar_url":"https://github.com/gilzoide.png","language":"D","funding_links":[],"categories":[],"sub_categories":[],"readme":"# betterclist\nA `-betterC` compatible dynamic list backed by array for [D](https://dlang.org/).\n\nIt is available as a [DUB package](https://code.dlang.org/packages/betterclist)\nand may be used directly as a [Meson subproject](https://mesonbuild.com/Subprojects.html)\nor [wrap](https://mesonbuild.com/Wrap-dependency-system-manual.html).\n\n## Usage\n```d\nimport betterclist : List;\n\n// Lists may be backed by static arrays by passing the capacity to template\nList!(int, 16) list;\nassert(list.capacity == 16);\n\n// Lists track their own element usage\nassert(list.length == 0);\nassert(list.empty);\n\nlist.pushBack(0);  // pushBack inserts an element in the end of the used slice\nassert(list.length == 1);\nassert(list[0] == 0);  // opIndex(size_t) indexes used elements slice, `list[1]` is out of bounds here\nlist[0] = 1;  // assigning to index works, if your List is mutable\n\nlist.push(2, 3);  // push is an alias to pushBack. Several elements may be pushed at once\nassert(list[] == [1, 2, 3]);  // opIndex() returns the used slice\nassert(list.availableCapacity == 13);\n\nlist ~= 4;  // operator ~= also calls pushBack\nassert(list == [1, 2, 3, 4]);  // Lists are aliased to the used slice by `alias this`\nassert(list[2 .. $] == [3, 4]);  // this means stuff like opDollar, slicing and length just works\n// so does foreach\nimport std.stdio : writeln;\nforeach (value; list)\n{\n    writeln(value);\n}\n// so does importing common range stuff\nimport std.range;\nassert(list.front == 1);\nassert(list.back == 4);\n\nlist.popBack();  // pops the last value. If element type has elaborate detructors, reinitializes element to it's `.init` value\nassert(list == [1, 2, 3]);\nlist.popBack(2);  // pops the last N values. The same caveats apply\nassert(list == [1]);\nlist.pop();  // pop is an alias to popBack\nassert(list == null);\nlist.pop(42);  // popping more items than there are is safe\nlist.clear();  // pops all elements from List\nassert(list.empty);\n\nlist.push(iota(16));  // ranges can be pushed at once\nassert(list.full);\nauto result = list.push(1, 2);  // Trying to push more items than capacity permits is an error, but no exception is thrown...\nassert(result == 2);  // ...rather pushBack returns the number of items that were not inserted\nlist.clear();\nresult = list.push(1, 1, 2, 3, 5);\nassert(result == 0);  // if all items were inserted, pushBack returns 0\nresult = list.pushBack(repeat(42));  // if range has no known length and not all elements were inserted...\nassert(result \u003c 0);  // ...pushBack returns a negative value\n\n// Lists can also be backed by a slice\nimport core.stdc.stdlib : malloc, free;\nalias IntList = List!int;\n\nenum bufferSize = 8 * int.sizeof;\nvoid* buffer = malloc(bufferSize);\n\n// Construction using void[]\nauto sliceList = IntList(buffer[0 .. bufferSize]);\nassert(sliceList.capacity == 8);\n\n// Construction using element type slice\nsliceList = IntList(cast(int[]) buffer[0 .. bufferSize]);\nassert(sliceList.capacity == 8);\n\n// Construction using void pointer and explicit buffer size (be careful!)\nsliceList = IntList(buffer, bufferSize);\nassert(sliceList.capacity == 8);\n\n// Construction using element type pointer and explicit capacity (be careful!)\nsliceList = IntList(cast(int*) buffer, 8);\nassert(sliceList.capacity == 8);\n\n// Lists backed by slices do not manage their own memory (TODO: memory mamaged (noGC, but destructor/auto resize) List type)\nfree(buffer);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Fbetterclist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilzoide%2Fbetterclist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Fbetterclist/lists"}