| author | |
| committer | |
| log | f2c237f7944dfcd72492a1123f5860088c64726c |
| tree | 84d1569bda71b15ccf00bc2e9fd5f4353535ce5e |
| parent | 4474a8e92ad519afefaebeba75dd14e072f05be4 |
2 files changed, 14 insertions(+), 0 deletions(-)
src/compareFnRange.zig created+13| ... | @@ -0,0 +1,13 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const extras = @import("./lib.zig"); | ||
| 3 | |||
| 4 | pub fn compareFnRange(N: type, H: type, lower: std.meta.FieldEnum(H), upper: std.meta.FieldEnum(H)) fn (N, H) std.math.Order { | ||
| 5 | const S = struct { | ||
| 6 | pub fn compare(needle: N, row: H) std.math.Order { | ||
| 7 | if (needle < @field(row, @tagName(lower))) return .lt; | ||
| 8 | if (needle > @field(row, @tagName(upper))) return .gt; | ||
| 9 | return .eq; | ||
| 10 | } | ||
| 11 | }; | ||
| 12 | return S.compare; | ||
| 13 | } | ||
src/lib.zig+1| ... | @@ -116,3 +116,4 @@ pub usingnamespace @import("./swapMany.zig"); | ... | @@ -116,3 +116,4 @@ pub usingnamespace @import("./swapMany.zig"); |
| 116 | pub usingnamespace @import("./ManyArrayList.zig"); | 116 | pub usingnamespace @import("./ManyArrayList.zig"); |
| 117 | pub usingnamespace @import("./compareFnBasic.zig"); | 117 | pub usingnamespace @import("./compareFnBasic.zig"); |
| 118 | pub usingnamespace @import("./compareFnField.zig"); | 118 | pub usingnamespace @import("./compareFnField.zig"); |
| 119 | pub usingnamespace @import("./compareFnRange.zig"); |