Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Function

insertEntryIntoNewHeaderGeneric

Private Function
std.array_hash_map.ArrayHashMap.insertEntryIntoNewHeaderGeneric
fn insertEntryIntoNewHeaderGeneric(header: *IndexHeader, h: u32, i: usize, comptime I: type) void

Params

File

array_hash_map.zig:1444
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
        fn insertEntryIntoNewHeaderGeneric(header: *IndexHeader, h: u32, i: usize, comptime I: type) void {
            const indexes = header.indexes(I);
            const start_index = safeTruncate(usize, h);
            const end_index = start_index +% indexes.len;
            var index = start_index;
            var entry_index: I = @intCast(i);
            var distance_from_start_index: I = 0;
            while (index != end_index) : ({
                index +%= 1;
                distance_from_start_index += 1;
            }) {
                const slot = header.constrainIndex(index);
                const next_index = indexes[slot];
                if (next_index.isEmpty()) {
                    indexes[slot] = .{
                        .distance_from_start_index = distance_from_start_index,
                        .entry_index = entry_index,
                    };
                    return;
                }
                if (next_index.distance_from_start_index < distance_from_start_index) {
                    indexes[slot] = .{
                        .distance_from_start_index = distance_from_start_index,
                        .entry_index = entry_index,
                    };
                    distance_from_start_index = next_index.distance_from_start_index;
                    entry_index = next_index.entry_index;
                }
            }
            unreachable;
        }