Jafagervik/zdsa
Data structures in zig
To create a simple collection of DSAs for further use All should be generic
const std = @import("std");
const zdsa = @import("zdsa");
const Stack = zdsa.Stack;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var stack = Stack(i32).init(allocator);
defer stack.deinit();
try stack.push(1);
try stack.push(2);
try stack.push(3);
const popped = try stack.pop();
stack.clear();
}
For more, see tests or example folders
Stack
Queue
Priority Queue
Dequeue
Singly Linked List
LRU Cache
Doubly Linked List
Binary Tree
Run this command in the parent directory of your project
zig fetch --save https://github.com/Jafagervik/zdsa/tarball/v0.6.0
Or alternatively use master or another version
Then add these lines to build.zig before b.installArtifact(exe)
const zdsa = b.dependency("zdsa", .{});
exe.root_module.addImport("zdsa", zdsa.module("zdsa"));