From b961f0bf62f8916294f72e5b18fd121ceb15c101 Mon Sep 17 00:00:00 2001 From: Ralph Caraveo Date: Wed, 22 Apr 2026 11:37:50 -0700 Subject: [PATCH 1/4] fixes for Zig 0.16.0 --- build.zig.zon | 11 +++++------ src/array_hash_set.zig | 10 +++++----- src/hash_set.zig | 16 ++++++++-------- src/main.zig | 23 +++++++++++++++++++++-- src/root.zig | 4 +--- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 66a3e9f..ffbf38e 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,9 @@ "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/main.zig", "src/root.zig", }, } diff --git a/src/array_hash_set.zig b/src/array_hash_set.zig index 17330c2..59bc4b7 100644 --- a/src/array_hash_set.zig +++ b/src/array_hash_set.zig @@ -1,6 +1,6 @@ /// Open Source Initiative OSI - The MIT License (MIT):Licensing /// The MIT License (MIT) -/// Copyright (c) 2025 Ralph Caraveo (deckarep@gmail.com) +/// Copyright (c) 2026 Ralph Caraveo (deckarep@gmail.com) /// Permission is hereby granted, free of charge, to any person obtaining a copy of /// this software and associated documentation files (the "Software"), to deal in /// the Software without restriction, including without limitation the rights to @@ -69,11 +69,11 @@ pub fn ArraySet(comptime E: type) type { }; const Self = @This(); - + pub const empty: Self = .{ .unmanaged = Map{}, }; - + // pub fn init() Self { // return .{ // .unmanaged = Map{}, @@ -86,7 +86,7 @@ pub fn ArraySet(comptime E: type) type { return self; } - /// TODO: zig has still not changed neither of the two maps from selectMap 0.16, + /// TODO: zig has still not changed neither of the two maps from selectMap 0.16, /// so we need to pass the allocator to deinit that. pub fn deinit(self: *Self, allocator: Allocator) void { self.unmanaged.deinit(allocator); @@ -827,6 +827,6 @@ test "removals" { test "sizeOf matches" { // No bloat guarantee, after all we're just building on top of what's good. const expectedByteSize = 40; - try expectEqual(expectedByteSize, @sizeOf(std.array_hash_map.AutoArrayHashMapUnmanaged(u32, void))); + try expectEqual(expectedByteSize, @sizeOf(std.AutoArrayHashMapUnmanaged(u32, void))); try expectEqual(expectedByteSize, @sizeOf(ArraySet(u32))); } diff --git a/src/hash_set.zig b/src/hash_set.zig index e26fad6..435651e 100644 --- a/src/hash_set.zig +++ b/src/hash_set.zig @@ -1,6 +1,6 @@ /// Open Source Initiative OSI - The MIT License (MIT):Licensing /// The MIT License (MIT) -/// Copyright (c) 2025 Ralph Caraveo (deckarep@gmail.com) +/// Copyright (c) 2026 Ralph Caraveo (deckarep@gmail.com) /// Permission is hereby granted, free of charge, to any person obtaining a copy of /// this software and associated documentation files (the "Software"), to deal in /// the Software without restriction, including without limitation the rights to @@ -72,7 +72,7 @@ pub fn HashSetWithContext(comptime E: type, comptime Context: type, comptime max pub const Iterator = Map.KeyIterator; const Self = @This(); - + pub const empty: Self = if (@sizeOf(Context) == 0) .{ .unmanaged = Map{}, .context = if (Context == void) {} else undefined, @@ -105,7 +105,7 @@ pub fn HashSetWithContext(comptime E: type, comptime Context: type, comptime max } /// Destroys the unmanaged Set. - /// TODO: zig has still not changed the HashMap in 0.16, so we need to pass + /// TODO: zig has still not changed the HashMap in 0.16, so we need to pass /// the allocator here. It needs to be removed. pub fn deinit(self: *Self, allocator: Allocator) void { self.unmanaged.deinit(allocator); @@ -251,10 +251,10 @@ pub fn HashSetWithContext(comptime E: type, comptime Context: type, comptime max /// and other. This set will contain all elements of this set that are not /// also elements of other. pub fn differenceUpdate(self: *Self, other: Self) Allocator.Error!void { - var iter = other.iterator(); - - while (iter.next()) |key_ptr| { - _ = self.remove(key_ptr.*); + var iter = other.iterator(); + + while (iter.next()) |key_ptr| { + _ = self.remove(key_ptr.*); } } @@ -344,7 +344,7 @@ pub fn HashSetWithContext(comptime E: type, comptime Context: type, comptime max for (to_remove.items) |item| { _ = self.remove(item); - } + } } /// isDisjoint returns true if the intersection between two sets is the null set. diff --git a/src/main.zig b/src/main.zig index 1a4f836..aa02ce6 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,3 +1,23 @@ +/// Open Source Initiative OSI - The MIT License (MIT):Licensing +/// The MIT License (MIT) +/// Copyright (c) 2026 Ralph Caraveo (deckarep@gmail.com) +/// Permission is hereby granted, free of charge, to any person obtaining a copy of +/// this software and associated documentation files (the "Software"), to deal in +/// the Software without restriction, including without limitation the rights to +/// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +/// of the Software, and to permit persons to whom the Software is furnished to do +/// so, subject to the following conditions: +/// The above copyright notice and this permission notice shall be included in all +/// copies or substantial portions of the Software. +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +/// SOFTWARE. +/// +/// const std = @import("std"); const set = @import("root.zig"); @@ -20,12 +40,11 @@ pub fn main(init: std.process.Init) void { // now we can initialize a HashSet with empty if no context is provided var A: HashSet(u32) = .empty; defer A.deinit(gpa); - + var B: ArraySet(u32) = .empty; defer B.deinit(gpa); const ctx = SimpleHasher{}; var C: set.HashSetContext(u32, SimpleHasher, 75) = .initContext(ctx); defer C.deinit(gpa); - } diff --git a/src/root.zig b/src/root.zig index 627c717..2c3b9e5 100644 --- a/src/root.zig +++ b/src/root.zig @@ -1,6 +1,6 @@ /// Open Source Initiative OSI - The MIT License (MIT):Licensing /// The MIT License (MIT) -/// Copyright (c) 2025 Ralph Caraveo (deckarep@gmail.com) +/// Copyright (c) 2026 Ralph Caraveo (deckarep@gmail.com) /// Permission is hereby granted, free of charge, to any person obtaining a copy of /// this software and associated documentation files (the "Software"), to deal in /// the Software without restriction, including without limitation the rights to @@ -18,7 +18,6 @@ /// SOFTWARE. /// /// - /// Set is just a short convenient "default" alias. If you don't know /// which to pick, just use Set. pub const Set = HashSet; @@ -30,7 +29,6 @@ pub const HashSetContext = @import("hash_set.zig").HashSetWithContext; /// This is a bit more specialized and optimized for heavy iteration. pub const ArraySet = @import("array_hash_set.zig").ArraySet; - test "tests" { _ = @import("hash_set.zig"); _ = @import("array_hash_set.zig"); From bd717594f7aeaca49b54fb3d55a3883449c58ad5 Mon Sep 17 00:00:00 2001 From: Ralph Caraveo Date: Wed, 22 Apr 2026 11:43:06 -0700 Subject: [PATCH 2/4] Regen docs --- docs/index.html | 18 +++++++++++++++++- docs/main.js | 25 ++++++++++++++++++++++--- docs/main.wasm | Bin 200771 -> 204328 bytes docs/sources.tar | Bin 14330368 -> 16891904 bytes 4 files changed, 39 insertions(+), 4 deletions(-) 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