mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Sorting functions correctly took slices by value, but also other types by value. Now, only slices are accepted by value, other containers are always by ref.
This commit is contained in:
@@ -47,7 +47,7 @@ fn void map()
|
||||
list.push({key, value});
|
||||
};
|
||||
assert(list.len() == tcases.len);
|
||||
quicksort(list, fn int (MapTest a, MapTest b) => (int)(a.value - b.value));
|
||||
quicksort(&list, fn int (MapTest a, MapTest b) => (int)(a.value - b.value));
|
||||
foreach (i, tc : tcases)
|
||||
{
|
||||
assert(tc.key == list[i].key);
|
||||
|
||||
@@ -79,7 +79,7 @@ fn void countingsort_list()
|
||||
{
|
||||
CountingSortTestList list;
|
||||
list.push_all({ 2, 1, 3});
|
||||
sort::countingsort(list, &sort::key_int_value);
|
||||
sort::countingsort(&list, &sort::key_int_value);
|
||||
assert(check::int_ascending_sort(list.array_view()));
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ fn void countingsort_random_large_list()
|
||||
list.push(random.next_int());
|
||||
}
|
||||
|
||||
sort::countingsort(list, &sort::key_int_value);
|
||||
sort::countingsort(&list, &sort::key_int_value);
|
||||
assert(check::int_ascending_sort(list.array_view()));
|
||||
list.free();
|
||||
}
|
||||
@@ -84,7 +84,7 @@ fn void insertionsort_list()
|
||||
{
|
||||
InsertionSortTestList list;
|
||||
list.push_all({ 2, 1, 3});
|
||||
sort::insertionsort(list, &sort::cmp_int_value);
|
||||
sort::insertionsort(&list, &sort::cmp_int_value);
|
||||
assert(check::int_ascending_sort(list.array_view()));
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ fn void quicksort_list()
|
||||
{
|
||||
List2 list;
|
||||
list.push_all({ 2, 1, 3});
|
||||
sort::quicksort(list, &sort::cmp_int_value);
|
||||
sort::quicksort(&list, &sort::cmp_int_value);
|
||||
assert(check::int_sort(list.array_view()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user