{"id":13741677,"url":"https://github.com/avdva/zigavl","last_synced_at":"2026-01-16T16:03:39.899Z","repository":{"id":188352449,"uuid":"678580956","full_name":"avdva/zigavl","owner":"avdva","description":"An AVL tree written in Zig","archived":false,"fork":false,"pushed_at":"2024-10-20T23:34:38.000Z","size":44,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-10T11:06:52.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avdva.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":"2023-08-14T22:19:23.000Z","updated_at":"2024-10-25T08:38:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"e3dbca0a-7760-46e7-84e5-333322e00fd3","html_url":"https://github.com/avdva/zigavl","commit_stats":null,"previous_names":["avdva/zigavl"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/avdva/zigavl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avdva%2Fzigavl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avdva%2Fzigavl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avdva%2Fzigavl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avdva%2Fzigavl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avdva","download_url":"https://codeload.github.com/avdva/zigavl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avdva%2Fzigavl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: 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":[],"created_at":"2024-08-03T04:01:01.674Z","updated_at":"2026-01-16T16:03:39.878Z","avatar_url":"https://github.com/avdva.png","language":"Zig","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# zigavl\nA self-balancing binary [AVL](https://en.wikipedia.org/wiki/AVL_tree) tree written in Zig.\n\n# Presentation\nTo use this library, you need at least Zig 0.13.x.\n\n## Badges\n\n![Build Status](https://img.shields.io/github/actions/workflow/status/ultd/base58-zig/test.yml?branch=main)\n\n## API\n```zig\n// create tree type:\npub const Options = struct {\n    countChildren: bool = false,\n};\npub fn TreeWithOptions(comptime K: type, comptime V: type, comptime Cmp: fn (a: K, b: K) math.Order, comptime options: Options) type\npub fn Tree(comptime K: type, comptime V: type, comptime Cmp: fn (a: K, b: K) math.Order) type\n\n// init/deinit:\npub const InitOptions = struct {\n    allowFastDeinit: enum { always, auto, never } = .never,\n};\npub fn init(a: std.mem.Allocator) Self\npub fn initWithOptions(a: std.mem.Allocator, io: InitOptions) Self\npub fn deinit()\n\n// insert:\npub fn insert(self: *Self, k: K, v: V) !InsertResult\npub fn getOrInsert(self: *Self, k: K, v: V) !InsertResult \npub fn getOrEmplace(self: *Self, k: K, ctor: fn (v: *V, args: anytype) void, args: anytype) !InsertResult\n\n// delete:\npub fn delete(self: *Self, k: K) ?V\npub fn deleteIterator(self: *Self, it: Iterator) Iterator\n\n// find:\npub fn getMin(self: *Self) ?Entry\npub fn getMax(self: *Self) ?Entry\npub fn get(self: *Self, k: K) ?*V\n\n// array-style access:\npub fn at(self: *Self, pos: usize) Entry\npub fn deleteAt(self: *Self, pos: usize) KV\n\n// iterate:\npub fn ascendFromStart(self: *Self) Iterator\npub fn ascendAt(self: *Self, pos: usize) Iterator\npub fn descendFromEnd(self: *Self) Iterator\n\n```\n\nExample:\n```zig\n\nconst std = @import(\"std\");\nconst math = std.math;\nconst zigavl = @import(\"zigavl\");\n\nfn i64Cmp(a: i64, b: i64) math.Order {\n    return math.order(a, b);\n}\n\npub fn main() !void {\n    var gpa = std.heap.GeneralPurposeAllocator(.{}){};\n    defer _ = gpa.detectLeaks();\n    // first, create an i64--\u003ei64 tree\n    const TreeType = zigavl.TreeWithOptions(i64, i64, i64Cmp, .{ .countChildren = true });\n    var t = TreeType.init(gpa.allocator());\n    defer t.deinit();\n    // add some elements\n    var i: i64 = 10;\n    while (i \u003e= 0) {\n        _ = try t.insert(i, i);\n        i -= 1;\n    }\n    // get min and max\n    if (t.getMin().?.k != 0) {\n        @panic(\"bad min\");\n    }\n    if (t.getMax().?.k != 10) {\n        @panic(\"bad max\");\n    }\n    // get an element by it's key\n    if (t.get(5).?.* != 5) {\n        @panic(\"invalid get result\");\n    }\n    // iterate\n    var it = t.ascendFromStart();\n    i = 0;\n    while (it.value()) |e| {\n        if (e.k != i) {\n            @panic(\"invalid key\");\n        }\n        if (e.v.* != i) {\n            @panic(\"invalid value\");\n        }\n        i += 1;\n        it.next();\n    }\n    //delete iterator\n    var second_it = t.deleteIterator(t.ascendFromStart());\n    if (second_it.value().?.k != 1 or second_it.value().?.v.* != 1) {\n        @panic(\"invalid deleteIterator result\");\n    }\n    // delete by key\n    if (t.delete(1).? != 1) {\n        @panic(\"invalid delete result\");\n    }\n    // delete by position\n    const kv = t.deleteAt(0);\n    if (kv.Key != 2 or kv.Value != 2) {\n        @panic(\"invalid deleteAt result\");\n    }\n\n    // ascend from pos.\n    it = t.ascendAt(3);\n    if (it.value()) |val| {\n        if (val.k != 6) {\n            @panic(\"invalid key\");\n        }\n    } else {\n        @panic(\"invalid iterator\");\n    }\n}\n\n```\n\n## Contact\n\n[Aleksandr Demakin](mailto:alexander.demakin@gmail.com)\n\n## License\n\nSource code is available under the [Apache License Version 2.0](/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favdva%2Fzigavl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favdva%2Fzigavl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favdva%2Fzigavl/lists"}