tiny.simd.Cuckoo2x2
Defined in cuckoo2x2.
API (7)
Actions
Public operations.
Fields and members
Public fields and members.
Source
Source: lib/simd/src/cuckoo2x2.zig:59
zig
pub const Cuckoo2x2 = struct { hash1: hash_mod.WeakTwoMul, data: Cuckoo2x2Data, const Self = @This(); pub fn init(data: Cuckoo2x2Data) Self { std.debug.assert(!data.isEmpty()); std.debug.assert(data.numBuckets() >= minimum_bucket_count); return .{ .hash1 = hash_mod.WeakTwoMul.initKey(data.config.hash_key), .data = data, }; } pub fn getData(self: Self) Cuckoo2x2Data { return self.data; } pub fn contains(self: Self, key: u32) bool { const h1 = self.hash1.hash(key); const b1 = h1 & self.data.config.bucket_mask; const fingerprint = h1 >> 18; const b2 = b1 ^ (fingerprint + 1); const primary: u16 = @truncate(fingerprint | 0x4000); const secondary: u16 = @truncate(fingerprint | 0x8000); const e1 = self.data.entries[b1]; const e2 = self.data.entries[b2]; return primary == @as(u16, @truncate(e1)) or primary == @as(u16, @truncate(e1 >> 16)) or secondary == @as(u16, @truncate(e2)) or secondary == @as(u16, @truncate(e2 >> 16)); } pub fn query(self: Self, comptime D: type, keys: D.Vector) D.Mask { requireTag(D); const h1 = self.hash1.oneVec(D, keys); const b1 = h1 & @as(D.Vector, @splat(self.data.config.bucket_mask)); const fingerprint = shift.shiftRight(D, 18, h1); const b2 = b1 ^ (fingerprint +% @as(D.Vector, @splat(1))); const primary = fingerprint | @as(D.Vector, @splat(0x4000)); const secondary = fingerprint | @as(D.Vector, @splat(0x8000)); const e1 = indexed.gatherIndex(D, self.data.entries, b1); const e2 = indexed.gatherIndex(D, self.data.entries, b2); const low_mask: D.Vector = @splat(0xffff); const found = (e1 & low_mask == primary) | (shift.shiftRight(D, 16, e1) == primary) | (e2 & low_mask == secondary) | (shift.shiftRight(D, 16, e2) == secondary); return !found; } pub fn containsVec(self: Self, comptime D: type, keys: D.Vector) D.Mask { return !self.query(D, keys); }};Source: lib/simd/src/root.zig:613
zig
pub const Cuckoo2x2 = cuckoo2x2.Cuckoo2x2;Audit
| Definitions | 6 |
|---|---|
| Public names | 12 |
| Members | 2 |
| Version | 26.7.0 |
| Revision | daab053ee433 |