Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetUnmanaged variant - the managed one, will eventually be based on this one #10

Merged
merged 14 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Ziglang-Set: a generic and general-purpose Set implementation for Zig. <br/>
<img src="assets/ZigSetGraphic.png" width="512"/>
</p>

#
<p align="center">
<a href="https://deckarep.github.io/ziglang-set/"><img src="https://img.shields.io/badge/api-reference-blue.svg?style=flat-square" alt="API Reference"></a>
</p>

#

Zig currently [does not have](https://github.com/ziglang/zig/issues/6919) a built-in, general purpose Set data structure at this point in time. Until it does, try this!
Expand All @@ -30,6 +35,9 @@ This implementation gives credit and acknowledgement to the [Zig language](https

#### Features
* Offers idiomatic, generic-based Zig API - allocators, iterators, capacity hints, clearing, resizing, etc.
* A few flavors to choose from
* SetManaged - initializes with an allocator and holds it internally (built on top of unmanaged)
* SetUnmanaged - does not hold an allocator, optimized when storing many Sets
* Common set operations
* add, append, appendSlice
* remove, removeAll
Expand Down
21 changes: 19 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});

_ = b.addModule("ziglangSet", .{
.root_source_file = .{.path = "src/set.zig"},
.root_source_file = .{ .path = "src/set.zig" },
});

const main_tests = b.addTest(.{
Expand All @@ -20,4 +20,21 @@ pub fn build(b: *std.Build) void {

const test_step = b.step("test", "Run library tests");
test_step.dependOn(&run_main_tests.step);
}

// Below is for docs generation.
const lib = b.addObject(.{
.name = "ziglang-set",
.root_source_file = b.path("src/set.zig"),
.target = target,
.optimize = optimize,
});

const my_docs = lib;
const build_docs = b.addInstallDirectory(.{
.source_dir = my_docs.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs",
});
const build_docs_step = b.step("docs", "Build the library docs");
build_docs_step.dependOn(&build_docs.step);
}
2 changes: 2 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"LICENSE",
"build.zig",
"build.zig.zon",
"src/managed.zig",
"src/set.zig",
"src/unmanaged.zig",
},
}
Loading