├── src ├── zig-cache │ ├── h │ │ ├── timestamp │ │ ├── d189ab8274c935fb7c53bd865c3eed39.txt │ │ └── 829df49dc636d1c215d8c0da71b4527e.txt │ ├── o │ │ ├── 18d0d3a51bc40b077d4a11778966a5e4 │ │ │ ├── cimport.h │ │ │ └── cimport.h.d │ │ ├── 15b1d201020b38a243d82958aa2c3324 │ │ │ ├── stage1.id │ │ │ ├── main.o │ │ │ └── builtin.zig │ │ └── 4a0013be77b43ed282340ac3afbfb278 │ │ │ └── cimport.zig │ └── z │ │ ├── 2d1fdc4cd88730da39ff42daede6a1cb │ │ ├── 2ef096516a69d4ffce94a1e6fab38b05 │ │ ├── 99482717c76fecd9ebba051805b7c561 │ │ └── b48582bf1489ebd7a506b47059a84ffd ├── main.zig ├── search.zig ├── algo_math.zig ├── sort.zig └── datastructures.zig ├── .gitignore ├── README.md └── LICENSE /src/zig-cache/h/timestamp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/zig-cache/o/18d0d3a51bc40b077d4a11778966a5e4/cimport.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/zig-cache/o/15b1d201020b38a243d82958aa2c3324/stage1.id: -------------------------------------------------------------------------------- 1 | 9a62ba78d6745ca6a944087b8e61a8d920 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | zig-cache/ 2 | zig-out/ 3 | /release/ 4 | /debug/ 5 | /build/ 6 | /build-*/ 7 | /docgen_tmp/ 8 | -------------------------------------------------------------------------------- /src/zig-cache/z/2d1fdc4cd88730da39ff42daede6a1cb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d-mironov/zig-algorithms/HEAD/src/zig-cache/z/2d1fdc4cd88730da39ff42daede6a1cb -------------------------------------------------------------------------------- /src/zig-cache/z/2ef096516a69d4ffce94a1e6fab38b05: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d-mironov/zig-algorithms/HEAD/src/zig-cache/z/2ef096516a69d4ffce94a1e6fab38b05 -------------------------------------------------------------------------------- /src/zig-cache/z/99482717c76fecd9ebba051805b7c561: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d-mironov/zig-algorithms/HEAD/src/zig-cache/z/99482717c76fecd9ebba051805b7c561 -------------------------------------------------------------------------------- /src/zig-cache/z/b48582bf1489ebd7a506b47059a84ffd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d-mironov/zig-algorithms/HEAD/src/zig-cache/z/b48582bf1489ebd7a506b47059a84ffd -------------------------------------------------------------------------------- /src/zig-cache/o/15b1d201020b38a243d82958aa2c3324/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d-mironov/zig-algorithms/HEAD/src/zig-cache/o/15b1d201020b38a243d82958aa2c3324/main.o -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zig Algorithms and Datastructures 2 | 3 | Zig Algorithms and Datastructures repository. 4 | Here you can find many types of algorithms and datastructures. 5 |
6 | Anyone is free to contribute here and is really appreciated if you do so. 7 | 8 | #### Contact 9 | **Discord:** `moonraccoon#1337` 10 | **Mail:** [mail@moonraccoon.sh](mailto:mail@moonraccoon.sh) 11 | -------------------------------------------------------------------------------- /src/main.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const sort = @import("sort.zig"); 3 | const search = @import("search.zig"); 4 | const math = @import("algo_math.zig"); 5 | const print = std.debug.print; 6 | const ds = @import("datastructures.zig"); 7 | const Node = ds.Node; 8 | const Stack = ds.Stack; 9 | const list = ds.list; 10 | 11 | pub fn main() anyerror!void { 12 | var ll1 = list(u32).init(); 13 | 14 | _ = ll1.push_back(1); 15 | _ = ll1.push_back(2); 16 | _ = ll1.push_back(5); 17 | _ = ll1.push_front(10); 18 | ll1.show(); 19 | 20 | _ = ll1.insert(4, 20); 21 | ll1.show(); 22 | _ = ll1.insert(6, 20); 23 | ll1.show(); 24 | 25 | _ = ll1.del(4); 26 | ll1.show(); 27 | _ = ll1.del(4); 28 | ll1.show(); 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Daniel Mironow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/search.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const print = std.debug.print; 3 | 4 | const SearchError = error{ 5 | ElementNotFound, 6 | }; 7 | 8 | /// Binary Search 9 | /// 10 | /// Search a sorted `i32` array for element `n` 11 | /// 12 | /// Parameters: 13 | /// `arr` - Array to search 14 | /// `n` - Element to serach 15 | /// 16 | /// Return: 17 | /// Index of element when found, `ElementNotFound` error if not. 18 | pub fn binary(arr: []i32, n: i32) SearchError!i32 { 19 | var upper: u32 = @intCast(u32, arr.len); 20 | var lower: u32 = 0; 21 | while (upper > lower) { 22 | var mid: u32 = lower + @divTrunc(upper - lower, 2); 23 | if (arr[mid] == n) { 24 | return @intCast(i32, mid); 25 | } 26 | if (arr[mid] > n) { 27 | upper = mid - 1; 28 | } else { 29 | lower = mid + 1; 30 | } 31 | } 32 | return SearchError.ElementNotFound; 33 | } 34 | 35 | /// Linear Search 36 | /// 37 | /// Search an `i32` array for element `n` 38 | /// 39 | /// Parameters: 40 | /// `arr` - Array to search 41 | /// `n` - Element to serach 42 | /// 43 | /// Return: 44 | /// Index of element when found, `ElementNotFound` error if not. 45 | pub fn linear(arr: []i32, n: i32) SearchError!i32 { 46 | for (arr) |e, i| { 47 | if (e == n) { 48 | return @intCast(i32, i); 49 | } 50 | } 51 | return SearchError.ElementNotFound; 52 | } 53 | -------------------------------------------------------------------------------- /src/zig-cache/o/18d0d3a51bc40b077d4a11778966a5e4/cimport.h.d: -------------------------------------------------------------------------------- 1 | cimport.o: src/zig-cache/o/18d0d3a51bc40b077d4a11778966a5e4/cimport.h \ 2 | /usr/lib/zig/libc/include/generic-glibc/time.h \ 3 | /usr/lib/zig/libc/include/generic-glibc/features.h \ 4 | /usr/lib/zig/libc/include/generic-glibc/features-time64.h \ 5 | /usr/lib/zig/libc/include/x86_64-linux-gnu/bits/wordsize.h \ 6 | /usr/lib/zig/libc/include/x86_64-linux-gnu/bits/timesize.h \ 7 | /usr/lib/zig/libc/include/generic-glibc/stdc-predef.h \ 8 | /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h \ 9 | /usr/lib/zig/libc/include/x86_64-linux-gnu/bits/long-double.h \ 10 | /usr/lib/zig/libc/include/x86_64-linux-gnu/gnu/stubs.h \ 11 | /usr/lib/zig/libc/include/x86_64-linux-gnu/gnu/stubs-64.h \ 12 | /usr/lib/zig/include/stddef.h \ 13 | /usr/lib/zig/libc/include/generic-glibc/bits/time.h \ 14 | /usr/lib/zig/libc/include/generic-glibc/bits/types.h \ 15 | /usr/lib/zig/libc/include/x86_64-linux-gnu/bits/typesizes.h \ 16 | /usr/lib/zig/libc/include/generic-glibc/bits/time64.h \ 17 | /usr/lib/zig/libc/include/generic-glibc/bits/types/clock_t.h \ 18 | /usr/lib/zig/libc/include/generic-glibc/bits/types/time_t.h \ 19 | /usr/lib/zig/libc/include/generic-glibc/bits/types/struct_tm.h \ 20 | /usr/lib/zig/libc/include/generic-glibc/bits/types/struct_timespec.h \ 21 | /usr/lib/zig/libc/include/generic-glibc/bits/endian.h \ 22 | /usr/lib/zig/libc/include/x86_64-linux-gnu/bits/endianness.h \ 23 | /usr/lib/zig/libc/include/generic-glibc/bits/types/clockid_t.h \ 24 | /usr/lib/zig/libc/include/generic-glibc/bits/types/timer_t.h \ 25 | /usr/lib/zig/libc/include/generic-glibc/bits/types/struct_itimerspec.h \ 26 | /usr/lib/zig/libc/include/generic-glibc/bits/types/locale_t.h \ 27 | /usr/lib/zig/libc/include/generic-glibc/bits/types/__locale_t.h 28 | -------------------------------------------------------------------------------- /src/zig-cache/o/15b1d201020b38a243d82958aa2c3324/builtin.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | /// Zig version. When writing code that supports multiple versions of Zig, prefer 3 | /// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks. 4 | pub const zig_version = std.SemanticVersion.parse("0.9.1") catch unreachable; 5 | /// Temporary until self-hosted is feature complete. 6 | pub const zig_is_stage2 = false; 7 | /// Temporary until self-hosted supports the `cpu.arch` value. 8 | pub const stage2_arch: std.Target.Cpu.Arch = .x86_64; 9 | /// Temporary until self-hosted can call `std.Target.x86.featureSetHas` at comptime. 10 | pub const stage2_x86_cx16 = true; 11 | 12 | pub const output_mode = std.builtin.OutputMode.Exe; 13 | pub const link_mode = std.builtin.LinkMode.Dynamic; 14 | pub const is_test = false; 15 | pub const single_threaded = false; 16 | pub const abi = std.Target.Abi.gnu; 17 | pub const cpu: std.Target.Cpu = .{ 18 | .arch = .x86_64, 19 | .model = &std.Target.x86.cpu.znver2, 20 | .features = std.Target.x86.featureSet(&[_]std.Target.x86.Feature{ 21 | .@"64bit", 22 | .adx, 23 | .aes, 24 | .avx, 25 | .avx2, 26 | .bmi, 27 | .bmi2, 28 | .branchfusion, 29 | .clflushopt, 30 | .clwb, 31 | .clzero, 32 | .cmov, 33 | .cx16, 34 | .cx8, 35 | .f16c, 36 | .fast_15bytenop, 37 | .fast_bextr, 38 | .fast_lzcnt, 39 | .fast_movbe, 40 | .fast_scalar_shift_masks, 41 | .fma, 42 | .fsgsbase, 43 | .fxsr, 44 | .lzcnt, 45 | .mmx, 46 | .movbe, 47 | .mwaitx, 48 | .nopl, 49 | .pclmul, 50 | .popcnt, 51 | .prfchw, 52 | .rdpid, 53 | .rdrnd, 54 | .rdseed, 55 | .sahf, 56 | .sha, 57 | .slow_shld, 58 | .sse, 59 | .sse2, 60 | .sse3, 61 | .sse4_1, 62 | .sse4_2, 63 | .sse4a, 64 | .ssse3, 65 | .vzeroupper, 66 | .wbnoinvd, 67 | .x87, 68 | .xsave, 69 | .xsavec, 70 | .xsaveopt, 71 | .xsaves, 72 | }), 73 | }; 74 | pub const os = std.Target.Os{ 75 | .tag = .linux, 76 | .version_range = .{ .linux = .{ 77 | .range = .{ 78 | .min = .{ 79 | .major = 5, 80 | .minor = 16, 81 | .patch = 14, 82 | }, 83 | .max = .{ 84 | .major = 5, 85 | .minor = 16, 86 | .patch = 14, 87 | }, 88 | }, 89 | .glibc = .{ 90 | .major = 2, 91 | .minor = 19, 92 | .patch = 0, 93 | }, 94 | }}, 95 | }; 96 | pub const target = std.Target{ 97 | .cpu = cpu, 98 | .os = os, 99 | .abi = abi, 100 | }; 101 | pub const object_format = std.Target.ObjectFormat.elf; 102 | pub const mode = std.builtin.Mode.Debug; 103 | pub const link_libc = true; 104 | pub const link_libcpp = false; 105 | pub const have_error_return_tracing = true; 106 | pub const valgrind_support = true; 107 | pub const position_independent_code = true; 108 | pub const position_independent_executable = false; 109 | pub const strip_debug_info = false; 110 | pub const code_model = std.builtin.CodeModel.default; 111 | -------------------------------------------------------------------------------- /src/zig-cache/h/d189ab8274c935fb7c53bd865c3eed39.txt: -------------------------------------------------------------------------------- 1 | 18 24804107 1651699810259026734 f15574204079d2d8a50375887dc59f8c /home/moonraccoon/Documents/Dev/Zig/zig-algorithms/src/zig-cache/o/18d0d3a51bc40b077d4a11778966a5e4/cimport.h 2 | 14838 25697871 1648297862000000000 b2c5b016f157313c6bcd81dae8d3d9c2 /usr/lib/zig/libc/include/generic-glibc/time.h 3 | 18189 25697624 1648297862000000000 5f53b619e8b25e059ed77f261abcf0df /usr/lib/zig/libc/include/generic-glibc/features.h 4 | 1403 25697623 1648297862000000000 1659569835893ac30f788866a1d0bfd1 /usr/lib/zig/libc/include/generic-glibc/features-time64.h 5 | 441 25827054 1648297862000000000 4e485f3b9fd2e11ef5c1bddd137daede /usr/lib/zig/libc/include/x86_64-linux-gnu/bits/wordsize.h 6 | 1080 25827050 1648297862000000000 316ca0b36d658d281fec5391420613bd /usr/lib/zig/libc/include/x86_64-linux-gnu/bits/timesize.h 7 | 2289 25697761 1648297862000000000 58a8db15680c32b47e8af59e5b0258be /usr/lib/zig/libc/include/generic-glibc/stdc-predef.h 8 | 23286 25697775 1648297862000000000 b9fb0ab913bbef75063ad757d6b1a5f2 /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h 9 | 969 25827038 1648297862000000000 882ed736d189c106ff059a237a832988 /usr/lib/zig/libc/include/x86_64-linux-gnu/bits/long-double.h 10 | 383 25827062 1648297862000000000 7532df84c2d9cbe2bfda99ac55254087 /usr/lib/zig/libc/include/x86_64-linux-gnu/gnu/stubs.h 11 | 480 25827061 1648297862000000000 467059ecdc1c823a4b6e7c13544d3e44 /usr/lib/zig/libc/include/x86_64-linux-gnu/gnu/stubs-64.h 12 | 3589 24799711 1648297862000000000 d5b2e707895a5f0328183b755fbeead3 /usr/lib/zig/include/stddef.h 13 | 3295 25697537 1648297862000000000 b7856fd8c3ee30a0b769077806cd72db /usr/lib/zig/libc/include/generic-glibc/bits/time.h 14 | 8805 25697542 1648297862000000000 06b478d486beb6e6f334257edcc5d260 /usr/lib/zig/libc/include/generic-glibc/bits/types.h 15 | 3736 25827053 1648297862000000000 692ca5a1cb67f8580ea512c248539c74 /usr/lib/zig/libc/include/x86_64-linux-gnu/bits/typesizes.h 16 | 1339 25697538 1648297862000000000 282e3d5852cd0092d3c94f006c7cd34f /usr/lib/zig/libc/include/generic-glibc/bits/time64.h 17 | 142 25697551 1648297862000000000 1aae54bf635ae737936189e4d9eadbd7 /usr/lib/zig/libc/include/generic-glibc/bits/types/clock_t.h 18 | 202 25697588 1648297862000000000 77fc66476fdbbada779bf3a2b17f4707 /usr/lib/zig/libc/include/generic-glibc/bits/types/time_t.h 19 | 759 25697587 1648297862000000000 cf2c788dbc00170e7513940f77d01aea /usr/lib/zig/libc/include/generic-glibc/bits/types/struct_tm.h 20 | 866 25697585 1648297862000000000 9dc2122b432046e7ad5077cc204f863f /usr/lib/zig/libc/include/generic-glibc/bits/types/struct_timespec.h 21 | 1904 25697397 1648297862000000000 c69b971154749ba02f6f1e162e39aa31 /usr/lib/zig/libc/include/generic-glibc/bits/endian.h 22 | 272 25827026 1648297862000000000 2883d68df8945f9483e2002e70bd68e5 /usr/lib/zig/libc/include/x86_64-linux-gnu/bits/endianness.h 23 | 173 25697552 1648297862000000000 50f3b19618ed41fade4a76f475b5b305 /usr/lib/zig/libc/include/generic-glibc/bits/types/clockid_t.h 24 | 158 25697589 1648297862000000000 0d5e206e73011381044cca358ce1f9d5 /usr/lib/zig/libc/include/generic-glibc/bits/types/timer_t.h 25 | 287 25697568 1648297862000000000 6c59e7bb3b50855597e8249f152bfe43 /usr/lib/zig/libc/include/generic-glibc/bits/types/struct_itimerspec.h 26 | 982 25697555 1648297862000000000 03161c412a7fceab007d81bf31604430 /usr/lib/zig/libc/include/generic-glibc/bits/types/locale_t.h 27 | 1721 25697547 1648297862000000000 6a07a3a451542a8d3cb9a8dff141d020 /usr/lib/zig/libc/include/generic-glibc/bits/types/__locale_t.h 28 | -------------------------------------------------------------------------------- /src/algo_math.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const print = std.debug.print; 3 | const HashMap = std.AutoHashMap; 4 | const time = std.time; 5 | // const c = @cImport({ 6 | // @cInclude("time.h"); 7 | // }); 8 | 9 | /// # Prime Sieve of Erathostenes 10 | /// ---------------------------------------------------------- 11 | /// This calculates all primes until `n`. 12 | /// In most cases just used as a performance test. 13 | /// Prints the time in ms taken for calculation at the end. 14 | /// ---------------------------------------------------------- 15 | /// Arguments: 16 | /// > `n`: number until the prime numbers are calculated 17 | /// > `verbose`: `true` if you want to print all found primes 18 | /// ---------------------------------------------------------- 19 | pub fn sieve_of_erathostenes_arr(n: u64, verbose: bool) !void { 20 | var allocator = std.heap.page_allocator; 21 | var sieve = try allocator.alloc(bool, n + 1); 22 | defer allocator.free(sieve); 23 | for (sieve) |_, index| { 24 | sieve[index] = true; 25 | } 26 | sieve[0] = false; 27 | sieve[1] = false; 28 | var i: u64 = 2; 29 | // var start = c.clock(); 30 | var start = time.milliTimestamp(); 31 | while (i * i < n) : (i += 1) { 32 | if (sieve[i] == true) { 33 | var j: u64 = i * i; 34 | while (j <= n) : (j += i) { 35 | sieve[j] = false; 36 | } 37 | } 38 | } 39 | var msec = time.milliTimestamp() - start; 40 | // var diff = c.clock() - start; 41 | // var msec = @divFloor(diff * 1000, c.CLOCKS_PER_SEC); 42 | if (verbose == true) { 43 | i = 1; 44 | for (sieve) |e, k| { 45 | if (e == true) { 46 | print("\t{d:8}", .{k}); 47 | i += 1; 48 | if (i % 8 == 0) { 49 | print("\n", .{}); 50 | } 51 | } 52 | } 53 | } 54 | print("\n\n[+] prime sieve took {d} milliseconds\n", .{msec}); 55 | } 56 | 57 | pub fn sieve_of_erathostenes_hash(n: u32, verbose: bool) !void { 58 | var allocator = std.heap.page_allocator; 59 | var sieve = HashMap(u32, bool).init(allocator); 60 | defer sieve.deinit(); 61 | var i: u32 = 0; 62 | while (i <= n) : (i += 1) { 63 | try sieve.put(i, true); 64 | } 65 | try sieve.put(0, false); 66 | try sieve.put(1, false); 67 | 68 | i = 2; 69 | var start = time.milliTimestamp(); 70 | while (i * i <= n) : (i += 1) { 71 | if (sieve.get(i) == true) { 72 | var j: u32 = i * i; 73 | while (j <= n) : (j += i) { 74 | try sieve.put(j, false); 75 | } 76 | } 77 | } 78 | var msec = time.milliTimestamp() - start; 79 | if (verbose == true) { 80 | var iterator = sieve.iterator(); 81 | i = 0; 82 | while (iterator.next()) |entry| { 83 | if (entry.value_ptr.* == true) { 84 | print("{d}\n", .{entry.key_ptr.*}); 85 | } 86 | } 87 | } 88 | print("\n\n[+] prime sieve took {d} milliseconds\n", .{msec}); 89 | } 90 | 91 | pub fn fibonacci(n: u32) u32 { 92 | if (n == 0 or n == 1) { 93 | return 1; 94 | } 95 | return fibonacci(n - 1) + fibonacci(n - 2); 96 | } 97 | 98 | pub fn fibonacci_oneline(n: u32) u32 { 99 | return if (n == 0 or n == 1) 1 else fibonacci_oneline(n - 1) + fibonacci_oneline(n - 2); 100 | } 101 | 102 | pub fn euclidian_greatest_common_divisor(a: u32, b: u32) u32 { 103 | return if (b == 0) a else euclidian_greatest_common_divisor(b, a % b); 104 | } 105 | 106 | pub fn faculty(n: u32) u32 { 107 | if (n == 0 or n == 1) { 108 | return 1; 109 | } 110 | return n * faculty(n - 1); 111 | } 112 | 113 | pub fn faculty_oneline(n: u32) u32 { 114 | return if (n == 0 or n == 1) 1 else n * faculty_oneline(n - 1); 115 | } 116 | -------------------------------------------------------------------------------- /src/sort.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const print = std.debug.print; 3 | const rng = std.rand.DefaultPrng; 4 | 5 | /// Swap function 6 | /// 7 | /// Swap two variables by their values 8 | /// 9 | /// Arguments: 10 | /// > `a`, `b`: Variables to swap 11 | /// 12 | /// Return: 13 | /// > `void` 14 | /// > 15 | fn swap(a: *i32, b: *i32) void { 16 | const tmp = a.*; 17 | a.* = b.*; 18 | b.* = tmp; 19 | } 20 | 21 | /// Print the specified array 22 | /// in the form: 23 | /// > `| x0 | x1 | ... | xn |` 24 | /// 25 | /// Arguments: 26 | /// > `arr`: Array to print 27 | /// 28 | pub fn print_arr(arr: []i32) void { 29 | if (arr.len == 0) { 30 | print("[!] arr empty => nothing to print\n", .{}); 31 | return; 32 | } 33 | for (arr) |e| { 34 | print("| {d} ", .{e}); 35 | } 36 | print("|\n", .{}); 37 | } 38 | 39 | /// # BubbleSort 40 | /// ------ 41 | /// Description: 42 | /// Perform the bubble sort algorithm on an `i32` array 43 | /// ------ 44 | /// Arguments: 45 | /// > `arr`: `i32` array to perform BubbleSort on 46 | /// ------ 47 | /// TODO: 48 | /// > [] add descending option 49 | /// ------ 50 | /// 51 | pub fn bubble(arr: []i32) void { 52 | var step: u32 = 0; 53 | while (step < arr.len) : (step += 1) { 54 | var i: u32 = 0; 55 | while (i < arr.len - step - 1) : (i += 1) { 56 | if (arr[i] > arr[i + 1]) { 57 | swap(&arr[i], &arr[i + 1]); 58 | } 59 | } 60 | } 61 | } 62 | 63 | /// # BubbleSort Optimized 64 | /// ------ 65 | /// Description: 66 | /// Perform the bubble sort algorithm on an `i32` array. 67 | /// This is an optimized version. 68 | /// ------ 69 | /// Arguments: 70 | /// > `arr`: `i32` array to perform BubbleSort on 71 | /// ------ 72 | /// TODO: 73 | /// > [] add descending option 74 | /// ------ 75 | /// 76 | pub fn bubble_sort_optimized(arr: []i32) void { 77 | var step: u32 = 0; 78 | while (step < arr.len) : (step += 1) { 79 | var swapped: bool = false; 80 | var i: usize = 0; 81 | while (i < arr.len - step - 1) : (i += 1) { 82 | swap(&arr[i], &arr[i + 1]); 83 | swapped = true; 84 | } 85 | if (swapped == false) { 86 | break; 87 | } 88 | } 89 | } 90 | 91 | /// # SelectionSort 92 | /// ------ 93 | /// Description: 94 | /// Perform the SelectionSort algorithm on an `i32` array. 95 | /// ------ 96 | /// Arguments: 97 | /// > `arr`: `i32` array to perform SelectionSort on 98 | /// ------ 99 | /// TODO: 100 | /// > [] add descending option 101 | /// ------ 102 | /// 103 | pub fn selection(arr: []i32) void { 104 | var step: u32 = 0; 105 | while (step < arr.len) : (step += 1) { 106 | var min_index = step; 107 | var i = step + 1; 108 | while (i < arr.len) : (i += 1) { 109 | if (arr[i] < arr[min_index]) { 110 | min_index = i; 111 | } 112 | } 113 | swap(&arr[min_index], &arr[step]); 114 | } 115 | } 116 | 117 | /// # QuickSort Partition helper 118 | /// ------------------------------------------------------------------------- 119 | /// this function helps partitioning the array 120 | /// to have the smallest numbers on the left and the 121 | /// greatest numbers on the right side, all depending on 122 | /// a **pivot** point. 123 | /// Pivot can either be just the first element in the array, 124 | /// or be selected random from the array by setting `randomize` to `true`. 125 | /// ------------------------------------------------------------------------- 126 | /// Arguments: 127 | /// > `arr`: Array to partition 128 | /// > `left`: lower end where to start partitioning 129 | /// > `right`: upper end where to end partitioning 130 | /// > `randomize`: randomized pivot select if `true`, else first element from 131 | /// list 132 | /// ------------------------------------------------------------------------- 133 | /// Return: 134 | /// > `i32`: position of the pivot point -> useful for further partitioning. 135 | /// 136 | pub fn partition(arr: []i32, left: i32, right: i32, randomize: bool) i32 { 137 | var low = @intCast(u32, left); 138 | var high = @intCast(u32, right); 139 | 140 | var rnd = rng.init(0); 141 | var pivot = arr[if (randomize == true) rnd.random().intRangeAtMost(u32, low, high) else low]; 142 | 143 | if (arr.len == 0) { 144 | return 0; 145 | } 146 | while (low < high) { 147 | while (arr[low] < pivot) { 148 | low += 1; 149 | } 150 | while (arr[high] > pivot) { 151 | high -= 1; 152 | } 153 | if (arr[low] == arr[high]) { 154 | return @intCast(i32, low); 155 | } 156 | if (low < high) { 157 | swap(&arr[low], &arr[high]); 158 | } 159 | } 160 | return @intCast(i32, low); 161 | } 162 | 163 | /// # QuickSort Recursive 164 | /// ------------------------------------------------------------------------- 165 | /// Description: 166 | /// Sorts the array with QuickSort from lower(`left`) to upper(`right`) limit. 167 | /// ------------------------------------------------------------------------- 168 | /// Arguments: 169 | /// > `arr`: Array to sort 170 | /// > `left`: lower end where to start sorting 171 | /// > `right`: upper end where to end sorting 172 | /// > `randomize`: randomized pivot select if `true`, else first element from 173 | /// list 174 | /// ------------------------------------------------------------------------- 175 | /// Return: 176 | /// > `void` 177 | /// 178 | pub fn quicksort_recursive(arr: []i32, left: i32, right: i32, randomize: bool) void { 179 | if (left < right) { 180 | var pivot = partition(arr, left, right, randomize); 181 | quicksort_recursive(arr, left, pivot - 1, randomize); 182 | quicksort_recursive(arr, pivot + 1, right, randomize); 183 | } 184 | } 185 | 186 | /// # QuickSort 187 | /// ------------------------------------------------------------------------- 188 | /// Description: 189 | /// Sorts the array using the QuickSort algorithm. You can select 190 | /// randomized **pivot** point by setting the `random_piv` argument to `true`. 191 | /// Wrapper function for `quicksort_recursive` 192 | /// ------------------------------------------------------------------------- 193 | /// Arguments: 194 | /// > `arr`: Array to sort 195 | /// > `rand_piv`: randomized pivot select if `true`, else first element from 196 | /// list 197 | /// ------------------------------------------------------------------------- 198 | /// Return: 199 | /// > `void` 200 | /// 201 | pub fn quicksort(arr: []i32, random_piv: bool) void { 202 | if (arr.len < 1) { 203 | return; 204 | } 205 | quicksort_recursive(arr, 0, @intCast(i32, (arr.len - 1)), random_piv); 206 | } 207 | -------------------------------------------------------------------------------- /src/zig-cache/h/829df49dc636d1c215d8c0da71b4527e.txt: -------------------------------------------------------------------------------- 1 | 682 24802794 1651699897012204173 bf04fa1db3876a03ddb4151ccadba731 /home/moonraccoon/Documents/Dev/Zig/zig-algorithms/src/main.zig 2 | 2818 24804102 1651699808925695911 3dff4183055bee7b0cd622ca91bcc6a2 /home/moonraccoon/Documents/Dev/Zig/zig-algorithms/src/zig-cache/o/15b1d201020b38a243d82958aa2c3324/builtin.zig 3 | 5391 27300318 1648297862000000000 99c935b1fadc1095742d1049c16b1f73 /usr/lib/zig/std/std.zig 4 | 682 24802794 1651699897012204173 bf04fa1db3876a03ddb4151ccadba731 /home/moonraccoon/Documents/Dev/Zig/zig-algorithms/src/main.zig 5 | 5391 27300318 1648297862000000000 99c935b1fadc1095742d1049c16b1f73 /usr/lib/zig/std/std.zig 6 | 26206 27300276 1648297862000000000 dbc4cb0419e16d4a31e572375da82b3e /usr/lib/zig/std/builtin.zig 7 | 21855 27300316 1648297862000000000 afc30f6da0dcf13f4d3062af48b3ac43 /usr/lib/zig/std/start.zig 8 | 61008 27300319 1648297862000000000 5b49cc22b6b033715b219b2e4c6df7ac /usr/lib/zig/std/target.zig 9 | 88870 27405623 1648297862000000000 a4e267754cdf9c71d18dca0dfe685156 /usr/lib/zig/std/target/x86.zig 10 | 57659 27300302 1648297862000000000 db42026211aa4121bafe18a7268b343c /usr/lib/zig/std/math.zig 11 | 33618 27300304 1648297862000000000 46535ad7f6a05d9584884e7b8ee186ce /usr/lib/zig/std/meta.zig 12 | 69235 27300284 1648297862000000000 0d3521a7b6366f64005e31da1083e0b7 /usr/lib/zig/std/debug.zig 13 | 5693 24802826 1651698662334566343 c5ec85f3f38bd14f6f630377c7a8e446 /home/moonraccoon/Documents/Dev/Zig/zig-algorithms/src/sort.zig 14 | 2393 24802814 1651699950392120869 9b6c423dd06d15586570ba84c4672350 /home/moonraccoon/Documents/Dev/Zig/zig-algorithms/src/algo_math.zig 15 | 45386 27300295 1648297862000000000 70932a11a45b5bf5a34e6339a8941375 /usr/lib/zig/std/heap.zig 16 | 107395 27300303 1648297862000000000 fcbd1b4b8725bfa78591bba05d9c2d70 /usr/lib/zig/std/mem.zig 17 | 30557 27404429 1648297862000000000 65c11e31a62933504f717be9e26f88d4 /usr/lib/zig/std/mem/Allocator.zig 18 | 46042 24804110 1651699810269026718 29c24e1f9f0c0db61e30e5ef96331a55 /home/moonraccoon/Documents/Dev/Zig/zig-algorithms/src/zig-cache/o/4a0013be77b43ed282340ac3afbfb278/cimport.zig 19 | 14075 27300326 1648297862000000000 4b3e1692b4d50ecd14b797bcb6314471 /usr/lib/zig/std/zig.zig 20 | 19809 27405639 1648297862000000000 17207381f2146df60e7430204e14284c /usr/lib/zig/std/zig/c_translation.zig 21 | 18207 27300277 1648297862000000000 3daf56112b1935b7c0da800597604de9 /usr/lib/zig/std/c.zig 22 | 11945 27394664 1648297862000000000 4bd1ebdca6f82c5be7fcbec489529d87 /usr/lib/zig/std/c/linux.zig 23 | 44172 27300287 1648297862000000000 65ec5ab92c40065cd449953a6e6f852b /usr/lib/zig/std/elf.zig 24 | 41844 27300257 1648297862000000000 809081a3fa77d0f9424a2b6785a9c119 /usr/lib/zig/std/Thread.zig 25 | 7904 27300261 1648297862000000000 f3b7ac95f2f098f334cb93310d8796bd /usr/lib/zig/std/Thread/Mutex.zig 26 | 6493 27300296 1648297862000000000 2f1ab48b0aec09df8c98184641d2023d /usr/lib/zig/std/io.zig 27 | 118163 27300292 1648297862000000000 5b76f8053fc57aaeea4755fbdbccfc60 /usr/lib/zig/std/fs.zig 28 | 41888 27402816 1648297862000000000 53274430079e3e9594bd5428d82b9b4a /usr/lib/zig/std/fs/file.zig 29 | 256538 27300308 1648297862000000000 db7c5a6deb052c7881eba11189dfc18a /usr/lib/zig/std/os.zig 30 | 152897 27404434 1648297862000000000 e4227e4d75b6a322bbe98b52420692f4 /usr/lib/zig/std/os/linux.zig 31 | 99977 27404446 1648297862000000000 29efc96c70131a7de02bb2142b49b720 /usr/lib/zig/std/os/linux/io_uring.zig 32 | 3436 27402852 1648297862000000000 52b506e9785d2910ac0c6dc1bc00339b /usr/lib/zig/std/io/writer.zig 33 | 13907 27300265 1648297862000000000 8076a44960496763cdf5c3049792e2e9 /usr/lib/zig/std/Thread/StaticResetEvent.zig 34 | 16198 27404458 1648297862000000000 33eeeaeaf18fad72f964812980a410e5 /usr/lib/zig/std/os/linux/x86_64.zig 35 | 98183 27300291 1648297862000000000 a61ad0621302b9f1305f66f425db3436 /usr/lib/zig/std/fmt.zig 36 | 83618 27300294 1648297862000000000 58d5c5778b4baa1368571fa84697db80 /usr/lib/zig/std/hash_map.zig 37 | 42277 27300285 1648297862000000000 bb8aca7bf5ec61c47aca7b6ebf08cb94 /usr/lib/zig/std/dwarf.zig 38 | 52325 27300267 1648297862000000000 83b54eba3ec17b5646e8ef82d50bfb55 /usr/lib/zig/std/array_list.zig 39 | 5853 27402844 1648297862000000000 e4ebd554fff4f4347909d2e820cd323d /usr/lib/zig/std/io/fixed_buffer_stream.zig 40 | 26615 27402848 1648297862000000000 e3a5103fb13d3c32dbaebed1925a90dd /usr/lib/zig/std/io/reader.zig 41 | 1117 27402849 1648297862000000000 3f2f071b498497f7d54bcfc458d51f5e /usr/lib/zig/std/io/seekable_stream.zig 42 | 15524 27300298 1648297862000000000 fd35bd5ce692e376140efff780ae8fd9 /usr/lib/zig/std/leb128.zig 43 | 3578 27402800 1648297862000000000 5be2b73bab9064c8b8fd700243bac785 /usr/lib/zig/std/dwarf/TAG.zig 44 | 6494 27402798 1648297862000000000 bbb5283cec1c0d8bce4f3f0c930e7958 /usr/lib/zig/std/dwarf/AT.zig 45 | 50424 27402818 1648297862000000000 12a03d3246107a6495b60c6a625c29a9 /usr/lib/zig/std/fs/path.zig 46 | 7889 27404442 1648297862000000000 562fc4eee397a5037d16dffd5e048cd4 /usr/lib/zig/std/os/linux/errno/generic.zig 47 | 932 27300289 1648297862000000000 b4c3b5276113dacf836baae9d9f94c34 /usr/lib/zig/std/event.zig 48 | 68675 27402807 1648297862000000000 c63f2338b6b028fe35892da44a377363 /usr/lib/zig/std/event/loop.zig 49 | 2956 27300269 1648297862000000000 224c7ee868b5251b2fb3a38a139de8ff /usr/lib/zig/std/atomic.zig 50 | 12142 27394272 1648297862000000000 960f31a28097b764cc5fbb0f9205d56e /usr/lib/zig/std/atomic/queue.zig 51 | 13435 27300299 1648297862000000000 841107470272eebec404e2b902f8b639 /usr/lib/zig/std/linked_list.zig 52 | 9321 27300262 1648297862000000000 6375a03982cbb853a43d3e581d5e5500 /usr/lib/zig/std/Thread/ResetEvent.zig 53 | 4685 27402830 1648297862000000000 bccc2a1210ecea59d9b108bd05b44f4d /usr/lib/zig/std/heap/arena_allocator.zig 54 | 10892 27300321 1648297862000000000 31fc51ed299a6e4baa67fa98f200e96a /usr/lib/zig/std/time.zig 55 | 7373 27300258 1648297862000000000 4d373c2c86127a7ec0f7b3ba579f054c /usr/lib/zig/std/Thread/AutoResetEvent.zig 56 | 5836 27394273 1648297862000000000 7d2404322fa027582c27f4f202ec6a58 /usr/lib/zig/std/atomic/stack.zig 57 | 19105 27404431 1648297862000000000 45e8137f667bfff4502578f66d4be5a5 /usr/lib/zig/std/meta/trait.zig 58 | 32421 27300322 1648297862000000000 16ca37fd4f5ff96730ce35daff9ee049 /usr/lib/zig/std/unicode.zig 59 | 1314 27300293 1648297862000000000 241bc6f0b7b0f07237a5e145b1d22a8a /usr/lib/zig/std/hash.zig 60 | 10122 27402829 1648297862000000000 6372ee29c64a8e176138e879d43eb625 /usr/lib/zig/std/hash/wyhash.zig 61 | 31592 27300313 1648297862000000000 32ddd57f125944112ecd368187c91caa /usr/lib/zig/std/process.zig 62 | 23439 27300314 1648297862000000000 7a34e96c7e4f543dd0f365818acb93fc /usr/lib/zig/std/rand.zig 63 | 3105 27404777 1648297862000000000 412e5ff0bcf84571f173caa8acab5393 /usr/lib/zig/std/rand/Xoshiro256.zig 64 | 9090 27300300 1648297862000000000 1180d90b55f45cb947269ff038108378 /usr/lib/zig/std/log.zig 65 | 36229 27300310 1648297862000000000 8dd156aa070c627fc25ef402c82b8cb0 /usr/lib/zig/std/pdb.zig 66 | 13263 27300279 1648297862000000000 52436f0b55cf344739d85e1b6989e029 /usr/lib/zig/std/coff.zig 67 | 127499 27404499 1648297862000000000 c34f941bc683d1597ce7899b65ef7fcc /usr/lib/zig/std/os/windows.zig 68 | 22970 27394271 1648297862000000000 2809286560339082772669bb49d3d305 /usr/lib/zig/std/atomic/Atomic.zig 69 | -------------------------------------------------------------------------------- /src/datastructures.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const print = std.debug.print; 3 | 4 | pub fn Node(comptime T: type) type { 5 | return struct { 6 | const Self = @This(); 7 | 8 | data: T, 9 | next: ?*Self = null, 10 | prev: ?*Self = null, 11 | 12 | pub fn new(data: T, next: ?*Self, prev: ?*Self) Self { 13 | return Self{ 14 | .data = data, 15 | .next = next, 16 | .prev = prev, 17 | }; 18 | } 19 | 20 | pub fn get(self: Self) T { 21 | return self.data; 22 | } 23 | }; 24 | } 25 | 26 | pub fn Stack(comptime T: type) type { 27 | return struct { 28 | const Self = @This(); 29 | 30 | head: ?*Node(T) = null, 31 | size: u32 = 0, 32 | 33 | /// # Stack init function 34 | /// --------------------------------------------------- 35 | /// Initialize the stack with the given datatype 36 | /// --------------------------------------------------- 37 | /// Return: 38 | /// > `Stack(T)`: Stack with the provided datatype `T` 39 | /// --------------------------------------------------- 40 | pub fn init() Self { 41 | return Self{}; 42 | } 43 | 44 | /// # Stack push function 45 | /// --------------------------------------- 46 | /// Pushes `data` onto the stack. 47 | /// --------------------------------------- 48 | /// Arguments: 49 | /// > `data`: data to push to stack 50 | /// --------------------------------------- 51 | pub fn push(self: *Self, data: T) !void { 52 | var new_node = try std.heap.page_allocator.create(Node(T)); 53 | new_node.data = data; 54 | if (self.size == 0) { 55 | self.head = new_node; 56 | self.head.?.next = null; 57 | } else { 58 | new_node.next = self.head; 59 | self.head = new_node; 60 | } 61 | self.size += 1; 62 | } 63 | 64 | /// # Stack pop() function 65 | /// --------------------------------------- 66 | /// Remove the first element of the stack, 67 | /// free the memory and return the element 68 | /// --------------------------------------- 69 | /// Return: 70 | /// > `T`: value of the topmost element 71 | /// --------------------------------------- 72 | pub fn pop(self: *Self) ?T { 73 | if (self.size < 1) { 74 | return null; 75 | } 76 | var data = self.head.?.data; 77 | var head = self.head; 78 | self.head = self.head.?.next; 79 | self.size -= 1; 80 | // Free memory of the Node 81 | std.heap.page_allocator.destroy(head.?); 82 | return data; 83 | } 84 | 85 | /// # Stack show function 86 | /// ------------------------------------------- 87 | /// Print the stack into the terminal 88 | /// "" will be printed if stack size is 0 89 | /// ------------------------------------------- 90 | pub fn show(self: Self) void { 91 | if (self.size < 1) { 92 | print("\n", .{}); 93 | return; 94 | } 95 | var node = self.head; 96 | print("|", .{}); 97 | while (node != null) { 98 | print(" {} |", .{node.?.data}); 99 | node = node.?.next; 100 | } 101 | print("\n", .{}); 102 | } 103 | }; 104 | } 105 | 106 | pub fn list(comptime T: type) type { 107 | return struct { 108 | const Self = @This(); 109 | 110 | head: ?*Node(T) = null, 111 | tail: ?*Node(T) = null, 112 | size: u32 = 0, 113 | /// # LinkedList init function 114 | /// ---------------------------------------------- 115 | /// Initialize the `list` with the given datatype 116 | /// ---------------------------------------------- 117 | /// Return: 118 | /// > Object of `list` 119 | /// ---------------------------------------------- 120 | pub fn init() Self { 121 | return Self{}; 122 | } 123 | 124 | /// # `list` - empty check function 125 | /// ---------------------------------------------- 126 | /// Checks if the list is empty 127 | /// ---------------------------------------------- 128 | /// Return: 129 | /// > `bool`: `true` if empty, else `false`. 130 | /// ---------------------------------------------- 131 | pub fn is_empty(self: Self) bool { 132 | return (self.size == 0); 133 | } 134 | 135 | /// # `list` push back function 136 | /// --------------------------------------------------------------- 137 | /// Appends the given element to the end of the list 138 | /// --------------------------------------------------------------- 139 | /// Args: 140 | /// > `data`: Element to be appended to list 141 | /// Return: 142 | /// > `bool`: `true` if memory allocation successful, else `false` 143 | /// --------------------------------------------------------------- 144 | pub fn push_back(self: *Self, data: T) bool { 145 | var new_node = std.heap.page_allocator.create(Node(T)) catch return false; 146 | new_node.data = data; 147 | 148 | if (self.size == 0) { 149 | self.head = new_node; 150 | self.head.?.next = null; 151 | self.head.?.prev = null; 152 | self.tail = new_node; 153 | self.tail.?.next = null; 154 | self.tail.?.prev = null; 155 | } else { 156 | new_node.next = null; 157 | new_node.prev = self.tail; 158 | self.tail.?.next = new_node; 159 | self.tail = new_node; 160 | } 161 | self.size += 1; 162 | return true; 163 | } 164 | 165 | /// # `list` remove from back function 166 | /// --------------------------------------------------------------- 167 | /// Deletes and deallocates the value from the tail of the list 168 | /// and returns the deleted value. 169 | /// --------------------------------------------------------------- 170 | /// Return: 171 | /// > `T`: value of last element on success, `null` else 172 | /// --------------------------------------------------------------- 173 | pub fn pop_back(self: *Self) ?T { 174 | if (self.size == 0) { 175 | return null; 176 | } 177 | 178 | var tmp = self.tail; 179 | var out = tmp.?.data; 180 | self.tail = self.tail.?.prev; 181 | self.tail.?.next = null; 182 | std.heap.page_allocator.destroy(tmp.?); 183 | self.size -= 1; 184 | return out; 185 | } 186 | 187 | /// # `list` add to front function 188 | /// --------------------------------------------------------------- 189 | /// Adds an element to the front of the `list` and shift the 190 | /// remaining elements to the right. 191 | /// Returns `true` on success. 192 | /// --------------------------------------------------------------- 193 | /// Args: 194 | /// > `data`: Data to be put at the front 195 | /// Return: 196 | /// > `bool`: `true` if allocation successful, `false` else. 197 | /// --------------------------------------------------------------- 198 | pub fn push_front(self: *Self, data: T) bool { 199 | var new_node = std.heap.page_allocator.create(Node(T)) catch return false; 200 | new_node.data = data; 201 | 202 | if (self.size == 0) { 203 | self.head = new_node; 204 | self.head.?.next = null; 205 | self.head.?.prev = null; 206 | self.tail = new_node; 207 | self.tail.?.next = null; 208 | self.tail.?.prev = null; 209 | } else { 210 | new_node.next = self.head; 211 | new_node.prev = null; 212 | self.head.?.prev = new_node; 213 | self.head = new_node; 214 | } 215 | self.size += 1; 216 | return true; 217 | } 218 | 219 | /// # `list` remove from front function 220 | /// --------------------------------------------------------------- 221 | /// Deletes and deallocates the value from the front of the list 222 | /// and returns the deleted value. 223 | /// --------------------------------------------------------------- 224 | /// Return: 225 | /// > `T`: value of first element on success, `null` else 226 | /// --------------------------------------------------------------- 227 | pub fn pop_front(self: *Self) ?T { 228 | if (self.size == 0) { 229 | return null; 230 | } 231 | var tmp = self.head; 232 | var out = self.head.?.data; 233 | self.head = self.head.?.next; 234 | self.head.?.prev = null; 235 | std.heap.page_allocator.destroy(tmp.?); 236 | self.size -= 1; 237 | return out; 238 | } 239 | 240 | /// # `list` - put element at the given position 241 | /// --------------------------------------------------------------- 242 | /// Puts the element at the position specified by `idx`. Shift 243 | /// rest of the elements to the right. 244 | /// Does nothing if out of bound. 245 | /// --------------------------------------------------------------- 246 | /// Args: 247 | /// > `idx`: Index to put the data in 248 | /// > `data`: Data to insert into the list 249 | /// Return: 250 | /// > `bool`: `true` on success, `false` else. 251 | /// --------------------------------------------------------------- 252 | pub fn insert(self: *Self, idx: i32, data: T) bool { 253 | if (idx == 0) { 254 | return self.push_front(data); 255 | } else if (idx == self.size) { 256 | return self.push_back(data); 257 | } 258 | // create loop-counter 259 | var cnt: u32 = 0; 260 | var cur = self.head; 261 | // Iterate through list until `idx` or until EOL 262 | while (cnt < idx and cur != null and cnt < self.size) : (cnt += 1) { 263 | cur = cur.?.next; 264 | } 265 | // Return if EOL 266 | if (cnt >= self.size) { 267 | return false; 268 | } 269 | // Create new data-node 270 | var new_node = std.heap.page_allocator.create(Node(T)) catch return false; 271 | new_node.data = data; 272 | new_node.next = cur; 273 | new_node.prev = cur.?.prev; 274 | cur.?.prev = new_node; 275 | new_node.prev.?.next = new_node; 276 | self.size += 1; 277 | return true; 278 | } 279 | 280 | pub fn replace(self: *Self, idx: i32, data: T) bool { 281 | if (self.size == 0) { 282 | return false; 283 | } 284 | if (idx == 0) { 285 | self.head.?.data = data; 286 | return true; 287 | } else if (idx == self.size) { 288 | self.head.?.data = data; 289 | } 290 | // create loop-counter 291 | var cnt: u32 = 0; 292 | var cur = self.head; 293 | // Iterate through list until `idx` or until EOL 294 | while (cnt < idx and cur != null and cnt < self.size) : (cnt += 1) { 295 | cur = cur.?.next; 296 | } 297 | // Return if EOL 298 | if (cnt >= self.size) { 299 | return false; 300 | } 301 | cur.?.data = data; 302 | return true; 303 | } 304 | 305 | /// TODO: List clear with memory deallocation 306 | pub fn clear(self: *Self) void { 307 | if (self.size == 0) { 308 | return; 309 | } 310 | } 311 | 312 | /// # `list` - Get the element at the specified index 313 | /// --------------------------------------------------------------- 314 | /// Returns the value from the list specified by the index `idx`. 315 | /// Returns the data if element found, `null` else. 316 | /// --------------------------------------------------------------- 317 | /// Args: 318 | /// > `idx`: Index to get the data from 319 | /// Return: 320 | /// > `?T`: data if found at index `idx`, else `null`. 321 | /// --------------------------------------------------------------- 322 | pub fn get(self: Self, idx: i32) ?T { 323 | if (self.size == 0) { 324 | return null; 325 | } 326 | 327 | var cnt: u32 = 0; 328 | var cur = self.head; 329 | // Iterate through list until `idx` or until EOL 330 | while (cnt < idx and cur != null and cnt < self.size) : (cnt += 1) { 331 | cur = cur.?.next; 332 | } 333 | if (cur == null or cnt >= self.size) { 334 | return null; 335 | } 336 | return cur.?.data; 337 | } 338 | 339 | /// # `list` - Delete the element at the specified index 340 | /// ---------------------------------------------------------------- 341 | /// Deletes the value at the specified index and returns it's value. 342 | /// Doesn't delete anything if element is not found. 343 | /// Data gets deallocated on success. 344 | /// ---------------------------------------------------------------- 345 | /// Args: 346 | /// > `idx`: Index to delete the data from 347 | /// Return: 348 | /// > `?T`: data if deleted at index `idx`, else `null`. 349 | /// ---------------------------------------------------------------- 350 | pub fn del(self: *Self, idx: i32) ?T { 351 | if (self.size == 0 or idx > self.size - 1) { 352 | return null; 353 | } 354 | if (idx == 0) { 355 | return self.pop_front(); 356 | } else if (idx == self.size - 1) { 357 | return self.pop_back(); 358 | } 359 | 360 | var cnt: u32 = 0; 361 | var cur = self.head; 362 | // Iterate through list until `idx` or until EOL 363 | while (cnt < idx and cur != null and cnt < self.size) : (cnt += 1) { 364 | cur = cur.?.next; 365 | } 366 | if (cur == null or cnt >= self.size) { 367 | return null; 368 | } 369 | var tmp = cur; 370 | var out = tmp.?.data; 371 | cur.?.prev.?.next = cur.?.next; 372 | cur.?.next.?.prev = cur.?.prev; 373 | std.heap.page_allocator.destroy(tmp.?); 374 | self.size -= 1; 375 | return out; 376 | } 377 | 378 | pub fn show(self: Self) void { 379 | if (self.size < 1) { 380 | print("\n", .{}); 381 | return; 382 | } 383 | var node = self.head; 384 | print("|", .{}); 385 | while (node != null) { 386 | print(" {} |", .{node.?.data}); 387 | node = node.?.next; 388 | } 389 | print("\n", .{}); 390 | } 391 | }; 392 | } 393 | -------------------------------------------------------------------------------- /src/zig-cache/o/4a0013be77b43ed282340ac3afbfb278/cimport.zig: -------------------------------------------------------------------------------- 1 | pub const __builtin_bswap16 = @import("std").zig.c_builtins.__builtin_bswap16; 2 | pub const __builtin_bswap32 = @import("std").zig.c_builtins.__builtin_bswap32; 3 | pub const __builtin_bswap64 = @import("std").zig.c_builtins.__builtin_bswap64; 4 | pub const __builtin_signbit = @import("std").zig.c_builtins.__builtin_signbit; 5 | pub const __builtin_signbitf = @import("std").zig.c_builtins.__builtin_signbitf; 6 | pub const __builtin_popcount = @import("std").zig.c_builtins.__builtin_popcount; 7 | pub const __builtin_ctz = @import("std").zig.c_builtins.__builtin_ctz; 8 | pub const __builtin_clz = @import("std").zig.c_builtins.__builtin_clz; 9 | pub const __builtin_sqrt = @import("std").zig.c_builtins.__builtin_sqrt; 10 | pub const __builtin_sqrtf = @import("std").zig.c_builtins.__builtin_sqrtf; 11 | pub const __builtin_sin = @import("std").zig.c_builtins.__builtin_sin; 12 | pub const __builtin_sinf = @import("std").zig.c_builtins.__builtin_sinf; 13 | pub const __builtin_cos = @import("std").zig.c_builtins.__builtin_cos; 14 | pub const __builtin_cosf = @import("std").zig.c_builtins.__builtin_cosf; 15 | pub const __builtin_exp = @import("std").zig.c_builtins.__builtin_exp; 16 | pub const __builtin_expf = @import("std").zig.c_builtins.__builtin_expf; 17 | pub const __builtin_exp2 = @import("std").zig.c_builtins.__builtin_exp2; 18 | pub const __builtin_exp2f = @import("std").zig.c_builtins.__builtin_exp2f; 19 | pub const __builtin_log = @import("std").zig.c_builtins.__builtin_log; 20 | pub const __builtin_logf = @import("std").zig.c_builtins.__builtin_logf; 21 | pub const __builtin_log2 = @import("std").zig.c_builtins.__builtin_log2; 22 | pub const __builtin_log2f = @import("std").zig.c_builtins.__builtin_log2f; 23 | pub const __builtin_log10 = @import("std").zig.c_builtins.__builtin_log10; 24 | pub const __builtin_log10f = @import("std").zig.c_builtins.__builtin_log10f; 25 | pub const __builtin_abs = @import("std").zig.c_builtins.__builtin_abs; 26 | pub const __builtin_fabs = @import("std").zig.c_builtins.__builtin_fabs; 27 | pub const __builtin_fabsf = @import("std").zig.c_builtins.__builtin_fabsf; 28 | pub const __builtin_floor = @import("std").zig.c_builtins.__builtin_floor; 29 | pub const __builtin_floorf = @import("std").zig.c_builtins.__builtin_floorf; 30 | pub const __builtin_ceil = @import("std").zig.c_builtins.__builtin_ceil; 31 | pub const __builtin_ceilf = @import("std").zig.c_builtins.__builtin_ceilf; 32 | pub const __builtin_trunc = @import("std").zig.c_builtins.__builtin_trunc; 33 | pub const __builtin_truncf = @import("std").zig.c_builtins.__builtin_truncf; 34 | pub const __builtin_round = @import("std").zig.c_builtins.__builtin_round; 35 | pub const __builtin_roundf = @import("std").zig.c_builtins.__builtin_roundf; 36 | pub const __builtin_strlen = @import("std").zig.c_builtins.__builtin_strlen; 37 | pub const __builtin_strcmp = @import("std").zig.c_builtins.__builtin_strcmp; 38 | pub const __builtin_object_size = @import("std").zig.c_builtins.__builtin_object_size; 39 | pub const __builtin___memset_chk = @import("std").zig.c_builtins.__builtin___memset_chk; 40 | pub const __builtin_memset = @import("std").zig.c_builtins.__builtin_memset; 41 | pub const __builtin___memcpy_chk = @import("std").zig.c_builtins.__builtin___memcpy_chk; 42 | pub const __builtin_memcpy = @import("std").zig.c_builtins.__builtin_memcpy; 43 | pub const __builtin_expect = @import("std").zig.c_builtins.__builtin_expect; 44 | pub const __builtin_nanf = @import("std").zig.c_builtins.__builtin_nanf; 45 | pub const __builtin_huge_valf = @import("std").zig.c_builtins.__builtin_huge_valf; 46 | pub const __builtin_inff = @import("std").zig.c_builtins.__builtin_inff; 47 | pub const __builtin_isnan = @import("std").zig.c_builtins.__builtin_isnan; 48 | pub const __builtin_isinf = @import("std").zig.c_builtins.__builtin_isinf; 49 | pub const __builtin_isinf_sign = @import("std").zig.c_builtins.__builtin_isinf_sign; 50 | pub const __u_char = u8; 51 | pub const __u_short = c_ushort; 52 | pub const __u_int = c_uint; 53 | pub const __u_long = c_ulong; 54 | pub const __int8_t = i8; 55 | pub const __uint8_t = u8; 56 | pub const __int16_t = c_short; 57 | pub const __uint16_t = c_ushort; 58 | pub const __int32_t = c_int; 59 | pub const __uint32_t = c_uint; 60 | pub const __int64_t = c_long; 61 | pub const __uint64_t = c_ulong; 62 | pub const __int_least8_t = __int8_t; 63 | pub const __uint_least8_t = __uint8_t; 64 | pub const __int_least16_t = __int16_t; 65 | pub const __uint_least16_t = __uint16_t; 66 | pub const __int_least32_t = __int32_t; 67 | pub const __uint_least32_t = __uint32_t; 68 | pub const __int_least64_t = __int64_t; 69 | pub const __uint_least64_t = __uint64_t; 70 | pub const __quad_t = c_long; 71 | pub const __u_quad_t = c_ulong; 72 | pub const __intmax_t = c_long; 73 | pub const __uintmax_t = c_ulong; 74 | pub const __dev_t = c_ulong; 75 | pub const __uid_t = c_uint; 76 | pub const __gid_t = c_uint; 77 | pub const __ino_t = c_ulong; 78 | pub const __ino64_t = c_ulong; 79 | pub const __mode_t = c_uint; 80 | pub const __nlink_t = c_ulong; 81 | pub const __off_t = c_long; 82 | pub const __off64_t = c_long; 83 | pub const __pid_t = c_int; 84 | pub const __fsid_t = extern struct { 85 | __val: [2]c_int, 86 | }; 87 | pub const __clock_t = c_long; 88 | pub const __rlim_t = c_ulong; 89 | pub const __rlim64_t = c_ulong; 90 | pub const __id_t = c_uint; 91 | pub const __time_t = c_long; 92 | pub const __useconds_t = c_uint; 93 | pub const __suseconds_t = c_long; 94 | pub const __suseconds64_t = c_long; 95 | pub const __daddr_t = c_int; 96 | pub const __key_t = c_int; 97 | pub const __clockid_t = c_int; 98 | pub const __timer_t = ?*anyopaque; 99 | pub const __blksize_t = c_long; 100 | pub const __blkcnt_t = c_long; 101 | pub const __blkcnt64_t = c_long; 102 | pub const __fsblkcnt_t = c_ulong; 103 | pub const __fsblkcnt64_t = c_ulong; 104 | pub const __fsfilcnt_t = c_ulong; 105 | pub const __fsfilcnt64_t = c_ulong; 106 | pub const __fsword_t = c_long; 107 | pub const __ssize_t = c_long; 108 | pub const __syscall_slong_t = c_long; 109 | pub const __syscall_ulong_t = c_ulong; 110 | pub const __loff_t = __off64_t; 111 | pub const __caddr_t = [*c]u8; 112 | pub const __intptr_t = c_long; 113 | pub const __socklen_t = c_uint; 114 | pub const __sig_atomic_t = c_int; 115 | pub const clock_t = __clock_t; 116 | pub const time_t = __time_t; 117 | pub const struct_tm = extern struct { 118 | tm_sec: c_int, 119 | tm_min: c_int, 120 | tm_hour: c_int, 121 | tm_mday: c_int, 122 | tm_mon: c_int, 123 | tm_year: c_int, 124 | tm_wday: c_int, 125 | tm_yday: c_int, 126 | tm_isdst: c_int, 127 | tm_gmtoff: c_long, 128 | tm_zone: [*c]const u8, 129 | }; 130 | pub const struct_timespec = extern struct { 131 | tv_sec: __time_t, 132 | tv_nsec: __syscall_slong_t, 133 | }; 134 | pub const clockid_t = __clockid_t; 135 | pub const timer_t = __timer_t; 136 | pub const struct_itimerspec = extern struct { 137 | it_interval: struct_timespec, 138 | it_value: struct_timespec, 139 | }; 140 | pub const struct_sigevent = opaque {}; 141 | pub const pid_t = __pid_t; 142 | pub const struct___locale_data = opaque {}; 143 | pub const struct___locale_struct = extern struct { 144 | __locales: [13]?*struct___locale_data, 145 | __ctype_b: [*c]const c_ushort, 146 | __ctype_tolower: [*c]const c_int, 147 | __ctype_toupper: [*c]const c_int, 148 | __names: [13][*c]const u8, 149 | }; 150 | pub const __locale_t = [*c]struct___locale_struct; 151 | pub const locale_t = __locale_t; 152 | pub extern fn clock() clock_t; 153 | pub extern fn time(__timer: [*c]time_t) time_t; 154 | pub extern fn difftime(__time1: time_t, __time0: time_t) f64; 155 | pub extern fn mktime(__tp: [*c]struct_tm) time_t; 156 | pub extern fn strftime(noalias __s: [*c]u8, __maxsize: usize, noalias __format: [*c]const u8, noalias __tp: [*c]const struct_tm) usize; 157 | pub extern fn strftime_l(noalias __s: [*c]u8, __maxsize: usize, noalias __format: [*c]const u8, noalias __tp: [*c]const struct_tm, __loc: locale_t) usize; 158 | pub extern fn gmtime(__timer: [*c]const time_t) [*c]struct_tm; 159 | pub extern fn localtime(__timer: [*c]const time_t) [*c]struct_tm; 160 | pub extern fn gmtime_r(noalias __timer: [*c]const time_t, noalias __tp: [*c]struct_tm) [*c]struct_tm; 161 | pub extern fn localtime_r(noalias __timer: [*c]const time_t, noalias __tp: [*c]struct_tm) [*c]struct_tm; 162 | pub extern fn asctime(__tp: [*c]const struct_tm) [*c]u8; 163 | pub extern fn ctime(__timer: [*c]const time_t) [*c]u8; 164 | pub extern fn asctime_r(noalias __tp: [*c]const struct_tm, noalias __buf: [*c]u8) [*c]u8; 165 | pub extern fn ctime_r(noalias __timer: [*c]const time_t, noalias __buf: [*c]u8) [*c]u8; 166 | pub extern var __tzname: [2][*c]u8; 167 | pub extern var __daylight: c_int; 168 | pub extern var __timezone: c_long; 169 | pub extern var tzname: [2][*c]u8; 170 | pub extern fn tzset() void; 171 | pub extern var daylight: c_int; 172 | pub extern var timezone: c_long; 173 | pub extern fn timegm(__tp: [*c]struct_tm) time_t; 174 | pub extern fn timelocal(__tp: [*c]struct_tm) time_t; 175 | pub extern fn dysize(__year: c_int) c_int; 176 | pub extern fn nanosleep(__requested_time: [*c]const struct_timespec, __remaining: [*c]struct_timespec) c_int; 177 | pub extern fn clock_getres(__clock_id: clockid_t, __res: [*c]struct_timespec) c_int; 178 | pub extern fn clock_gettime(__clock_id: clockid_t, __tp: [*c]struct_timespec) c_int; 179 | pub extern fn clock_settime(__clock_id: clockid_t, __tp: [*c]const struct_timespec) c_int; 180 | pub extern fn clock_nanosleep(__clock_id: clockid_t, __flags: c_int, __req: [*c]const struct_timespec, __rem: [*c]struct_timespec) c_int; 181 | pub extern fn clock_getcpuclockid(__pid: pid_t, __clock_id: [*c]clockid_t) c_int; 182 | pub extern fn timer_create(__clock_id: clockid_t, noalias __evp: ?*struct_sigevent, noalias __timerid: [*c]timer_t) c_int; 183 | pub extern fn timer_delete(__timerid: timer_t) c_int; 184 | pub extern fn timer_settime(__timerid: timer_t, __flags: c_int, noalias __value: [*c]const struct_itimerspec, noalias __ovalue: [*c]struct_itimerspec) c_int; 185 | pub extern fn timer_gettime(__timerid: timer_t, __value: [*c]struct_itimerspec) c_int; 186 | pub extern fn timer_getoverrun(__timerid: timer_t) c_int; 187 | pub extern fn timespec_get(__ts: [*c]struct_timespec, __base: c_int) c_int; 188 | pub const __INTMAX_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `L`"); // (no file):67:9 189 | pub const __UINTMAX_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `UL`"); // (no file):73:9 190 | pub const __INT64_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `L`"); // (no file):164:9 191 | pub const __UINT32_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `U`"); // (no file):186:9 192 | pub const __UINT64_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `UL`"); // (no file):194:9 193 | pub const __seg_gs = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // (no file):315:9 194 | pub const __seg_fs = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // (no file):316:9 195 | pub const __GLIBC_USE = @compileError("unable to translate macro: undefined identifier `__GLIBC_USE_`"); // /usr/lib/zig/libc/include/generic-glibc/features.h:186:9 196 | pub const __glibc_has_attribute = @compileError("unable to translate macro: undefined identifier `__has_attribute`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:44:10 197 | pub const __glibc_has_builtin = @compileError("unable to translate macro: undefined identifier `__has_builtin`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:49:10 198 | pub const __glibc_has_extension = @compileError("unable to translate macro: undefined identifier `__has_extension`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:54:10 199 | pub const __THROW = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:78:11 200 | pub const __THROWNL = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:79:11 201 | pub const __NTH = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:80:11 202 | pub const __NTHNL = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:81:11 203 | pub const __CONCAT = @compileError("unable to translate C expr: unexpected token .HashHash"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:123:9 204 | pub const __STRING = @compileError("unable to translate C expr: unexpected token .Hash"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:124:9 205 | pub const __warnattr = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:158:10 206 | pub const __errordecl = @compileError("unable to translate C expr: unexpected token .Keyword_extern"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:159:10 207 | pub const __flexarr = @compileError("unable to translate C expr: unexpected token .LBracket"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:167:10 208 | pub const __REDIRECT = @compileError("unable to translate macro: undefined identifier `__asm__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:198:10 209 | pub const __REDIRECT_NTH = @compileError("unable to translate macro: undefined identifier `__asm__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:205:11 210 | pub const __REDIRECT_NTHNL = @compileError("unable to translate macro: undefined identifier `__asm__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:207:11 211 | pub const __ASMNAME2 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:211:10 212 | pub const __attribute_malloc__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:232:10 213 | pub const __attribute_alloc_size__ = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:243:10 214 | pub const __attribute_pure__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:250:10 215 | pub const __attribute_const__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:257:10 216 | pub const __attribute_maybe_unused__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:263:10 217 | pub const __attribute_used__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:272:10 218 | pub const __attribute_noinline__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:273:10 219 | pub const __attribute_deprecated__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:281:10 220 | pub const __attribute_deprecated_msg__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:291:10 221 | pub const __attribute_format_arg__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:304:10 222 | pub const __attribute_format_strfmon__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:314:10 223 | pub const __nonnull = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:324:11 224 | pub const __returns_nonnull = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:337:10 225 | pub const __attribute_warn_unused_result__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:346:10 226 | pub const __always_inline = @compileError("unable to translate macro: undefined identifier `__inline`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:364:10 227 | pub const __attribute_artificial__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:373:10 228 | pub const __extern_inline = @compileError("unable to translate macro: undefined identifier `__inline`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:391:11 229 | pub const __extern_always_inline = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:392:11 230 | pub const __restrict_arr = @compileError("unable to translate macro: undefined identifier `__restrict`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:435:10 231 | pub const __attribute_copy__ = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:484:10 232 | pub const __LDBL_REDIR2_DECL = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:560:10 233 | pub const __LDBL_REDIR_DECL = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:561:10 234 | pub const __glibc_macro_warning1 = @compileError("unable to translate macro: undefined identifier `_Pragma`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:575:10 235 | pub const __glibc_macro_warning = @compileError("unable to translate macro: undefined identifier `GCC`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:576:10 236 | pub const __attr_access = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:612:11 237 | pub const __attr_access_none = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:613:11 238 | pub const __attr_dealloc = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:623:10 239 | pub const __attribute_returns_twice__ = @compileError("unable to translate macro: undefined identifier `__attribute__`"); // /usr/lib/zig/libc/include/generic-glibc/sys/cdefs.h:630:10 240 | pub const __STD_TYPE = @compileError("unable to translate C expr: unexpected token .Keyword_typedef"); // /usr/lib/zig/libc/include/generic-glibc/bits/types.h:137:10 241 | pub const __FSID_T_TYPE = @compileError("unable to translate macro: undefined identifier `__val`"); // /usr/lib/zig/libc/include/x86_64-linux-gnu/bits/typesizes.h:73:9 242 | pub const __llvm__ = @as(c_int, 1); 243 | pub const __clang__ = @as(c_int, 1); 244 | pub const __clang_major__ = @as(c_int, 13); 245 | pub const __clang_minor__ = @as(c_int, 0); 246 | pub const __clang_patchlevel__ = @as(c_int, 1); 247 | pub const __clang_version__ = "13.0.1 "; 248 | pub const __GNUC__ = @as(c_int, 4); 249 | pub const __GNUC_MINOR__ = @as(c_int, 2); 250 | pub const __GNUC_PATCHLEVEL__ = @as(c_int, 1); 251 | pub const __GXX_ABI_VERSION = @as(c_int, 1002); 252 | pub const __ATOMIC_RELAXED = @as(c_int, 0); 253 | pub const __ATOMIC_CONSUME = @as(c_int, 1); 254 | pub const __ATOMIC_ACQUIRE = @as(c_int, 2); 255 | pub const __ATOMIC_RELEASE = @as(c_int, 3); 256 | pub const __ATOMIC_ACQ_REL = @as(c_int, 4); 257 | pub const __ATOMIC_SEQ_CST = @as(c_int, 5); 258 | pub const __OPENCL_MEMORY_SCOPE_WORK_ITEM = @as(c_int, 0); 259 | pub const __OPENCL_MEMORY_SCOPE_WORK_GROUP = @as(c_int, 1); 260 | pub const __OPENCL_MEMORY_SCOPE_DEVICE = @as(c_int, 2); 261 | pub const __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES = @as(c_int, 3); 262 | pub const __OPENCL_MEMORY_SCOPE_SUB_GROUP = @as(c_int, 4); 263 | pub const __PRAGMA_REDEFINE_EXTNAME = @as(c_int, 1); 264 | pub const __VERSION__ = "Clang 13.0.1"; 265 | pub const __OBJC_BOOL_IS_BOOL = @as(c_int, 0); 266 | pub const __CONSTANT_CFSTRINGS__ = @as(c_int, 1); 267 | pub const __clang_literal_encoding__ = "UTF-8"; 268 | pub const __clang_wide_literal_encoding__ = "UTF-32"; 269 | pub const __OPTIMIZE__ = @as(c_int, 1); 270 | pub const __ORDER_LITTLE_ENDIAN__ = @as(c_int, 1234); 271 | pub const __ORDER_BIG_ENDIAN__ = @as(c_int, 4321); 272 | pub const __ORDER_PDP_ENDIAN__ = @as(c_int, 3412); 273 | pub const __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__; 274 | pub const __LITTLE_ENDIAN__ = @as(c_int, 1); 275 | pub const _LP64 = @as(c_int, 1); 276 | pub const __LP64__ = @as(c_int, 1); 277 | pub const __CHAR_BIT__ = @as(c_int, 8); 278 | pub const __SCHAR_MAX__ = @as(c_int, 127); 279 | pub const __SHRT_MAX__ = @as(c_int, 32767); 280 | pub const __INT_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); 281 | pub const __LONG_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); 282 | pub const __LONG_LONG_MAX__ = @as(c_longlong, 9223372036854775807); 283 | pub const __WCHAR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); 284 | pub const __WINT_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); 285 | pub const __INTMAX_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); 286 | pub const __SIZE_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); 287 | pub const __UINTMAX_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); 288 | pub const __PTRDIFF_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); 289 | pub const __INTPTR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); 290 | pub const __UINTPTR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); 291 | pub const __SIZEOF_DOUBLE__ = @as(c_int, 8); 292 | pub const __SIZEOF_FLOAT__ = @as(c_int, 4); 293 | pub const __SIZEOF_INT__ = @as(c_int, 4); 294 | pub const __SIZEOF_LONG__ = @as(c_int, 8); 295 | pub const __SIZEOF_LONG_DOUBLE__ = @as(c_int, 16); 296 | pub const __SIZEOF_LONG_LONG__ = @as(c_int, 8); 297 | pub const __SIZEOF_POINTER__ = @as(c_int, 8); 298 | pub const __SIZEOF_SHORT__ = @as(c_int, 2); 299 | pub const __SIZEOF_PTRDIFF_T__ = @as(c_int, 8); 300 | pub const __SIZEOF_SIZE_T__ = @as(c_int, 8); 301 | pub const __SIZEOF_WCHAR_T__ = @as(c_int, 4); 302 | pub const __SIZEOF_WINT_T__ = @as(c_int, 4); 303 | pub const __SIZEOF_INT128__ = @as(c_int, 16); 304 | pub const __INTMAX_TYPE__ = c_long; 305 | pub const __INTMAX_FMTd__ = "ld"; 306 | pub const __INTMAX_FMTi__ = "li"; 307 | pub const __UINTMAX_TYPE__ = c_ulong; 308 | pub const __UINTMAX_FMTo__ = "lo"; 309 | pub const __UINTMAX_FMTu__ = "lu"; 310 | pub const __UINTMAX_FMTx__ = "lx"; 311 | pub const __UINTMAX_FMTX__ = "lX"; 312 | pub const __INTMAX_WIDTH__ = @as(c_int, 64); 313 | pub const __PTRDIFF_TYPE__ = c_long; 314 | pub const __PTRDIFF_FMTd__ = "ld"; 315 | pub const __PTRDIFF_FMTi__ = "li"; 316 | pub const __PTRDIFF_WIDTH__ = @as(c_int, 64); 317 | pub const __INTPTR_TYPE__ = c_long; 318 | pub const __INTPTR_FMTd__ = "ld"; 319 | pub const __INTPTR_FMTi__ = "li"; 320 | pub const __INTPTR_WIDTH__ = @as(c_int, 64); 321 | pub const __SIZE_TYPE__ = c_ulong; 322 | pub const __SIZE_FMTo__ = "lo"; 323 | pub const __SIZE_FMTu__ = "lu"; 324 | pub const __SIZE_FMTx__ = "lx"; 325 | pub const __SIZE_FMTX__ = "lX"; 326 | pub const __SIZE_WIDTH__ = @as(c_int, 64); 327 | pub const __WCHAR_TYPE__ = c_int; 328 | pub const __WCHAR_WIDTH__ = @as(c_int, 32); 329 | pub const __WINT_TYPE__ = c_uint; 330 | pub const __WINT_WIDTH__ = @as(c_int, 32); 331 | pub const __SIG_ATOMIC_WIDTH__ = @as(c_int, 32); 332 | pub const __SIG_ATOMIC_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); 333 | pub const __CHAR16_TYPE__ = c_ushort; 334 | pub const __CHAR32_TYPE__ = c_uint; 335 | pub const __UINTMAX_WIDTH__ = @as(c_int, 64); 336 | pub const __UINTPTR_TYPE__ = c_ulong; 337 | pub const __UINTPTR_FMTo__ = "lo"; 338 | pub const __UINTPTR_FMTu__ = "lu"; 339 | pub const __UINTPTR_FMTx__ = "lx"; 340 | pub const __UINTPTR_FMTX__ = "lX"; 341 | pub const __UINTPTR_WIDTH__ = @as(c_int, 64); 342 | pub const __FLT_DENORM_MIN__ = @as(f32, 1.40129846e-45); 343 | pub const __FLT_HAS_DENORM__ = @as(c_int, 1); 344 | pub const __FLT_DIG__ = @as(c_int, 6); 345 | pub const __FLT_DECIMAL_DIG__ = @as(c_int, 9); 346 | pub const __FLT_EPSILON__ = @as(f32, 1.19209290e-7); 347 | pub const __FLT_HAS_INFINITY__ = @as(c_int, 1); 348 | pub const __FLT_HAS_QUIET_NAN__ = @as(c_int, 1); 349 | pub const __FLT_MANT_DIG__ = @as(c_int, 24); 350 | pub const __FLT_MAX_10_EXP__ = @as(c_int, 38); 351 | pub const __FLT_MAX_EXP__ = @as(c_int, 128); 352 | pub const __FLT_MAX__ = @as(f32, 3.40282347e+38); 353 | pub const __FLT_MIN_10_EXP__ = -@as(c_int, 37); 354 | pub const __FLT_MIN_EXP__ = -@as(c_int, 125); 355 | pub const __FLT_MIN__ = @as(f32, 1.17549435e-38); 356 | pub const __DBL_DENORM_MIN__ = 4.9406564584124654e-324; 357 | pub const __DBL_HAS_DENORM__ = @as(c_int, 1); 358 | pub const __DBL_DIG__ = @as(c_int, 15); 359 | pub const __DBL_DECIMAL_DIG__ = @as(c_int, 17); 360 | pub const __DBL_EPSILON__ = 2.2204460492503131e-16; 361 | pub const __DBL_HAS_INFINITY__ = @as(c_int, 1); 362 | pub const __DBL_HAS_QUIET_NAN__ = @as(c_int, 1); 363 | pub const __DBL_MANT_DIG__ = @as(c_int, 53); 364 | pub const __DBL_MAX_10_EXP__ = @as(c_int, 308); 365 | pub const __DBL_MAX_EXP__ = @as(c_int, 1024); 366 | pub const __DBL_MAX__ = 1.7976931348623157e+308; 367 | pub const __DBL_MIN_10_EXP__ = -@as(c_int, 307); 368 | pub const __DBL_MIN_EXP__ = -@as(c_int, 1021); 369 | pub const __DBL_MIN__ = 2.2250738585072014e-308; 370 | pub const __LDBL_DENORM_MIN__ = @as(c_longdouble, 3.64519953188247460253e-4951); 371 | pub const __LDBL_HAS_DENORM__ = @as(c_int, 1); 372 | pub const __LDBL_DIG__ = @as(c_int, 18); 373 | pub const __LDBL_DECIMAL_DIG__ = @as(c_int, 21); 374 | pub const __LDBL_EPSILON__ = @as(c_longdouble, 1.08420217248550443401e-19); 375 | pub const __LDBL_HAS_INFINITY__ = @as(c_int, 1); 376 | pub const __LDBL_HAS_QUIET_NAN__ = @as(c_int, 1); 377 | pub const __LDBL_MANT_DIG__ = @as(c_int, 64); 378 | pub const __LDBL_MAX_10_EXP__ = @as(c_int, 4932); 379 | pub const __LDBL_MAX_EXP__ = @as(c_int, 16384); 380 | pub const __LDBL_MAX__ = @as(c_longdouble, 1.18973149535723176502e+4932); 381 | pub const __LDBL_MIN_10_EXP__ = -@as(c_int, 4931); 382 | pub const __LDBL_MIN_EXP__ = -@as(c_int, 16381); 383 | pub const __LDBL_MIN__ = @as(c_longdouble, 3.36210314311209350626e-4932); 384 | pub const __POINTER_WIDTH__ = @as(c_int, 64); 385 | pub const __BIGGEST_ALIGNMENT__ = @as(c_int, 16); 386 | pub const __WINT_UNSIGNED__ = @as(c_int, 1); 387 | pub const __INT8_TYPE__ = i8; 388 | pub const __INT8_FMTd__ = "hhd"; 389 | pub const __INT8_FMTi__ = "hhi"; 390 | pub const __INT8_C_SUFFIX__ = ""; 391 | pub const __INT16_TYPE__ = c_short; 392 | pub const __INT16_FMTd__ = "hd"; 393 | pub const __INT16_FMTi__ = "hi"; 394 | pub const __INT16_C_SUFFIX__ = ""; 395 | pub const __INT32_TYPE__ = c_int; 396 | pub const __INT32_FMTd__ = "d"; 397 | pub const __INT32_FMTi__ = "i"; 398 | pub const __INT32_C_SUFFIX__ = ""; 399 | pub const __INT64_TYPE__ = c_long; 400 | pub const __INT64_FMTd__ = "ld"; 401 | pub const __INT64_FMTi__ = "li"; 402 | pub const __UINT8_TYPE__ = u8; 403 | pub const __UINT8_FMTo__ = "hho"; 404 | pub const __UINT8_FMTu__ = "hhu"; 405 | pub const __UINT8_FMTx__ = "hhx"; 406 | pub const __UINT8_FMTX__ = "hhX"; 407 | pub const __UINT8_C_SUFFIX__ = ""; 408 | pub const __UINT8_MAX__ = @as(c_int, 255); 409 | pub const __INT8_MAX__ = @as(c_int, 127); 410 | pub const __UINT16_TYPE__ = c_ushort; 411 | pub const __UINT16_FMTo__ = "ho"; 412 | pub const __UINT16_FMTu__ = "hu"; 413 | pub const __UINT16_FMTx__ = "hx"; 414 | pub const __UINT16_FMTX__ = "hX"; 415 | pub const __UINT16_C_SUFFIX__ = ""; 416 | pub const __UINT16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal); 417 | pub const __INT16_MAX__ = @as(c_int, 32767); 418 | pub const __UINT32_TYPE__ = c_uint; 419 | pub const __UINT32_FMTo__ = "o"; 420 | pub const __UINT32_FMTu__ = "u"; 421 | pub const __UINT32_FMTx__ = "x"; 422 | pub const __UINT32_FMTX__ = "X"; 423 | pub const __UINT32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); 424 | pub const __INT32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); 425 | pub const __UINT64_TYPE__ = c_ulong; 426 | pub const __UINT64_FMTo__ = "lo"; 427 | pub const __UINT64_FMTu__ = "lu"; 428 | pub const __UINT64_FMTx__ = "lx"; 429 | pub const __UINT64_FMTX__ = "lX"; 430 | pub const __UINT64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); 431 | pub const __INT64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); 432 | pub const __INT_LEAST8_TYPE__ = i8; 433 | pub const __INT_LEAST8_MAX__ = @as(c_int, 127); 434 | pub const __INT_LEAST8_FMTd__ = "hhd"; 435 | pub const __INT_LEAST8_FMTi__ = "hhi"; 436 | pub const __UINT_LEAST8_TYPE__ = u8; 437 | pub const __UINT_LEAST8_MAX__ = @as(c_int, 255); 438 | pub const __UINT_LEAST8_FMTo__ = "hho"; 439 | pub const __UINT_LEAST8_FMTu__ = "hhu"; 440 | pub const __UINT_LEAST8_FMTx__ = "hhx"; 441 | pub const __UINT_LEAST8_FMTX__ = "hhX"; 442 | pub const __INT_LEAST16_TYPE__ = c_short; 443 | pub const __INT_LEAST16_MAX__ = @as(c_int, 32767); 444 | pub const __INT_LEAST16_FMTd__ = "hd"; 445 | pub const __INT_LEAST16_FMTi__ = "hi"; 446 | pub const __UINT_LEAST16_TYPE__ = c_ushort; 447 | pub const __UINT_LEAST16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal); 448 | pub const __UINT_LEAST16_FMTo__ = "ho"; 449 | pub const __UINT_LEAST16_FMTu__ = "hu"; 450 | pub const __UINT_LEAST16_FMTx__ = "hx"; 451 | pub const __UINT_LEAST16_FMTX__ = "hX"; 452 | pub const __INT_LEAST32_TYPE__ = c_int; 453 | pub const __INT_LEAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); 454 | pub const __INT_LEAST32_FMTd__ = "d"; 455 | pub const __INT_LEAST32_FMTi__ = "i"; 456 | pub const __UINT_LEAST32_TYPE__ = c_uint; 457 | pub const __UINT_LEAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); 458 | pub const __UINT_LEAST32_FMTo__ = "o"; 459 | pub const __UINT_LEAST32_FMTu__ = "u"; 460 | pub const __UINT_LEAST32_FMTx__ = "x"; 461 | pub const __UINT_LEAST32_FMTX__ = "X"; 462 | pub const __INT_LEAST64_TYPE__ = c_long; 463 | pub const __INT_LEAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); 464 | pub const __INT_LEAST64_FMTd__ = "ld"; 465 | pub const __INT_LEAST64_FMTi__ = "li"; 466 | pub const __UINT_LEAST64_TYPE__ = c_ulong; 467 | pub const __UINT_LEAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); 468 | pub const __UINT_LEAST64_FMTo__ = "lo"; 469 | pub const __UINT_LEAST64_FMTu__ = "lu"; 470 | pub const __UINT_LEAST64_FMTx__ = "lx"; 471 | pub const __UINT_LEAST64_FMTX__ = "lX"; 472 | pub const __INT_FAST8_TYPE__ = i8; 473 | pub const __INT_FAST8_MAX__ = @as(c_int, 127); 474 | pub const __INT_FAST8_FMTd__ = "hhd"; 475 | pub const __INT_FAST8_FMTi__ = "hhi"; 476 | pub const __UINT_FAST8_TYPE__ = u8; 477 | pub const __UINT_FAST8_MAX__ = @as(c_int, 255); 478 | pub const __UINT_FAST8_FMTo__ = "hho"; 479 | pub const __UINT_FAST8_FMTu__ = "hhu"; 480 | pub const __UINT_FAST8_FMTx__ = "hhx"; 481 | pub const __UINT_FAST8_FMTX__ = "hhX"; 482 | pub const __INT_FAST16_TYPE__ = c_short; 483 | pub const __INT_FAST16_MAX__ = @as(c_int, 32767); 484 | pub const __INT_FAST16_FMTd__ = "hd"; 485 | pub const __INT_FAST16_FMTi__ = "hi"; 486 | pub const __UINT_FAST16_TYPE__ = c_ushort; 487 | pub const __UINT_FAST16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal); 488 | pub const __UINT_FAST16_FMTo__ = "ho"; 489 | pub const __UINT_FAST16_FMTu__ = "hu"; 490 | pub const __UINT_FAST16_FMTx__ = "hx"; 491 | pub const __UINT_FAST16_FMTX__ = "hX"; 492 | pub const __INT_FAST32_TYPE__ = c_int; 493 | pub const __INT_FAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); 494 | pub const __INT_FAST32_FMTd__ = "d"; 495 | pub const __INT_FAST32_FMTi__ = "i"; 496 | pub const __UINT_FAST32_TYPE__ = c_uint; 497 | pub const __UINT_FAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); 498 | pub const __UINT_FAST32_FMTo__ = "o"; 499 | pub const __UINT_FAST32_FMTu__ = "u"; 500 | pub const __UINT_FAST32_FMTx__ = "x"; 501 | pub const __UINT_FAST32_FMTX__ = "X"; 502 | pub const __INT_FAST64_TYPE__ = c_long; 503 | pub const __INT_FAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); 504 | pub const __INT_FAST64_FMTd__ = "ld"; 505 | pub const __INT_FAST64_FMTi__ = "li"; 506 | pub const __UINT_FAST64_TYPE__ = c_ulong; 507 | pub const __UINT_FAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); 508 | pub const __UINT_FAST64_FMTo__ = "lo"; 509 | pub const __UINT_FAST64_FMTu__ = "lu"; 510 | pub const __UINT_FAST64_FMTx__ = "lx"; 511 | pub const __UINT_FAST64_FMTX__ = "lX"; 512 | pub const __USER_LABEL_PREFIX__ = ""; 513 | pub const __FINITE_MATH_ONLY__ = @as(c_int, 0); 514 | pub const __GNUC_STDC_INLINE__ = @as(c_int, 1); 515 | pub const __GCC_ATOMIC_TEST_AND_SET_TRUEVAL = @as(c_int, 1); 516 | pub const __CLANG_ATOMIC_BOOL_LOCK_FREE = @as(c_int, 2); 517 | pub const __CLANG_ATOMIC_CHAR_LOCK_FREE = @as(c_int, 2); 518 | pub const __CLANG_ATOMIC_CHAR16_T_LOCK_FREE = @as(c_int, 2); 519 | pub const __CLANG_ATOMIC_CHAR32_T_LOCK_FREE = @as(c_int, 2); 520 | pub const __CLANG_ATOMIC_WCHAR_T_LOCK_FREE = @as(c_int, 2); 521 | pub const __CLANG_ATOMIC_SHORT_LOCK_FREE = @as(c_int, 2); 522 | pub const __CLANG_ATOMIC_INT_LOCK_FREE = @as(c_int, 2); 523 | pub const __CLANG_ATOMIC_LONG_LOCK_FREE = @as(c_int, 2); 524 | pub const __CLANG_ATOMIC_LLONG_LOCK_FREE = @as(c_int, 2); 525 | pub const __CLANG_ATOMIC_POINTER_LOCK_FREE = @as(c_int, 2); 526 | pub const __GCC_ATOMIC_BOOL_LOCK_FREE = @as(c_int, 2); 527 | pub const __GCC_ATOMIC_CHAR_LOCK_FREE = @as(c_int, 2); 528 | pub const __GCC_ATOMIC_CHAR16_T_LOCK_FREE = @as(c_int, 2); 529 | pub const __GCC_ATOMIC_CHAR32_T_LOCK_FREE = @as(c_int, 2); 530 | pub const __GCC_ATOMIC_WCHAR_T_LOCK_FREE = @as(c_int, 2); 531 | pub const __GCC_ATOMIC_SHORT_LOCK_FREE = @as(c_int, 2); 532 | pub const __GCC_ATOMIC_INT_LOCK_FREE = @as(c_int, 2); 533 | pub const __GCC_ATOMIC_LONG_LOCK_FREE = @as(c_int, 2); 534 | pub const __GCC_ATOMIC_LLONG_LOCK_FREE = @as(c_int, 2); 535 | pub const __GCC_ATOMIC_POINTER_LOCK_FREE = @as(c_int, 2); 536 | pub const __PIC__ = @as(c_int, 2); 537 | pub const __pic__ = @as(c_int, 2); 538 | pub const __FLT_EVAL_METHOD__ = @as(c_int, 0); 539 | pub const __FLT_RADIX__ = @as(c_int, 2); 540 | pub const __DECIMAL_DIG__ = __LDBL_DECIMAL_DIG__; 541 | pub const __SSP_STRONG__ = @as(c_int, 2); 542 | pub const __GCC_ASM_FLAG_OUTPUTS__ = @as(c_int, 1); 543 | pub const __code_model_small__ = @as(c_int, 1); 544 | pub const __amd64__ = @as(c_int, 1); 545 | pub const __amd64 = @as(c_int, 1); 546 | pub const __x86_64 = @as(c_int, 1); 547 | pub const __x86_64__ = @as(c_int, 1); 548 | pub const __SEG_GS = @as(c_int, 1); 549 | pub const __SEG_FS = @as(c_int, 1); 550 | pub const __znver2 = @as(c_int, 1); 551 | pub const __znver2__ = @as(c_int, 1); 552 | pub const __tune_znver2__ = @as(c_int, 1); 553 | pub const __REGISTER_PREFIX__ = ""; 554 | pub const __NO_MATH_INLINES = @as(c_int, 1); 555 | pub const __AES__ = @as(c_int, 1); 556 | pub const __PCLMUL__ = @as(c_int, 1); 557 | pub const __LAHF_SAHF__ = @as(c_int, 1); 558 | pub const __LZCNT__ = @as(c_int, 1); 559 | pub const __RDRND__ = @as(c_int, 1); 560 | pub const __FSGSBASE__ = @as(c_int, 1); 561 | pub const __BMI__ = @as(c_int, 1); 562 | pub const __BMI2__ = @as(c_int, 1); 563 | pub const __POPCNT__ = @as(c_int, 1); 564 | pub const __PRFCHW__ = @as(c_int, 1); 565 | pub const __RDSEED__ = @as(c_int, 1); 566 | pub const __ADX__ = @as(c_int, 1); 567 | pub const __MWAITX__ = @as(c_int, 1); 568 | pub const __MOVBE__ = @as(c_int, 1); 569 | pub const __SSE4A__ = @as(c_int, 1); 570 | pub const __FMA__ = @as(c_int, 1); 571 | pub const __F16C__ = @as(c_int, 1); 572 | pub const __SHA__ = @as(c_int, 1); 573 | pub const __FXSR__ = @as(c_int, 1); 574 | pub const __XSAVE__ = @as(c_int, 1); 575 | pub const __XSAVEOPT__ = @as(c_int, 1); 576 | pub const __XSAVEC__ = @as(c_int, 1); 577 | pub const __XSAVES__ = @as(c_int, 1); 578 | pub const __CLFLUSHOPT__ = @as(c_int, 1); 579 | pub const __CLWB__ = @as(c_int, 1); 580 | pub const __WBNOINVD__ = @as(c_int, 1); 581 | pub const __CLZERO__ = @as(c_int, 1); 582 | pub const __RDPID__ = @as(c_int, 1); 583 | pub const __AVX2__ = @as(c_int, 1); 584 | pub const __AVX__ = @as(c_int, 1); 585 | pub const __SSE4_2__ = @as(c_int, 1); 586 | pub const __SSE4_1__ = @as(c_int, 1); 587 | pub const __SSSE3__ = @as(c_int, 1); 588 | pub const __SSE3__ = @as(c_int, 1); 589 | pub const __SSE2__ = @as(c_int, 1); 590 | pub const __SSE2_MATH__ = @as(c_int, 1); 591 | pub const __SSE__ = @as(c_int, 1); 592 | pub const __SSE_MATH__ = @as(c_int, 1); 593 | pub const __MMX__ = @as(c_int, 1); 594 | pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 = @as(c_int, 1); 595 | pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 = @as(c_int, 1); 596 | pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 = @as(c_int, 1); 597 | pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 = @as(c_int, 1); 598 | pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 = @as(c_int, 1); 599 | pub const __SIZEOF_FLOAT128__ = @as(c_int, 16); 600 | pub const unix = @as(c_int, 1); 601 | pub const __unix = @as(c_int, 1); 602 | pub const __unix__ = @as(c_int, 1); 603 | pub const linux = @as(c_int, 1); 604 | pub const __linux = @as(c_int, 1); 605 | pub const __linux__ = @as(c_int, 1); 606 | pub const __ELF__ = @as(c_int, 1); 607 | pub const __gnu_linux__ = @as(c_int, 1); 608 | pub const __FLOAT128__ = @as(c_int, 1); 609 | pub const __STDC__ = @as(c_int, 1); 610 | pub const __STDC_HOSTED__ = @as(c_int, 1); 611 | pub const __STDC_VERSION__ = @as(c_long, 201710); 612 | pub const __STDC_UTF_16__ = @as(c_int, 1); 613 | pub const __STDC_UTF_32__ = @as(c_int, 1); 614 | pub const __GLIBC_MINOR__ = @as(c_int, 19); 615 | pub const _DEBUG = @as(c_int, 1); 616 | pub const __GCC_HAVE_DWARF2_CFI_ASM = @as(c_int, 1); 617 | pub const _TIME_H = @as(c_int, 1); 618 | pub const _FEATURES_H = @as(c_int, 1); 619 | pub const __KERNEL_STRICT_NAMES = ""; 620 | pub inline fn __GNUC_PREREQ(maj: anytype, min: anytype) @TypeOf(((__GNUC__ << @as(c_int, 16)) + __GNUC_MINOR__) >= ((maj << @as(c_int, 16)) + min)) { 621 | return ((__GNUC__ << @as(c_int, 16)) + __GNUC_MINOR__) >= ((maj << @as(c_int, 16)) + min); 622 | } 623 | pub inline fn __glibc_clang_prereq(maj: anytype, min: anytype) @TypeOf(((__clang_major__ << @as(c_int, 16)) + __clang_minor__) >= ((maj << @as(c_int, 16)) + min)) { 624 | return ((__clang_major__ << @as(c_int, 16)) + __clang_minor__) >= ((maj << @as(c_int, 16)) + min); 625 | } 626 | pub const _DEFAULT_SOURCE = @as(c_int, 1); 627 | pub const __GLIBC_USE_ISOC2X = @as(c_int, 0); 628 | pub const __USE_ISOC11 = @as(c_int, 1); 629 | pub const __USE_ISOC99 = @as(c_int, 1); 630 | pub const __USE_ISOC95 = @as(c_int, 1); 631 | pub const __USE_POSIX_IMPLICITLY = @as(c_int, 1); 632 | pub const _POSIX_SOURCE = @as(c_int, 1); 633 | pub const _POSIX_C_SOURCE = @as(c_long, 200809); 634 | pub const __USE_POSIX = @as(c_int, 1); 635 | pub const __USE_POSIX2 = @as(c_int, 1); 636 | pub const __USE_POSIX199309 = @as(c_int, 1); 637 | pub const __USE_POSIX199506 = @as(c_int, 1); 638 | pub const __USE_XOPEN2K = @as(c_int, 1); 639 | pub const __USE_XOPEN2K8 = @as(c_int, 1); 640 | pub const _ATFILE_SOURCE = @as(c_int, 1); 641 | pub const __WORDSIZE = @as(c_int, 64); 642 | pub const __WORDSIZE_TIME64_COMPAT32 = @as(c_int, 1); 643 | pub const __SYSCALL_WORDSIZE = @as(c_int, 64); 644 | pub const __TIMESIZE = __WORDSIZE; 645 | pub const __USE_MISC = @as(c_int, 1); 646 | pub const __USE_ATFILE = @as(c_int, 1); 647 | pub const __USE_FORTIFY_LEVEL = @as(c_int, 0); 648 | pub const __GLIBC_USE_DEPRECATED_GETS = @as(c_int, 0); 649 | pub const __GLIBC_USE_DEPRECATED_SCANF = @as(c_int, 0); 650 | pub const _STDC_PREDEF_H = @as(c_int, 1); 651 | pub const __STDC_IEC_559__ = @as(c_int, 1); 652 | pub const __STDC_IEC_559_COMPLEX__ = @as(c_int, 1); 653 | pub const __STDC_ISO_10646__ = @as(c_long, 201706); 654 | pub const __GNU_LIBRARY__ = @as(c_int, 6); 655 | pub const __GLIBC__ = @as(c_int, 2); 656 | pub inline fn __GLIBC_PREREQ(maj: anytype, min: anytype) @TypeOf(((__GLIBC__ << @as(c_int, 16)) + __GLIBC_MINOR__) >= ((maj << @as(c_int, 16)) + min)) { 657 | return ((__GLIBC__ << @as(c_int, 16)) + __GLIBC_MINOR__) >= ((maj << @as(c_int, 16)) + min); 658 | } 659 | pub const _SYS_CDEFS_H = @as(c_int, 1); 660 | pub const __LEAF = ""; 661 | pub const __LEAF_ATTR = ""; 662 | pub inline fn __P(args: anytype) @TypeOf(args) { 663 | return args; 664 | } 665 | pub inline fn __PMT(args: anytype) @TypeOf(args) { 666 | return args; 667 | } 668 | pub const __ptr_t = ?*anyopaque; 669 | pub const __BEGIN_DECLS = ""; 670 | pub const __END_DECLS = ""; 671 | pub inline fn __bos(ptr: anytype) @TypeOf(__builtin_object_size(ptr, __USE_FORTIFY_LEVEL > @as(c_int, 1))) { 672 | return __builtin_object_size(ptr, __USE_FORTIFY_LEVEL > @as(c_int, 1)); 673 | } 674 | pub inline fn __bos0(ptr: anytype) @TypeOf(__builtin_object_size(ptr, @as(c_int, 0))) { 675 | return __builtin_object_size(ptr, @as(c_int, 0)); 676 | } 677 | pub inline fn __glibc_objsize0(__o: anytype) @TypeOf(__bos0(__o)) { 678 | return __bos0(__o); 679 | } 680 | pub inline fn __glibc_objsize(__o: anytype) @TypeOf(__bos(__o)) { 681 | return __bos(__o); 682 | } 683 | pub const __glibc_c99_flexarr_available = @as(c_int, 1); 684 | pub inline fn __ASMNAME(cname: anytype) @TypeOf(__ASMNAME2(__USER_LABEL_PREFIX__, cname)) { 685 | return __ASMNAME2(__USER_LABEL_PREFIX__, cname); 686 | } 687 | pub const __wur = ""; 688 | pub const __fortify_function = __extern_always_inline ++ __attribute_artificial__; 689 | pub inline fn __glibc_unlikely(cond: anytype) @TypeOf(__builtin_expect(cond, @as(c_int, 0))) { 690 | return __builtin_expect(cond, @as(c_int, 0)); 691 | } 692 | pub inline fn __glibc_likely(cond: anytype) @TypeOf(__builtin_expect(cond, @as(c_int, 1))) { 693 | return __builtin_expect(cond, @as(c_int, 1)); 694 | } 695 | pub const __attribute_nonstring__ = ""; 696 | pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = @as(c_int, 0); 697 | pub inline fn __LDBL_REDIR1(name: anytype, proto: anytype, alias: anytype) @TypeOf(name ++ proto) { 698 | _ = alias; 699 | return name ++ proto; 700 | } 701 | pub inline fn __LDBL_REDIR(name: anytype, proto: anytype) @TypeOf(name ++ proto) { 702 | return name ++ proto; 703 | } 704 | pub inline fn __LDBL_REDIR1_NTH(name: anytype, proto: anytype, alias: anytype) @TypeOf(name ++ proto ++ __THROW) { 705 | _ = alias; 706 | return name ++ proto ++ __THROW; 707 | } 708 | pub inline fn __LDBL_REDIR_NTH(name: anytype, proto: anytype) @TypeOf(name ++ proto ++ __THROW) { 709 | return name ++ proto ++ __THROW; 710 | } 711 | pub inline fn __REDIRECT_LDBL(name: anytype, proto: anytype, alias: anytype) @TypeOf(__REDIRECT(name, proto, alias)) { 712 | return __REDIRECT(name, proto, alias); 713 | } 714 | pub inline fn __REDIRECT_NTH_LDBL(name: anytype, proto: anytype, alias: anytype) @TypeOf(__REDIRECT_NTH(name, proto, alias)) { 715 | return __REDIRECT_NTH(name, proto, alias); 716 | } 717 | pub const __HAVE_GENERIC_SELECTION = @as(c_int, 1); 718 | pub const __attr_dealloc_free = ""; 719 | pub const __USE_EXTERN_INLINES = @as(c_int, 1); 720 | pub const __stub___compat_bdflush = ""; 721 | pub const __stub_chflags = ""; 722 | pub const __stub_fchflags = ""; 723 | pub const __stub_gtty = ""; 724 | pub const __stub_revoke = ""; 725 | pub const __stub_setlogin = ""; 726 | pub const __stub_sigreturn = ""; 727 | pub const __stub_stty = ""; 728 | pub const __need_size_t = ""; 729 | pub const __need_NULL = ""; 730 | pub const _SIZE_T = ""; 731 | pub const NULL = @import("std").zig.c_translation.cast(?*anyopaque, @as(c_int, 0)); 732 | pub const _BITS_TIME_H = @as(c_int, 1); 733 | pub const _BITS_TYPES_H = @as(c_int, 1); 734 | pub const __S16_TYPE = c_short; 735 | pub const __U16_TYPE = c_ushort; 736 | pub const __S32_TYPE = c_int; 737 | pub const __U32_TYPE = c_uint; 738 | pub const __SLONGWORD_TYPE = c_long; 739 | pub const __ULONGWORD_TYPE = c_ulong; 740 | pub const __SQUAD_TYPE = c_long; 741 | pub const __UQUAD_TYPE = c_ulong; 742 | pub const __SWORD_TYPE = c_long; 743 | pub const __UWORD_TYPE = c_ulong; 744 | pub const __SLONG32_TYPE = c_int; 745 | pub const __ULONG32_TYPE = c_uint; 746 | pub const __S64_TYPE = c_long; 747 | pub const __U64_TYPE = c_ulong; 748 | pub const _BITS_TYPESIZES_H = @as(c_int, 1); 749 | pub const __SYSCALL_SLONG_TYPE = __SLONGWORD_TYPE; 750 | pub const __SYSCALL_ULONG_TYPE = __ULONGWORD_TYPE; 751 | pub const __DEV_T_TYPE = __UQUAD_TYPE; 752 | pub const __UID_T_TYPE = __U32_TYPE; 753 | pub const __GID_T_TYPE = __U32_TYPE; 754 | pub const __INO_T_TYPE = __SYSCALL_ULONG_TYPE; 755 | pub const __INO64_T_TYPE = __UQUAD_TYPE; 756 | pub const __MODE_T_TYPE = __U32_TYPE; 757 | pub const __NLINK_T_TYPE = __SYSCALL_ULONG_TYPE; 758 | pub const __FSWORD_T_TYPE = __SYSCALL_SLONG_TYPE; 759 | pub const __OFF_T_TYPE = __SYSCALL_SLONG_TYPE; 760 | pub const __OFF64_T_TYPE = __SQUAD_TYPE; 761 | pub const __PID_T_TYPE = __S32_TYPE; 762 | pub const __RLIM_T_TYPE = __SYSCALL_ULONG_TYPE; 763 | pub const __RLIM64_T_TYPE = __UQUAD_TYPE; 764 | pub const __BLKCNT_T_TYPE = __SYSCALL_SLONG_TYPE; 765 | pub const __BLKCNT64_T_TYPE = __SQUAD_TYPE; 766 | pub const __FSBLKCNT_T_TYPE = __SYSCALL_ULONG_TYPE; 767 | pub const __FSBLKCNT64_T_TYPE = __UQUAD_TYPE; 768 | pub const __FSFILCNT_T_TYPE = __SYSCALL_ULONG_TYPE; 769 | pub const __FSFILCNT64_T_TYPE = __UQUAD_TYPE; 770 | pub const __ID_T_TYPE = __U32_TYPE; 771 | pub const __CLOCK_T_TYPE = __SYSCALL_SLONG_TYPE; 772 | pub const __TIME_T_TYPE = __SYSCALL_SLONG_TYPE; 773 | pub const __USECONDS_T_TYPE = __U32_TYPE; 774 | pub const __SUSECONDS_T_TYPE = __SYSCALL_SLONG_TYPE; 775 | pub const __SUSECONDS64_T_TYPE = __SQUAD_TYPE; 776 | pub const __DADDR_T_TYPE = __S32_TYPE; 777 | pub const __KEY_T_TYPE = __S32_TYPE; 778 | pub const __CLOCKID_T_TYPE = __S32_TYPE; 779 | pub const __TIMER_T_TYPE = ?*anyopaque; 780 | pub const __BLKSIZE_T_TYPE = __SYSCALL_SLONG_TYPE; 781 | pub const __SSIZE_T_TYPE = __SWORD_TYPE; 782 | pub const __CPU_MASK_TYPE = __SYSCALL_ULONG_TYPE; 783 | pub const __OFF_T_MATCHES_OFF64_T = @as(c_int, 1); 784 | pub const __INO_T_MATCHES_INO64_T = @as(c_int, 1); 785 | pub const __RLIM_T_MATCHES_RLIM64_T = @as(c_int, 1); 786 | pub const __STATFS_MATCHES_STATFS64 = @as(c_int, 1); 787 | pub const __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = @as(c_int, 1); 788 | pub const __FD_SETSIZE = @as(c_int, 1024); 789 | pub const _BITS_TIME64_H = @as(c_int, 1); 790 | pub const __TIME64_T_TYPE = __TIME_T_TYPE; 791 | pub const CLOCKS_PER_SEC = @import("std").zig.c_translation.cast(__clock_t, @import("std").zig.c_translation.promoteIntLiteral(c_int, 1000000, .decimal)); 792 | pub const CLOCK_REALTIME = @as(c_int, 0); 793 | pub const CLOCK_MONOTONIC = @as(c_int, 1); 794 | pub const CLOCK_PROCESS_CPUTIME_ID = @as(c_int, 2); 795 | pub const CLOCK_THREAD_CPUTIME_ID = @as(c_int, 3); 796 | pub const CLOCK_MONOTONIC_RAW = @as(c_int, 4); 797 | pub const CLOCK_REALTIME_COARSE = @as(c_int, 5); 798 | pub const CLOCK_MONOTONIC_COARSE = @as(c_int, 6); 799 | pub const CLOCK_BOOTTIME = @as(c_int, 7); 800 | pub const CLOCK_REALTIME_ALARM = @as(c_int, 8); 801 | pub const CLOCK_BOOTTIME_ALARM = @as(c_int, 9); 802 | pub const CLOCK_TAI = @as(c_int, 11); 803 | pub const TIMER_ABSTIME = @as(c_int, 1); 804 | pub const __clock_t_defined = @as(c_int, 1); 805 | pub const __time_t_defined = @as(c_int, 1); 806 | pub const __struct_tm_defined = @as(c_int, 1); 807 | pub const _STRUCT_TIMESPEC = @as(c_int, 1); 808 | pub const _BITS_ENDIAN_H = @as(c_int, 1); 809 | pub const __LITTLE_ENDIAN = @as(c_int, 1234); 810 | pub const __BIG_ENDIAN = @as(c_int, 4321); 811 | pub const __PDP_ENDIAN = @as(c_int, 3412); 812 | pub const _BITS_ENDIANNESS_H = @as(c_int, 1); 813 | pub const __BYTE_ORDER = __LITTLE_ENDIAN; 814 | pub const __FLOAT_WORD_ORDER = __BYTE_ORDER; 815 | pub inline fn __LONG_LONG_PAIR(HI: anytype, LO: anytype) @TypeOf(HI) { 816 | return blk: { 817 | _ = LO; 818 | break :blk HI; 819 | }; 820 | } 821 | pub const __clockid_t_defined = @as(c_int, 1); 822 | pub const __timer_t_defined = @as(c_int, 1); 823 | pub const __itimerspec_defined = @as(c_int, 1); 824 | pub const __pid_t_defined = ""; 825 | pub const _BITS_TYPES_LOCALE_T_H = @as(c_int, 1); 826 | pub const _BITS_TYPES___LOCALE_T_H = @as(c_int, 1); 827 | pub const TIME_UTC = @as(c_int, 1); 828 | pub inline fn __isleap(year: anytype) @TypeOf(((year % @as(c_int, 4)) == @as(c_int, 0)) and (((year % @as(c_int, 100)) != @as(c_int, 0)) or ((year % @as(c_int, 400)) == @as(c_int, 0)))) { 829 | return ((year % @as(c_int, 4)) == @as(c_int, 0)) and (((year % @as(c_int, 100)) != @as(c_int, 0)) or ((year % @as(c_int, 400)) == @as(c_int, 0))); 830 | } 831 | pub const tm = struct_tm; 832 | pub const timespec = struct_timespec; 833 | pub const itimerspec = struct_itimerspec; 834 | pub const sigevent = struct_sigevent; 835 | pub const __locale_data = struct___locale_data; 836 | pub const __locale_struct = struct___locale_struct; 837 | --------------------------------------------------------------------------------