Skip to content

Commit

Permalink
SetUnmanaged variant - the managed one, will eventually be based on t…
Browse files Browse the repository at this point in the history
…his one (#10)

* Starting to stub out unmanaged root Set object

* Continuing to flesh out an unmanaged variant of the Set datastructure

* stubbing out tests for the SetUnmanaged variant

* Updating README.md in preparation for the Unmanaged variant

* adding some docs

* Adding button for api

* additional test for clone

* adding tests for in-place

* adding comprehensive unit test

* Adding a sizeOf matches test

* Phew, lots of code, now the managed Set type

* Adding sizeOf test for Managed Set

* Simplfying the entire package structure

* Updating docs, simplifying the src/set.zig file
  • Loading branch information
deckarep authored May 15, 2024
1 parent 1db312a commit 64d589d
Show file tree
Hide file tree
Showing 14 changed files with 4,453 additions and 847 deletions.
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

0 comments on commit 64d589d

Please sign in to comment.