Skip to content

Commit 8f8d07d

Browse files
move other notifier for new logic
1 parent 6f8dff5 commit 8f8d07d

File tree

2 files changed

+7
-39
lines changed

2 files changed

+7
-39
lines changed
Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,10 @@
11
import 'package:algorithm_visualizer/features/sorting/base/view_model/sorting_notifier.dart';
2-
import 'package:collection/collection.dart';
3-
import 'package:flutter/material.dart';
42

53
class InsertionSortNotifier extends SortingNotifier {
6-
@override
7-
Future<void> buildSort() async {
8-
final list = List<SortableItem>.from(state.list);
9-
10-
for (int i = 1; i < list.length; i++) {
11-
if (operation != SortingEnum.played) return;
12-
13-
SortableItem keyItem = list[i];
14-
int j = i - 1;
15-
16-
while (j >= 0 && list[j].value > keyItem.value) {
17-
if (operation != SortingEnum.played) return;
18-
19-
list[j] = list[j].copyWith(sortedStatus: SortingStatus.compared);
20-
list[j + 1] = list[j + 1].copyWith(sortedStatus: SortingStatus.compared);
21-
state = state.copyWith(list: list);
22-
await Future.delayed(speedDuration);
234

24-
list.swap(j, j + 1);
25-
26-
final positions = Map<int, Offset>.from(state.positions);
27-
final temp = positions[list[j].id]!;
28-
positions[list[j].id] = positions[list[j + 1].id]!;
29-
positions[list[j + 1].id] = temp;
30-
31-
state = state.copyWith(list: list, positions: positions);
32-
await Future.delayed(speedDuration);
33-
34-
list[j] = list[j].copyWith(sortedStatus: SortingStatus.unSorted);
35-
list[j + 1] = list[j + 1].copyWith(sortedStatus: SortingStatus.unSorted);
36-
state = state.copyWith(list: list);
37-
j--;
38-
}
39-
}
40-
41-
await greenSortedItemsAsDone();
5+
@override
6+
List<SortingStep> buildSorting(List<int> values) {
7+
// TODO: implement buildSorting
8+
throw UnimplementedError();
429
}
4310
}

lib/features/sorting/merge/view_model/merge_sort_notifier.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import 'package:algorithm_visualizer/features/sorting/base/view_model/sorting_no
22

33
class MergeSortNotifier extends SortingNotifier {
44
@override
5-
Future<void> buildSort() async {
6-
/// TODO: implement this
5+
List<SortingStep> buildSorting(List<int> values) {
6+
// TODO: implement buildSorting
7+
throw UnimplementedError();
78
}
89
}

0 commit comments

Comments
 (0)