You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ziglang-Set: a generic and general-purpose Set implementation for Zig. <br/> 🚧 PRE-ALPHA 🚧
6
+
Ziglang-Set: a generic and general-purpose Set implementation for Zig. <br/> 🚧 BETA 🚧
7
7
</p>
8
8
9
9
#
@@ -21,21 +21,22 @@ Ziglang-Set: a generic and general-purpose Set implementation for Zig. <br/>
21
21
22
22
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!
23
23
24
-
Rationale: It may be common knowledge that a dictionary or map or hashset can be used as a set where the value is basically 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 can't exist. After studying the Zig stdlib, I'm hoping this implementation can fill that gap and provide some value.
24
+
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.
25
25
26
26
#
27
27
28
28
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.
29
29
30
-
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 `4k 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 2.5 years on personal projects, I thought it was time that Zig had a robust Set implementation for itself.
30
+
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.
31
31
32
32
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.
33
33
34
34
#
35
35
36
36
#### Features
37
-
* Offers idiomatic, generic-based Zig API - allocators, iterators, capacity hints, clearing, resizing, etc.
37
+
* Offers idiomatic, generic-based Zig API - allocator support, iterators, capacity hints, clearing, resizing, etc.
38
38
* A few flavors to choose from
39
+
* NOTE: Future versions of Zig will be deprecating the `managed` variants, and this repo will be following suit.
* HashSetManaged - initializes with an allocator and holds it internally (built on top of unmanaged)
41
42
* HashSetUnmanaged - does not hold an allocator, smaller footprint
@@ -57,11 +58,11 @@ This implementation gives credit and acknowledgement to the [Zig language](https
57
58
* isProperSubset
58
59
* isProperSuperset
59
60
* pop
60
-
* Fully documented and robustly tested - in progress
61
+
* Fully documented and robustly tested
61
62
* Performance aware to minimize unecessary allocs/iteration internally
62
63
* Custom hash function support
63
-
* "string" support - coming soon
64
-
* Benchmarks - coming soon
64
+
* "string" support
65
+
* Benchmarks
65
66
#
66
67
#### Why use a set?
67
68
* 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.
@@ -213,3 +214,13 @@ Check the tests for more comprehensive examples on how to use this package.
213
214
```sh
214
215
zig build test
215
216
```
217
+
218
+
#### Docs Generation
219
+
220
+
```sh
221
+
# With Zig installed:
222
+
zig build-lib -femit-docs src/root.zig
223
+
224
+
# Alternatively, using Zigup:
225
+
zigup run {zig-version} build-lib -femit-docs src/root.zig
0 commit comments