mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
add basic quicksort support (#816)
* lib/std/sort: refactor binarysearch namespace to prepare for sorting Signed-off-by: Pierre Curto <pierre.curto@gmail.com> * std/lib/sort: add basic quicksort support Signed-off-by: Pierre Curto <pierre.curto@gmail.com> * lib/std/hash: use method first parameter inferred type Signed-off-by: Pierre Curto <pierre.curto@gmail.com> * lib/std/hash: add fnv64a support Signed-off-by: Pierre Curto <pierre.curto@gmail.com> --------- Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
21
lib/std/sort/sort.c3
Normal file
21
lib/std/sort/sort.c3
Normal file
@@ -0,0 +1,21 @@
|
||||
module std::sort;
|
||||
|
||||
macro bool is_searchable(list)
|
||||
{
|
||||
return $checks(list[0]) && ($checks(list.len) || $checks(list.len()));
|
||||
}
|
||||
|
||||
macro usz @len_from_list(&list)
|
||||
{
|
||||
$if $checks(list.len()):
|
||||
return list.len();
|
||||
$else
|
||||
return list.len;
|
||||
$endif
|
||||
}
|
||||
|
||||
macro bool is_comparer(cmp, list)
|
||||
{
|
||||
return $checks(int i = cmp(list[0], list[0]))
|
||||
|| $checks(int i = cmp(&list[0], &list[0]));
|
||||
}
|
||||
Reference in New Issue
Block a user