diff --git a/README.md b/README.md index f5d7863..c3d5690 100644 --- a/README.md +++ b/README.md @@ -19,15 +19,17 @@ Ziglang-Set: a generic and general-purpose Set implementation for Zig.
# +A set offers a fast way to manipulate data and avoid excessive looping. + 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! -Rationale: It may be common knowledge that a dictionary, map or hashset can be used as a set with a value of `void`. While this is true, there's a lot to think about in terms of supporting all the common set operations in a performant and correct way and there's no good reason why a common module for this shouldn't exist. After studying the Zig stdlib, I'm hoping this implementation can fill that gap and provide some value. +Rationale: It may be common knowledge that a dictionary, map or hashset can be used as a set with a value of `void`. While this is true, there's a lot to think about in terms of supporting all the common set operations in a performant and correct way and there's no good reason why a common module for this shouldn't exist. I'm hoping this implementation can fill that gap and provide some value after being modeled similar to other collections in Zig's stdlib. # -This module offers a Set implementation built in the same vein and spirit of the other data structures within the Zig standard library. This is my attempt to model one that can get better over time and grow with community interest and support. See a problem, file a bug! Or better yet contribute and let's build the best implementation together. +This module offers a Set implementation built in the same vein and spirit of the other data structures within the Zig standard library. This is an attempt to model one that can get better over time and grow with community interest and support. See a problem, file a bug! Or better yet contribute and let's build the best implementation together. -I am the original author of the popular Go based set package: [golang-set](https://github.com/deckarep/golang-set) that is used by software components built by Docker, 1Password, Ethereum, SendGrid, CrowdStrike and HashiCorp. At just shy of `4.5k stars`, I figured I'd take a crack at building a comprehensive and generic Zig-based set that goes above and beyond the original Go implementation. After using Zig for over 3+ years on personal projects, I thought it was time that Zig had a robust Set implementation for itself. +I am the original author of a popular Go based set package: [golang-set](https://github.com/deckarep/golang-set) that is used by software components built by Docker, 1Password, Ethereum, SendGrid, CrowdStrike and HashiCorp. At just shy of `4.7k stars`, I figured I'd take a crack at building a comprehensive and generic Zig-based set that goes above and beyond the original Go implementation. After using Zig for over 3+ years on personal projects, I thought it was time that Zig had a robust Set implementation for itself. This implementation gives credit and acknowledgement to the [Zig language](https://ziglang.org) and powerful [Std Library](https://ziglang.org/documentation/master/std/#std) [HashMap](https://ziglang.org/documentation/master/std/#std.hash_map.HashMap) data structure of which this set implementation is built on top of. Without that, this probably wouldn't exist. Efforts will be made to keep the Ziglang Set code fast and straightforward but this Set's raw speed will largely be bounded by the performance of the Zig HashMap of which it is built on top of. @@ -38,11 +40,7 @@ This implementation gives credit and acknowledgement to the [Zig language](https * A few flavors to choose from * NOTE: Future versions of Zig [will be deprecating the `managed` variants](https://ziglang.org/download/0.14.0/release-notes.html#Embracing-Unmanaged-Style-Containers), and this repo will be following suit. * Hash-based: everyday usecase, optimized for lookups primarily, insertion/removal secondarily - [further reading](https://devlog.hexops.com/2022/zig-hashmaps-explained/) - * HashSetManaged - initializes with an allocator and holds it internally (built on top of unmanaged) - * HashSetUnmanaged - does not hold an allocator, smaller footprint * Array-based: more specialized, iteration much faster, insertion order preserved, indexing into underylying data - [further reading](https://devlog.hexops.com/2022/zig-hashmaps-explained/) - * ArrayHashSetManaged - initializes with an allocator and holds it internally (built on top of unmanaged) - * ArrayHashSetUnmanaged - does not hold an allocator, smaller footprint * Common set operations * add, append, appendSlice * remove, removeAll @@ -64,10 +62,9 @@ This implementation gives credit and acknowledgement to the [Zig language](https * Custom hash function support * "string" support * Benchmarks + # -#### Why use a set? - * A set offers a fast way to manipulate data and avoid excessive looping. Look into it as there is already tons of literature on the advantages of having a set in your arsenal of tools. -# + #### Example ```zig // import the namespace. @@ -220,7 +217,7 @@ zig build test ```sh # With Zig installed: -zigup build docs && cp -a zig-out/docs/. docs/ +zig build docs && cp -a zig-out/docs/. docs/ # Alternatively, using Zigup: zigup run build docs && cp -a zig-out/docs/. docs/ diff --git a/build.zig.zon b/build.zig.zon index 66a3e9f..26e0a5a 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,8 +1,8 @@ .{ .name = .ziglangSet, - .version = "0.0.1", + .version = "0.1.0", .fingerprint = 0x65aa5acd2ef4855, - .minimum_zig_version = "0.15.1", + .minimum_zig_version = "0.16.0", .dependencies = .{}, @@ -10,10 +10,8 @@ "LICENSE", "build.zig", "build.zig.zon", - "src/array_hash_set/managed.zig", - "src/array_hash_set/unmanaged.zig", - "src/hash_set/managed.zig", - "src/hash_set/unmanaged.zig", + "src/hash_set.zig", + "src/array_hash_set.zig", "src/root.zig", }, } diff --git a/docs/index.html b/docs/index.html index e60a3f9..75c0daf 100644 --- a/docs/index.html +++ b/docs/index.html @@ -40,6 +40,15 @@ code a { color: #000000; } + .source-code { + display: grid; + grid-template-columns: auto 1fr; + align-items: start; + } + .source-line-numbers pre { + text-align: right; + color: #666; + } #listFields > div, #listParams > div { margin-bottom: 1em; } @@ -429,7 +438,14 @@

Example Usage