Alexis Brodeur
98dd041d53
Relax std.sort.binarySearch requirements
...
Forcing the key to be of the same type as the sorted items used during
the search is a valid use case.
There, however, exists some cases where the key and the items are of
heterogeneous types, like searching for a code point in ordered ranges
of code points:
```zig
const CodePoint = u21;
const CodePointRange = [2]CodePoint;
const valid_ranges = &[_]CodePointRange{
// an ordered array of ranges
};
fn orderCodePointAndRange(
context: void,
code_point: CodePoint,
range: CodePointRange
) std.math.Order {
_ = context;
if (code_point < range[0]) {
return .lt;
}
if (code_point > range[1]) {
return .gt;
}
return .eq;
}
fn isValidCodePoint(code_point: CodePoint) bool {
return std.sort.binarySearch(
CodePointRange,
code_point,
valid_ranges,
void,
orderCodePointAndRange
) != null;
}
```
It is so expected that `std.sort.binarySearch` should therefore support
both homogeneous and heterogeneous keys.
2023-02-21 12:28:43 -05:00
..
2023-02-18 19:17:21 -07:00
2023-02-21 01:59:37 +00:00
2023-01-28 19:05:38 -05:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:20:19 -07:00
2022-05-09 18:51:46 +02:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-19 09:40:55 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-01-17 01:44:56 -05:00
2023-01-29 15:07:06 -05:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-15 01:43:57 +02:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2022-11-29 23:30:38 -07:00
2023-02-18 19:17:21 -07:00
2021-12-16 19:08:58 -08:00
2022-01-01 12:47:08 +00:00
2022-12-13 13:14:20 +02:00
2022-08-22 13:55:00 +03:00
2023-02-19 10:10:59 -05:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2022-11-04 00:09:27 +03:30
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2022-05-11 18:41:23 -06:00
2022-03-01 13:28:47 -05:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-14 02:17:33 +02:00
2023-02-21 12:26:55 -05:00
2023-02-18 19:17:21 -07:00
2023-02-05 06:52:28 -08:00
2023-02-18 19:17:21 -07:00
2023-02-16 21:18:20 +01:00
2023-01-29 15:07:06 -05:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2022-12-13 13:14:20 +02:00
2022-11-18 19:22:42 +00:00
2023-02-18 19:17:21 -07:00
2021-09-01 17:54:06 -07:00
2021-11-30 23:32:47 +00:00
2023-02-18 19:17:21 -07:00
2023-02-15 01:43:57 +02:00
2023-02-18 19:17:21 -07:00
2022-01-07 00:06:06 -05:00
2023-02-18 19:17:21 -07:00
2023-01-05 19:57:00 -07:00
2023-01-11 15:39:48 -08:00
2023-01-11 15:39:48 -08:00
2023-02-18 19:17:21 -07:00
2022-12-27 15:13:14 +02:00
2022-09-11 23:18:43 -04:00
2023-01-05 02:31:29 -07:00
2023-01-21 13:18:14 +01:00
2023-01-03 13:30:24 +02:00
2023-02-20 13:55:45 -05:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 11:49:15 -07:00
2023-02-19 10:10:59 -05:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2022-12-13 09:11:30 +01:00
2023-02-18 19:17:21 -07:00
2022-12-10 12:33:17 +01:00
2022-12-09 21:57:17 +01:00
2023-02-18 19:17:21 -07:00
2023-02-21 12:28:43 -05:00
2023-01-29 15:04:13 -05:00
2023-02-17 09:08:41 -07:00
2023-02-18 11:49:15 -07:00
2023-02-01 18:42:29 -07:00
2023-02-18 19:17:21 -07:00
2023-02-18 19:17:21 -07:00
2023-01-29 15:07:06 -05:00
2022-11-02 23:20:19 +01:00
2022-04-15 17:01:01 -05:00
2022-06-17 21:04:21 +03:00
2022-12-06 20:38:54 -07:00
2023-01-06 18:52:39 -07:00
2022-11-19 19:32:45 -07:00
2023-02-18 19:17:21 -07:00
2023-02-03 00:06:11 -07:00