1#exe {
2--name hash_map
3-Mroot=main.zig
4#}
5
6#write main.zig {
7const std = @import("std");
8const Context = struct {
9 pub fn hash(_: Context, key: u32) Map.Hash {
10 return key;
11 }
12 pub fn eql(_: Context, lhs: u32, rhs: u32) bool {
13 return lhs == rhs;
14 }
15};
16const Map = std.HashMapUnmanaged(u32, u32, Context, 63);
17fn testHashMap(map: Map) void {
18 _ = map;
19}
20pub fn main() !void {
21 var map: Map = .empty;
22 defer map.deinit(std.heap.page_allocator);
23 try map.ensureTotalCapacity(std.heap.page_allocator, 10);
24 map.putAssumeCapacity(0, 1);
25 map.putAssumeCapacity(2, 3);
26 map.putAssumeCapacity(4, 5);
27 map.putAssumeCapacity(6, 7);
28 map.putAssumeCapacity(8, 9);
29
30 testHashMap(map);
31}
32#}
33#update
34#check lldb {
35(lldb) breakpoint set --file main.zig --source-pattern-regexp '_ = map;'
36Breakpoint 1: where = hash_map`main.testHashMap + #... at main.zig:13:1, address = 0x#...
37(lldb) process launch
38Process #... launched: '#.../hash_map' (#...)
39Process #... stopped
40* thread #1, name = 'hash_map', stop reason = breakpoint 1.1
41 frame #0: hash_map`main.testHashMap(map=len=5 capacity=16) at main.zig:13:1
42(lldb) frame variable --show-all-children --show-types -- map
43(std.hash_map.Custom(u32,u32,main.Context,63)) map = len=5 capacity=16 {
44 (std.hash_map.Custom(u32,u32,main.Context,63).KV) [0] = {
45 (u32) .key = 0
46 (u32) .value = 1
47 }
48 (std.hash_map.Custom(u32,u32,main.Context,63).KV) [1] = {
49 (u32) .key = 2
50 (u32) .value = 3
51 }
52 (std.hash_map.Custom(u32,u32,main.Context,63).KV) [2] = {
53 (u32) .key = 4
54 (u32) .value = 5
55 }
56 (std.hash_map.Custom(u32,u32,main.Context,63).KV) [3] = {
57 (u32) .key = 6
58 (u32) .value = 7
59 }
60 (std.hash_map.Custom(u32,u32,main.Context,63).KV) [4] = {
61 (u32) .key = 8
62 (u32) .value = 9
63 }
64}
65(lldb) breakpoint delete --force 1
661 breakpoints deleted; 0 breakpoint locations disabled.
67#}