File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
lib/features/sorting/bubble/view_model Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 11import 'package:algorithm_visualizer/features/sorting/base/view_model/sorting_notifier.dart' ;
2+ import 'package:collection/collection.dart' ;
23
34class BubbleSortNotifier extends SortingNotifier {
45 @override
@@ -13,14 +14,13 @@ class BubbleSortNotifier extends SortingNotifier {
1314 steps.add (SortingStep (index1: j, index2: j + 1 , action: SortingStatus .compared)); // external
1415
1516 if (arr[j] > arr[j + 1 ]) {
16- steps.add (SortingStep (index1: j, index2: j + 1 , action: SortingStatus .swiping)); // external
17- final tmp = arr[j];
18- arr[j] = arr[j + 1 ];
19- arr[j + 1 ] = tmp;
17+ steps.add (SortingStep (index1: j, index2: j + 1 , action: SortingStatus .swapping)); // external
18+
19+ arr.swap (j, j + 1 );
2020 isSorted = false ;
2121 }
2222
23- steps.add (SortingStep (index1: j, index2: j + 1 , action: SortingStatus .swiped )); // external
23+ steps.add (SortingStep (index1: j, index2: j + 1 , action: SortingStatus .swapped )); // external
2424 }
2525
2626 steps.add (SortingStep (
You can’t perform that action at this time.
0 commit comments