Skip to content

Commit 77fbffa

Browse files
cleanup the code
1 parent b7d1dc0 commit 77fbffa

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/features/sorting/selection/view_model/selection_sort_notifier.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:algorithm_visualizer/features/sorting/base/view_model/sorting_notifier.dart';
2+
import 'package:collection/collection.dart';
23

34
class SelectionSortNotifier extends SortingNotifier {
45
@override
@@ -25,12 +26,10 @@ class SelectionSortNotifier extends SortingNotifier {
2526
}
2627

2728
if (minIndex != i) {
28-
steps.add(SortingStep(index1: i, index2: minIndex, action: SortingStatus.swiping));
29+
steps.add(SortingStep(index1: i, index2: minIndex, action: SortingStatus.swapping));
2930

30-
final temp = arr[i];
31-
arr[i] = arr[minIndex];
32-
arr[minIndex] = temp;
33-
steps.add(SortingStep(index1: minIndex, index2: j, action: SortingStatus.swiped));
31+
arr.swap(minIndex, i);
32+
steps.add(SortingStep(index1: minIndex, index2: j, action: SortingStatus.swapped));
3433
}
3534

3635
steps.add(SortingStep(index1: i, index2: i, action: SortingStatus.sorted));

0 commit comments

Comments
 (0)