{"id":10116043,"url":"https://github.com/jakubgiesler/VecZig","last_synced_at":"2025-09-03T03:31:53.460Z","repository":{"id":156711946,"uuid":"633065215","full_name":"jakubgiesler/VecZig","owner":"jakubgiesler","description":"Vector implementation in Zig","archived":true,"fork":false,"pushed_at":"2023-05-04T22:13:56.000Z","size":31,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-06T16:16:53.102Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Zig","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/jakubgiesler.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.txt","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}},"created_at":"2023-04-26T17:50:52.000Z","updated_at":"2024-07-27T17:56:55.000Z","dependencies_parsed_at":"2024-02-24T21:46:28.160Z","dependency_job_id":null,"html_url":"https://github.com/jakubgiesler/VecZig","commit_stats":null,"previous_names":["0x79616b7562/veczig","jakubgiesler/veczig"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubgiesler%2FVecZig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubgiesler%2FVecZig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubgiesler%2FVecZig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubgiesler%2FVecZig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakubgiesler","download_url":"https://codeload.github.com/jakubgiesler/VecZig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231833391,"owners_count":18433410,"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-05-23T04:15:14.794Z","updated_at":"2024-12-30T08:30:33.867Z","avatar_url":"https://github.com/jakubgiesler.png","language":"Zig","funding_links":[],"categories":["Language Essentials"],"sub_categories":["Data Structure and Algorithm"],"readme":"# VecZig\nZig implementation of Vectors.\n###### Used Zig version v0.10.1\n###### Library version 0.2.1\n```markdown\n\u003e About\n```\n - Storing any Zig and C variables inside Vec including Structs, Unions and Enums on heap\n - Super simple iteration \n - Automatic memory allocations, reallocations\n - Uses `c allocator` by default, no need to pass allocator\n  ```markdown\n\u003e Note\n```\nThis library is not meant to be a replacement for ArrayList in STD, but rather an alternative.\nAlso, this library is young (see lib version above) and not meant to be in production yet.\n## Usage example\n```zig\n// build.zig\nexe.linkLibC();\nexe.addPackage(std.build.Pkg { .name = \"vec\", .source = .{ .path = \"path_to_pkg/VecZig/src/main.zig\" } });\n```\n- Then you can anywhere use\n```zig\n// main.zig\nconst Vec = @import(\"vec\").Vec;\n\nfn main() !void {\n\tvar vec = Vec.new();\n\tdefer vec.delete();\n\t// ...\n}\n```\n## Docs?\n\n#### Creating new Vec examples\n\n```zig\nvar vector0 = Vec(type).init();\nvar vector1 = Vec(i32).init();\n\n// or can be initalized with\nvar vector2 = Vec(f32).new();\n\nconst MY_STRUCT = struct {\n\tdata: i32,\n};\n\nvar vector3 = Vec(MY_STRUCT).new();\n```\n#### Freeing Vec\n```zig\ndefer vec0.deinit();\n\n// or can be freed with\ndefer vec1.delete();\n```\n#### Pushing new elements\n```zig\ntry vector1.push(1);\ntry vector3.push(MY_STRUCT { .data = 13, });\n```\n#### Push same value n times\n```zig\n// n times --------------\\\n// value ------------\\   |\n//                   |   |\ntry vector1.populate(10, 10);\n```\n#### Print entire content of Vec into Terminal\n```zig\nvector1.debug_print();\n```\n#### Iterate through elements\n```zig\nfor (try  vec.iterate()) |element| {\n\tprint(\"{}\", .{ element });\n}\n\n// or by pointer which you can edit\nfor (try  vec.iterate()) |*element| {\n\telement.* += 1;\n\t\n\tprint(\"{}\", .{ element });\n}\n```\n#### Getting length of Vec\n```zig\nvar length = vector1.len;\n```\n#### Check if Vec is empty with\n```zig\nif (vector1.is_empty()) {\n\tprint(\"Yes its empty\", .{});\n}\n```\n#### Removing last element\n```zig\ntry vector1.pop();\n```\n#### Removing element by index\n```zig\ntry vector1.remove(3);\n```\n#### Edit value by index\n```zig\n// new value -------\\\n// index -------\\   |\n//              |   |\ntry vector1.set(10, 100);\n```\n#### Getting value by index\n```zig\ntry vector1.get(10);\n```\n#### Getting pointer to value by index\n```zig\ntry vector1.get_ptr(10);\n```\n#### Clearing entire array\n```zig\nvector1.clear();\n```\n#### Checking if Vec contains value\n```zig\nvar result = vector1.contains(13);\n```\n#### Pushing slices\n```zig\ntry vector1.insert(\u0026[_] i32 { 1, 2, 3, 4, 5 });\n```\n#### Concat another arrays with same type\n```zig\ntry vector1.append(another_vector);\n```\n#### Reversing order \n```zig\ntry vector1.reverse();\n```\n#### Truncate -\u003e shortens the vector\n```zig\ntry vector1.truncate(5);\n```\n#### Drain -\u003e Removes range from array and returns it as slice\n```zig\nvar slice = try vector1.drain(5, 7);\n```\n#### Swaping values by indexes\n```zig\ntry vector1.swap(0, 3);\n```\n#### Getting slice -\u003e slices are returned as Vec(T)\n```zig\n// end at -------------------\\\n// begin at --------------\\  |\n//                        |  |\nvar slice = vector1.slice(0, 5);\ndefer slice.delete();\n```\n#### Cloning Vec\n```zig\nvar new_vector = vector1.clone();\n```\n#### Getting last / first values\n```zig\nvar first = try vector1.first();\nvar last = try vector1.last();\n```\n#### Getting last / first pointers\n```zig\nvar first = try vector1.first_ptr();\nvar last = try vector1.last_ptr();\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakubgiesler%2FVecZig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakubgiesler%2FVecZig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakubgiesler%2FVecZig/lists"}