Files
flutter_server_box/lib/data/model/server/time_seq.dart
2023-07-28 20:21:15 +08:00

23 lines
448 B
Dart

// ignore_for_file: prefer_final_fields
abstract class TimeSeq<T extends TimeSeqIface> {
List<T> pre;
List<T> now;
void update(List<T> new_) {
pre = now;
now = new_;
if (pre.length != now.length) {
pre.removeWhere((e) => now.any((el) => e.same(el)));
pre.addAll(now.where((e) => pre.every((el) => !e.same(el))));
}
}
TimeSeq(this.pre, this.now);
}
abstract class TimeSeqIface<T> {
bool same(T other);
}