https://github.com/jafagervik/zdsa
Data structures in zig
https://github.com/jafagervik/zdsa
dsa zig zig-package
Last synced: about 1 year ago
JSON representation
Data structures in zig
- Host: GitHub
- URL: https://github.com/jafagervik/zdsa
- Owner: Jafagervik
- License: mit
- Created: 2025-01-29T19:25:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-02T15:48:47.000Z (over 1 year ago)
- Last Synced: 2025-02-06T12:19:16.709Z (over 1 year ago)
- Topics: dsa, zig, zig-package
- Language: Zig
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ZDSA - Zig Data structures and algorithms
## Goal
To create a simple collection of DSAs for further use
All should be generic
## Usage
```zig
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
## Road to 1.0
- [x] Stack
- [x] Queue
- [ ] Priority Queue
- [x] Dequeue
- [x] Singly Linked List
- [x] LRU Cache
- [x] Doubly Linked List
- [ ] Binary Tree
## Install (Per 0.14 beta)
Run this command in the parent directory of your project
```sh
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)
```zig
const zdsa = b.dependency("zdsa", .{});
exe.root_module.addImport("zdsa", zdsa.module("zdsa"));
```