Skip to content

Commit a34160a

Browse files
reformat the code
1 parent faf3eb6 commit a34160a

File tree

2 files changed

+0
-8
lines changed

2 files changed

+0
-8
lines changed

lib/features/sorting/quick/view_model/quick_sort_notifier.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class QuickSortNotifier extends SortingNotifier {
1212
int i = low - 1;
1313

1414
for (int j = low; j < high; j++) {
15-
// Compare arr[j] with pivot
1615
steps.add(SortingStep(index1: j, index2: high, action: SortingStatus.compared));
1716
steps.add(SortingStep(index1: j, index2: high, action: SortingStatus.unSorted));
1817

@@ -26,7 +25,6 @@ class QuickSortNotifier extends SortingNotifier {
2625
}
2726
}
2827

29-
// Place pivot in correct position
3028
if (i + 1 != high) {
3129
steps.add(SortingStep(index1: i + 1, index2: high, action: SortingStatus.swapping));
3230
arr.swap(i + 1, high);

lib/features/sorting/radix/view_model/radix_sort_notifier.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ class RadixSortNotifier extends SortingNotifier {
1313

1414
int maxVal = arr.reduce((a, b) => a > b ? a : b);
1515

16-
// Perform counting sort for every digit
1716
for (int exp = 1; maxVal ~/ exp > 0; exp *= 10) {
1817
_countingSortByDigit(arr, exp, steps);
1918
}
2019

21-
// Mark all as sorted
2220
steps.add(SortingStep(index1: arr.length - 1, index2: arr.length - 1, action: SortingStatus.sorted));
2321

2422
return SortingResult(sortedValues: arr, steps: steps);
@@ -29,25 +27,21 @@ class RadixSortNotifier extends SortingNotifier {
2927
List<int> output = List<int>.filled(n, 0);
3028
List<int> count = List<int>.filled(10, 0);
3129

32-
// 1. Count occurrences of digits
3330
for (int i = 0; i < n; i++) {
3431
int digit = (arr[i] ~/ exp) % 10;
3532
count[digit]++;
3633
}
3734

38-
// 2. Compute prefix sums
3935
for (int i = 1; i < 10; i++) {
4036
count[i] += count[i - 1];
4137
}
4238

43-
// 3. Build output array (stable order, so go from right to left)
4439
for (int i = n - 1; i >= 0; i--) {
4540
int digit = (arr[i] ~/ exp) % 10;
4641
output[count[digit] - 1] = arr[i];
4742
count[digit]--;
4843
}
4944

50-
// 4. Copy back to arr + log steps
5145
for (int i = 0; i < n; i++) {
5246
if (arr[i] != output[i]) {
5347
int oldIndex = arr.indexOf(output[i], i);

0 commit comments

Comments
 (0)