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. Public Function

getIndex

Public Function
std.static_string_map.StaticStringMapWithEql.getIndex
pub fn getIndex(self: Self, str: []const u8) ?usize

Returns the index corresponding to the str within the generated kvs, or null if str was not found. The returned index is unrelated to the input kvs_list.

Params

  • self: Self
  • str: []const u8

File

static_string_map.zig:247
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
        pub fn getIndex(self: Self, str: []const u8) ?usize {
            const kvs = self.kvs.*;
            if (kvs.len == 0)
                return null;

            if (str.len < self.min_len or str.len > self.max_len)
                return null;

            var i = self.len_indexes[str.len];
            while (true) {
                const key = kvs.keys[i];
                if (key.len != str.len)
                    return null;
                if (eql(key, str))
                    return i;
                i += 1;
                if (i >= kvs.len)
                    return null;
            }
        }