Refactor: extract collection utilities to package

This commit is contained in:
Ming Ming 2023-08-26 01:31:06 +08:00
parent b0cac85d7f
commit 9f43092dab
66 changed files with 239 additions and 200 deletions

View file

@ -5,8 +5,8 @@ import 'package:copy_with/copy_with.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/type.dart';
import 'package:np_string/np_string.dart';
import 'package:to_string/to_string.dart';

View file

@ -11,12 +11,12 @@ import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/entity/collection.dart';
import 'package:nc_photos/entity/person.dart';
import 'package:nc_photos/entity/tag.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/use_case/collection/list_collection.dart';
import 'package:nc_photos/use_case/list_location_group.dart';
import 'package:nc_photos/use_case/list_tag.dart';
import 'package:nc_photos/use_case/person/list_person.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_string/np_string.dart';
import 'package:to_string/to_string.dart';
import 'package:tuple/tuple.dart';

View file

@ -10,11 +10,11 @@ import 'package:nc_photos/entity/album/item.dart';
import 'package:nc_photos/entity/album/provider.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/share.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/object_extension.dart';
import 'package:nc_photos/use_case/list_share.dart';
import 'package:nc_photos/use_case/list_sharee.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_string/np_string.dart';
import 'package:to_string/to_string.dart';

View file

@ -8,11 +8,11 @@ import 'package:nc_photos/entity/album.dart';
import 'package:nc_photos/entity/album/provider.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
import 'package:nc_photos/use_case/album/list_album.dart';
import 'package:nc_photos/use_case/ls.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:to_string/to_string.dart';
part 'list_importable_album.g.dart';

View file

@ -11,7 +11,6 @@ import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/entity/share.dart';
import 'package:nc_photos/event/event.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
import 'package:nc_photos/throttler.dart';
import 'package:nc_photos/use_case/find_file.dart';
@ -19,6 +18,7 @@ import 'package:nc_photos/use_case/list_share_with_me.dart';
import 'package:nc_photos/use_case/ls.dart';
import 'package:nc_photos/use_case/ls_single_file.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:path/path.dart' as path_lib;
import 'package:to_string/to_string.dart';

View file

@ -5,9 +5,9 @@ import 'package:logging/logging.dart';
import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/entity/local_file.dart';
import 'package:nc_photos/event/event.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/use_case/scan_local_dir.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:to_string/to_string.dart';
part 'scan_local_dir.g.dart';

View file

@ -2,8 +2,8 @@ import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:logging/logging.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_string/np_string.dart';
import 'package:to_string/to_string.dart';
import 'package:tuple/tuple.dart';

View file

@ -15,7 +15,6 @@ import 'package:nc_photos/entity/collection_item/new_item.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/event/event.dart';
import 'package:nc_photos/exception_event.dart';
import 'package:nc_photos/list_extension.dart';
import 'package:nc_photos/object_extension.dart';
import 'package:nc_photos/rx_extension.dart';
import 'package:nc_photos/use_case/collection/add_file_to_collection.dart';
@ -24,6 +23,7 @@ import 'package:nc_photos/use_case/collection/remove_from_collection.dart';
import 'package:nc_photos/use_case/collection/update_collection_post_load.dart';
import 'package:nc_photos/use_case/remove.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:rxdart/rxdart.dart';
part 'collection_items_controller.g.dart';

View file

@ -7,9 +7,9 @@ import 'package:nc_photos/entity/album/provider.dart';
import 'package:nc_photos/entity/album/sort_provider.dart';
import 'package:nc_photos/entity/album/upgrader.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/object_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/or_null.dart';
import 'package:np_common/type.dart';
import 'package:np_string/np_string.dart';

View file

@ -9,8 +9,8 @@ import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/exception.dart';
import 'package:nc_photos/exception_event.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'data_source.g.dart';

View file

@ -7,8 +7,8 @@ import 'package:nc_photos/entity/album.dart';
import 'package:nc_photos/entity/album/item.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/tag.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/or_null.dart';
import 'package:np_common/type.dart';
import 'package:to_string/to_string.dart';

View file

@ -19,7 +19,6 @@ import 'package:nc_photos/entity/collection_item/util.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/entity/sharee.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/object_extension.dart';
import 'package:nc_photos/use_case/album/add_file_to_album.dart';
import 'package:nc_photos/use_case/album/edit_album.dart';
@ -32,6 +31,7 @@ import 'package:nc_photos/use_case/preprocess_album.dart';
import 'package:nc_photos/use_case/unimport_shared_album.dart';
import 'package:nc_photos/use_case/update_album_with_actual_items.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/or_null.dart';
import 'package:np_common/type.dart';
import 'package:np_string/np_string.dart';

View file

@ -4,8 +4,8 @@ import 'package:nc_photos/entity/album/sort_provider.dart';
import 'package:nc_photos/entity/collection_item.dart';
import 'package:nc_photos/entity/collection_item/util.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:tuple/tuple.dart';
part 'sorter.g.dart';

View file

@ -14,12 +14,12 @@ import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/entity/sqlite/files_query_builder.dart' as sql;
import 'package:nc_photos/exception.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/np_api_util.dart';
import 'package:nc_photos/object_extension.dart';
import 'package:nc_photos/use_case/compat/v32.dart';
import 'package:np_api/np_api.dart' as api;
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/or_null.dart';
import 'package:path/path.dart' as path_lib;

View file

@ -12,10 +12,9 @@ import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/entity/sqlite/files_query_builder.dart' as sql;
import 'package:nc_photos/entity/sqlite/type_converter.dart';
import 'package:nc_photos/exception.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/list_util.dart' as list_util;
import 'package:nc_photos/object_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'file_cache_manager.g.dart';
@ -136,7 +135,7 @@ class FileSqliteCacheUpdater {
..where((t) => t.dir.equals(_dirRowId!))
..orderBy([(t) => sql.OrderingTerm.asc(t.rowId)]);
final dirFiles = await dirFileQuery.get();
final diff = list_util.diff(dirFiles.map((e) => e.child),
final diff = getDiff(dirFiles.map((e) => e.child),
_childRowIds.sorted(Comparable.compare));
if (diff.onlyInB.isNotEmpty) {
await db.batch((batch) {

View file

@ -2,7 +2,6 @@ import 'package:collection/collection.dart';
import 'package:logging/logging.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/entity/local_file.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/mobile/android/android_info.dart';
import 'package:nc_photos/mobile/android/k.dart' as android;
import 'package:nc_photos/mobile/share.dart';
@ -10,6 +9,7 @@ import 'package:nc_photos/object_extension.dart';
import 'package:nc_photos/stream_extension.dart';
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'data_source.g.dart';

View file

@ -9,10 +9,10 @@ import 'package:nc_photos/entity/nc_album_item.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/entity/sqlite/type_converter.dart';
import 'package:nc_photos/exception.dart';
import 'package:nc_photos/list_util.dart' as list_util;
import 'package:nc_photos/np_api_util.dart';
import 'package:np_api/np_api.dart' as api;
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'data_source.g.dart';
@ -236,7 +236,7 @@ class NcAlbumSqliteDbDataSource implements NcAlbumCacheDataSource {
final existingItems = await db.ncAlbumItemsByParent(
parent: dbAlbum!,
);
final diff = list_util.diffWith<NcAlbumItem>(
final diff = getDiffWith<NcAlbumItem>(
existingItems
.map((e) => SqliteNcAlbumItemConverter.fromSql(
account.userId.raw, album.strippedPath, e))

View file

@ -9,11 +9,10 @@ import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/entity/sqlite/table.dart';
import 'package:nc_photos/entity/sqlite/type_converter.dart';
import 'package:nc_photos/exception.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/map_extension.dart';
import 'package:nc_photos/np_api_util.dart';
import 'package:np_api/np_api.dart' as api;
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/type.dart';
part 'data_source.g.dart';

View file

@ -2,7 +2,7 @@ import 'package:nc_photos/account.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/entity/sqlite/files_query_builder.dart' as sql;
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_collection/np_collection.dart';
import 'package:to_string/to_string.dart';
part 'search.g.dart';

View file

@ -10,12 +10,12 @@ import 'package:nc_photos/entity/search_util.dart' as search_util;
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/entity/sqlite/files_query_builder.dart' as sql;
import 'package:nc_photos/entity/sqlite/type_converter.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/object_extension.dart';
import 'package:nc_photos/use_case/inflate_file_descriptor.dart';
import 'package:nc_photos/use_case/list_tagged_file.dart';
import 'package:nc_photos/use_case/person/list_person_face.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_string/np_string.dart';
part 'data_source.g.dart';

View file

@ -16,6 +16,7 @@ import 'package:nc_photos/mobile/platform.dart'
import 'package:nc_photos/object_extension.dart';
import 'package:nc_photos/platform/k.dart' as platform_k;
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'database.g.dart';
part 'database/nc_album_extension.dart';

View file

@ -5,10 +5,10 @@ import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/tag.dart';
import 'package:nc_photos/entity/tagged_file.dart';
import 'package:nc_photos/exception.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/np_api_util.dart';
import 'package:np_api/np_api.dart' as api;
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'data_source.g.dart';

View file

@ -1,6 +1,6 @@
import 'dart:async';
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_collection/np_collection.dart';
Future<List<T>> waitOr<T>(
Iterable<Future<T>> futures,

View file

@ -7,15 +7,14 @@ import 'package:nc_photos/app_localizations.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/exception_util.dart' as exception_util;
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/map_extension.dart';
import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/use_case/download_file.dart';
import 'package:nc_photos/use_case/download_preview.dart';
import 'package:nc_photos/widget/processing_dialog.dart';
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'internal_download_handler.g.dart';

View file

@ -1,62 +1,9 @@
import 'dart:async';
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:nc_photos/list_extension.dart';
import 'package:nc_photos/override_comparator.dart';
import 'package:quiver/iterables.dart';
import 'package:tuple/tuple.dart';
import 'package:np_collection/np_collection.dart';
extension IterableExtension<T> on Iterable<T> {
/// Return a new stable sorted list
List<T> stableSorted([int Function(T a, T b)? compare]) =>
toList()..stableSort(compare);
/// Return a string representation of this iterable by joining the result of
/// toString for each items
String toReadableString() => "[${join(', ')}]";
Iterable<Tuple2<int, T>> withIndex() => mapIndexed((i, e) => Tuple2(i, e));
/// Whether the collection contains an element equal to [element] using the
/// equality function [equalFn]
bool containsIf(T element, bool Function(T a, T b) equalFn) =>
any((e) => equalFn(e, element));
/// Same as [contains] but uses [identical] to compare the objects
bool containsIdentical(T element) =>
containsIf(element, (a, b) => identical(a, b));
Map<U, List<T>> groupBy<U>({required U Function(T e) key}) {
return fold<Map<U, List<T>>>(
{},
(previousValue, element) =>
previousValue..putIfAbsent(key(element), () => []).add(element));
}
/// Return a new list with only distinct elements
List<T> distinct() {
final s = <T>{};
return where((element) => s.add(element)).toList();
}
/// Return a new list with only distinct elements determined by [equalFn]
List<T> distinctIf(
bool Function(T a, T b) equalFn, int Function(T a) hashCodeFn) {
final s = <OverrideComparator<T>>{};
return where((element) =>
s.add(OverrideComparator<T>(element, equalFn, hashCodeFn))).toList();
}
/// Invokes [action] on each element of this iterable in iteration order
/// lazily
Iterable<T> forEachLazy(void Function(T element) action) sync* {
for (final e in this) {
action(e);
yield e;
}
}
Future<List<U>> computeAll<U>(ComputeCallback<T, U> callback) async {
final list = asList();
if (list.isEmpty) {
@ -66,63 +13,6 @@ extension IterableExtension<T> on Iterable<T> {
_computeAllImpl<T, U>, _ComputeAllMessage(callback, list));
}
}
/// Return a list containing elements in this iterable
///
/// If this Iterable is itself a list, this will be returned directly with no
/// copying
List<T> asList() {
if (this is List) {
return this as List<T>;
} else {
return toList();
}
}
/// The first index of [element] in this iterable
///
/// Searches the list from index start to the end of the list. The first time
/// an object o is encountered so that o == element, the index of o is
/// returned. Returns -1 if element is not found.
int indexOf(T element, [int start = 0]) {
var i = 0;
for (final e in this) {
final j = i++;
if (j < start) {
continue;
}
if (e == element) {
return j;
}
}
return -1;
}
Future<List<U>> withPartition<U>(
FutureOr<Iterable<U>> Function(Iterable<T> sublist) fn, int size) async {
final products = <U>[];
final sublists = partition(this, size);
for (final l in sublists) {
products.addAll(await fn(l));
}
return products;
}
Future<void> withPartitionNoReturn(
FutureOr<void> Function(Iterable<T> sublist) fn, int size) async {
final sublists = partition(this, size);
for (final l in sublists) {
await fn(l);
}
}
}
extension IterableFlattenExtension<T> on Iterable<Iterable<T>> {
/// Flattens an [Iterable] of [Iterable] values of type [T] to a [Iterable] of
/// values of type [T].
///
/// This function originated in the xml package
Iterable<T> flatten() => expand((values) => values);
}
class _ComputeAllMessage<T, U> {

View file

@ -10,7 +10,6 @@ import 'package:nc_photos/entity/pref.dart';
import 'package:nc_photos/entity/pref_util.dart' as pref_util;
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/help_utils.dart' as help_utils;
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/legacy/connect.dart';
import 'package:nc_photos/platform/k.dart' as platform_k;
import 'package:nc_photos/theme.dart';
@ -18,6 +17,7 @@ import 'package:nc_photos/url_launcher_util.dart';
import 'package:nc_photos/widget/home.dart';
import 'package:nc_photos/widget/root_picker.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_string/np_string.dart';
part 'sign_in.g.dart';

View file

@ -1,8 +1,8 @@
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_string/np_string.dart';
import 'package:tuple/tuple.dart';
import 'package:woozy_search/woozy_search.dart';

View file

@ -9,12 +9,12 @@ import 'package:nc_photos/entity/album/provider.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/exception.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/use_case/album/unshare_file_from_album.dart';
import 'package:nc_photos/use_case/preprocess_album.dart';
import 'package:nc_photos/use_case/update_album.dart';
import 'package:nc_photos/use_case/update_album_with_actual_items.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/type.dart';
part 'remove_from_album.g.dart';

View file

@ -7,10 +7,10 @@ import 'package:nc_photos/entity/album/provider.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/share.dart';
import 'package:nc_photos/entity/sharee.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/use_case/create_share.dart';
import 'package:nc_photos/use_case/update_album.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/or_null.dart';
import 'package:np_common/type.dart';
import 'package:np_string/np_string.dart';

View file

@ -8,10 +8,9 @@ import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/entity/sqlite/files_query_builder.dart' as sql;
import 'package:nc_photos/event/event.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/list_util.dart' as list_util;
import 'package:nc_photos/object_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'cache_favorite.g.dart';
@ -32,8 +31,7 @@ class CacheFavorite {
final cache = await _getCacheFavorites(db, dbAccount);
final cacheMap =
Map.fromEntries(cache.map((e) => MapEntry(e.fileId, e.rowId)));
final diff =
list_util.diff(cacheMap.keys.sorted(Comparable.compare), remote);
final diff = getDiff(cacheMap.keys.sorted(Comparable.compare), remote);
final newFileIds = diff.onlyInB;
_log.info("[call] New favorites: ${newFileIds.toReadableString()}");
final removedFildIds = diff.onlyInA;

View file

@ -3,8 +3,8 @@ import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:tuple/tuple.dart';
part 'v55.g.dart';

View file

@ -7,10 +7,9 @@ import 'package:nc_photos/entity/face_recognition_person.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/entity/sqlite/type_converter.dart';
import 'package:nc_photos/exception.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/list_util.dart' as list_util;
import 'package:nc_photos/use_case/face_recognition_person/list_face_recognition_person.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'sync_face_recognition_person.g.dart';
@ -41,7 +40,7 @@ class SyncFaceRecognitionPerson {
final cache = (await ListFaceRecognitionPerson(_c.withLocalRepo())(account)
.last)
..sort(personSorter);
final diff = list_util.diffWith(cache, remote, personSorter);
final diff = getDiffWith(cache, remote, personSorter);
final inserts = diff.onlyInB;
_log.info("[call] New people: ${inserts.toReadableString()}");
final deletes = diff.onlyInA;

View file

@ -3,8 +3,8 @@ import 'package:nc_photos/account.dart';
import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'find_file.g.dart';

View file

@ -3,8 +3,8 @@ import 'package:nc_photos/account.dart';
import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'find_file_descriptor.g.dart';

View file

@ -8,12 +8,10 @@ import 'package:nc_photos/entity/recognize_face_item.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/entity/sqlite/type_converter.dart';
import 'package:nc_photos/exception.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/list_util.dart' as list_util;
import 'package:nc_photos/map_extension.dart';
import 'package:nc_photos/use_case/recognize_face/list_recognize_face.dart';
import 'package:nc_photos/use_case/recognize_face/list_recognize_face_item.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'sync_recognize_face.g.dart';
@ -96,7 +94,7 @@ class SyncRecognizeFace {
}
final cache = (await ListRecognizeFace(_c.withLocalRepo())(account).last)
..sort(faceSorter);
final diff = list_util.diffWith(cache, remote, faceSorter);
final diff = getDiffWith(cache, remote, faceSorter);
final inserts = diff.onlyInB;
_log.info("[_getFaceResults] New face: ${inserts.toReadableString()}");
final deletes = diff.onlyInA;
@ -152,8 +150,8 @@ class SyncRecognizeFace {
for (final f in faces) {
final thisCache = (cache[f] ?? [])..sort(itemSorter);
final thisRemote = (remote[f] ?? [])..sort(itemSorter);
final diff = list_util.diffWith<RecognizeFaceItem>(
thisCache, thisRemote, itemSorter);
final diff =
getDiffWith<RecognizeFaceItem>(thisCache, thisRemote, itemSorter);
final inserts = diff.onlyInB;
_log.info(
"[_getFaceItemResults] New item: ${inserts.toReadableString()}");
@ -194,7 +192,7 @@ class SyncRecognizeFace {
// await ListRecognizeFaceItem(_c.withLocalRepo())(account, face).last;
// int itemSorter(RecognizeFaceItem a, RecognizeFaceItem b) =>
// a.fileId.compareTo(b.fileId);
// final diff = list_util.diffWith(cache, remote, itemSorter);
// final diff = getDiffWith(cache, remote, itemSorter);
// final inserts = diff.onlyInB;
// _log.info("[_getFaceItemResults] New face: ${inserts.toReadableString()}");
// final deletes = diff.onlyInA;

View file

@ -10,13 +10,13 @@ import 'package:nc_photos/entity/album/provider.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/event/event.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/stream_extension.dart';
import 'package:nc_photos/use_case/album/list_album.dart';
import 'package:nc_photos/use_case/album/remove_from_album.dart';
import 'package:nc_photos/use_case/list_share.dart';
import 'package:nc_photos/use_case/remove_share.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/type.dart';
import 'package:np_string/np_string.dart';

View file

@ -6,9 +6,8 @@ import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/entity/sqlite/type_converter.dart';
import 'package:nc_photos/entity/tag.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/list_util.dart' as list_util;
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'sync_tag.g.dart';
@ -26,7 +25,7 @@ class SyncTag {
int tagSorter(Tag a, Tag b) => a.id.compareTo(b.id);
final remote = (await _c.tagRepoRemote.list(account))..sort(tagSorter);
final cache = (await _c.tagRepoLocal.list(account))..sort(tagSorter);
final diff = list_util.diffWith<Tag>(cache, remote, tagSorter);
final diff = getDiffWith<Tag>(cache, remote, tagSorter);
final inserts = diff.onlyInB;
_log.info("[call] New tags: ${inserts.toReadableString()}");
final deletes = diff.onlyInA;

View file

@ -5,11 +5,11 @@ import 'package:nc_photos/api/api_util.dart' as api_util;
import 'package:nc_photos/app_localizations.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/widget/dir_picker.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'album_dir_picker.g.dart';

View file

@ -17,7 +17,6 @@ import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/exception_util.dart' as exception_util;
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/use_case/album/create_album.dart';
@ -25,6 +24,7 @@ import 'package:nc_photos/use_case/preprocess_album.dart';
import 'package:nc_photos/use_case/update_album_with_actual_items.dart';
import 'package:nc_photos/widget/processing_dialog.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'album_importer.g.dart';

View file

@ -11,7 +11,6 @@ import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/entity/local_file.dart';
import 'package:nc_photos/entity/pref.dart';
import 'package:nc_photos/exception_util.dart' as exception_util;
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/mobile/android/android_info.dart';
import 'package:nc_photos/mobile/android/permission_util.dart';
@ -28,6 +27,7 @@ import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart';
import 'package:nc_photos/widget/selection_app_bar.dart';
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'enhanced_photo_browser.g.dart';

View file

@ -17,7 +17,6 @@ import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/exception_event.dart';
import 'package:nc_photos/exception_util.dart' as exception_util;
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/mobile/share.dart';
import 'package:nc_photos/platform/k.dart' as platform_k;
@ -34,6 +33,7 @@ import 'package:nc_photos/widget/share_link_multiple_files_dialog.dart';
import 'package:nc_photos/widget/simple_input_dialog.dart';
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:to_string/to_string.dart';
import 'package:tuple/tuple.dart';

View file

@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:nc_photos/app_localizations.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/object_extension.dart';
import 'package:nc_photos/widget/image_editor/toolbar_button.dart';
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_string/np_string.dart';
import 'package:np_ui/np_ui.dart';

View file

@ -5,13 +5,13 @@ import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:logging/logging.dart';
import 'package:nc_photos/app_localizations.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/platform/k.dart' as platform_k;
import 'package:nc_photos/session_storage.dart';
import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/widget/selectable.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'selectable_item_list.g.dart';

View file

@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:logging/logging.dart';
import 'package:nc_photos/app_localizations.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/platform/k.dart' as platform_k;
import 'package:nc_photos/session_storage.dart';
@ -13,6 +12,7 @@ import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/widget/measurable_item_list.dart';
import 'package:nc_photos/widget/selectable.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:uuid/uuid.dart';
import 'package:visibility_detector/visibility_detector.dart';

View file

@ -5,11 +5,11 @@ import 'package:nc_photos/app_localizations.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/widget/dir_picker.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
part 'share_folder_picker.g.dart';

View file

@ -10,13 +10,13 @@ import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/entity/pref.dart';
import 'package:nc_photos/entity/pref_util.dart' as pref_util;
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/legacy/sign_in.dart' as legacy;
import 'package:nc_photos/theme.dart';
import 'package:nc_photos/widget/connect.dart';
import 'package:nc_photos/widget/home.dart';
import 'package:nc_photos/widget/root_picker.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_string/np_string.dart';
part 'sign_in.g.dart';

View file

@ -962,6 +962,13 @@ packages:
relative: true
source: path
version: "1.0.0"
np_collection:
dependency: "direct main"
description:
path: "../np_collection"
relative: true
source: path
version: "1.0.0"
np_common:
dependency: "direct main"
description:
@ -1205,7 +1212,7 @@ packages:
source: hosted
version: "1.2.3"
quiver:
dependency: "direct main"
dependency: transitive
description:
name: quiver
sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47

View file

@ -103,6 +103,8 @@ dependencies:
path: ../codegen
np_common:
path: ../np_common
np_collection:
path: ../np_collection
np_log:
path: ../np_log
np_math:
@ -115,7 +117,6 @@ dependencies:
page_view_indicators: ^2.0.0
path: ^1.8.0
path_provider: ^2.0.15
quiver: ^3.2.1
rxdart: ^0.27.7
screen_brightness: ^0.2.2
shared_preferences: ^2.0.8

View file

@ -2,7 +2,7 @@ import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file/data_source.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/list_extension.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/or_null.dart';
import 'package:test/test.dart';

View file

@ -3,7 +3,7 @@ import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file/data_source.dart';
import 'package:nc_photos/entity/file/file_cache_manager.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/list_extension.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/or_null.dart';
import 'package:np_math/np_math.dart';
import 'package:test/test.dart';

View file

@ -16,7 +16,7 @@ import 'package:nc_photos/entity/share.dart';
import 'package:nc_photos/entity/sharee.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/entity/sqlite/type_converter.dart';
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_collection/np_collection.dart';
import 'package:np_common/or_null.dart';
import 'package:np_string/np_string.dart';
import 'package:tuple/tuple.dart';

View file

@ -2,8 +2,8 @@ import 'package:clock/clock.dart';
import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
import 'package:nc_photos/list_extension.dart';
import 'package:nc_photos/use_case/inflate_file_descriptor.dart';
import 'package:np_collection/np_collection.dart';
import 'package:test/test.dart';
import '../test_util.dart' as util;

View file

@ -1,7 +1,7 @@
import 'package:nc_photos/entity/file.dart';
import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/list_extension.dart';
import 'package:nc_photos/use_case/ls.dart';
import 'package:np_collection/np_collection.dart';
import 'package:test/test.dart';
import '../mock_type.dart';

7
np_collection/.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock

View file

@ -0,0 +1 @@
include: package:np_lints/np.yaml

View file

@ -0,0 +1,7 @@
library np_collection;
export 'src/iterable_extension.dart';
export 'src/iterator_extension.dart';
export 'src/list_extension.dart';
export 'src/list_util.dart';
export 'src/map_extension.dart';

View file

@ -0,0 +1,114 @@
import 'dart:async';
import 'dart:collection';
import 'package:collection/collection.dart';
import 'package:np_collection/src/list_extension.dart';
import 'package:quiver/iterables.dart';
import 'package:tuple/tuple.dart';
extension IterableExtension<T> on Iterable<T> {
/// Return a new stable sorted list
List<T> stableSorted([int Function(T a, T b)? compare]) =>
toList()..stableSort(compare);
/// Return a string representation of this iterable by joining the result of
/// toString for each items
String toReadableString() => "[${join(', ')}]";
Iterable<Tuple2<int, T>> withIndex() => mapIndexed((i, e) => Tuple2(i, e));
/// Whether the collection contains an element equal to [element] using the
/// equality function [equalFn]
bool containsIf(T element, bool Function(T a, T b) equalFn) =>
any((e) => equalFn(e, element));
/// Same as [contains] but uses [identical] to compare the objects
bool containsIdentical(T element) =>
containsIf(element, (a, b) => identical(a, b));
Map<U, List<T>> groupBy<U>({required U Function(T e) key}) {
return fold<Map<U, List<T>>>(
{},
(previousValue, element) =>
previousValue..putIfAbsent(key(element), () => []).add(element));
}
/// Return a new list with only distinct elements
List<T> distinct() {
final s = <T>{};
return where((element) => s.add(element)).toList();
}
/// Return a new list with only distinct elements determined by [equalFn]
List<T> distinctIf(
bool Function(T a, T b) equalFn, int Function(T a) hashCodeFn) {
final s = LinkedHashSet(equals: equalFn, hashCode: hashCodeFn);
return where((element) => s.add(element)).toList();
}
/// Invokes [action] on each element of this iterable in iteration order
/// lazily
Iterable<T> forEachLazy(void Function(T element) action) sync* {
for (final e in this) {
action(e);
yield e;
}
}
/// Return a list containing elements in this iterable
///
/// If this Iterable is itself a list, this will be returned directly with no
/// copying
List<T> asList() {
if (this is List) {
return this as List<T>;
} else {
return toList();
}
}
/// The first index of [element] in this iterable
///
/// Searches the list from index start to the end of the list. The first time
/// an object o is encountered so that o == element, the index of o is
/// returned. Returns -1 if element is not found.
int indexOf(T element, [int start = 0]) {
var i = 0;
for (final e in this) {
final j = i++;
if (j < start) {
continue;
}
if (e == element) {
return j;
}
}
return -1;
}
Future<List<U>> withPartition<U>(
FutureOr<Iterable<U>> Function(Iterable<T> sublist) fn, int size) async {
final products = <U>[];
final sublists = partition(this, size);
for (final l in sublists) {
products.addAll(await fn(l));
}
return products;
}
Future<void> withPartitionNoReturn(
FutureOr<void> Function(Iterable<T> sublist) fn, int size) async {
final sublists = partition(this, size);
for (final l in sublists) {
await fn(l);
}
}
}
extension IterableFlattenExtension<T> on Iterable<Iterable<T>> {
/// Flattens an [Iterable] of [Iterable] values of type [T] to a [Iterable] of
/// values of type [T].
///
/// This function originated in the xml package
Iterable<T> flatten() => expand((values) => values);
}

View file

@ -1,4 +1,4 @@
import 'package:nc_photos/iterator_extension.dart';
import 'package:np_collection/src/iterator_extension.dart';
/// Contain results from the diff functions
///
@ -18,7 +18,7 @@ class DiffResult<T> {
///
/// [a] and [b] MUST be sorted in ascending order, otherwise the result is
/// undefined
DiffResult<T> diffWith<T>(
DiffResult<T> getDiffWith<T>(
Iterable<T> a, Iterable<T> b, int Function(T a, T b) comparator) {
final aIt = a.iterator, bIt = b.iterator;
final aMissing = <T>[], bMissing = <T>[];
@ -41,8 +41,8 @@ DiffResult<T> diffWith<T>(
}
}
DiffResult<T> diff<T extends Comparable>(Iterable<T> a, Iterable<T> b) =>
diffWith(a, b, Comparable.compare);
DiffResult<T> getDiff<T extends Comparable>(Iterable<T> a, Iterable<T> b) =>
getDiffWith(a, b, Comparable.compare);
DiffResult<T> _diffUntilEqual<T>(
Iterator<T> aIt, Iterator<T> bIt, int Function(T a, T b) comparator) {

View file

@ -0,0 +1,20 @@
name: np_collection
description: A starting point for Dart libraries or applications.
version: 1.0.0
# repository: https://github.com/my_org/my_repo
publish_to: none
environment:
sdk: '>=2.19.6 <3.0.0'
dependencies:
collection: ^1.15.0
np_math:
path: ../np_math
quiver: ^3.2.1
tuple: ^2.0.1
dev_dependencies:
np_lints:
path: ../np_lints
test: ^1.21.0

View file

@ -1,4 +1,4 @@
import 'package:nc_photos/iterable_extension.dart';
import 'package:np_collection/src/iterable_extension.dart';
import 'package:np_math/np_math.dart';
import 'package:quiver/core.dart';
import 'package:test/test.dart';

View file

@ -1,4 +1,4 @@
import 'package:nc_photos/iterator_extension.dart';
import 'package:np_collection/src/iterator_extension.dart';
import 'package:test/test.dart';
void main() {

View file

@ -1,4 +1,4 @@
import 'package:nc_photos/list_extension.dart';
import 'package:np_collection/src/list_extension.dart';
import 'package:test/test.dart';
void main() {

View file

@ -1,4 +1,4 @@
import 'package:nc_photos/list_util.dart' as list_util;
import 'package:np_collection/src/list_util.dart';
import 'package:test/test.dart';
void main() {
@ -26,7 +26,7 @@ void main() {
/// b: [1, 2, 3, 4, 5]
/// Expect: [1, 2], []
void _diffExtraBBegin() {
final diff = list_util.diff([3, 4, 5], [1, 2, 3, 4, 5]);
final diff = getDiff([3, 4, 5], [1, 2, 3, 4, 5]);
expect(diff.onlyInB, [1, 2]);
expect(diff.onlyInA, []);
}
@ -37,7 +37,7 @@ void _diffExtraBBegin() {
/// b: [1, 2, 3, 4, 5]
/// Expect: [4, 5], []
void _diffExtraBEnd() {
final diff = list_util.diff([1, 2, 3], [1, 2, 3, 4, 5]);
final diff = getDiff([1, 2, 3], [1, 2, 3, 4, 5]);
expect(diff.onlyInB, [4, 5]);
expect(diff.onlyInA, []);
}
@ -48,7 +48,7 @@ void _diffExtraBEnd() {
/// b: [1, 2, 3, 4, 5]
/// Expect: [3, 4], []
void _diffExtraBMid() {
final diff = list_util.diff([1, 2, 5], [1, 2, 3, 4, 5]);
final diff = getDiff([1, 2, 5], [1, 2, 3, 4, 5]);
expect(diff.onlyInB, [3, 4]);
expect(diff.onlyInA, []);
}
@ -59,7 +59,7 @@ void _diffExtraBMid() {
/// b: [1, 2, 3]
/// Expect: [1, 2, 3], []
void _diffAEmpty() {
final diff = list_util.diff(<int>[], [1, 2, 3]);
final diff = getDiff(<int>[], [1, 2, 3]);
expect(diff.onlyInB, [1, 2, 3]);
expect(diff.onlyInA, []);
}
@ -70,7 +70,7 @@ void _diffAEmpty() {
/// b: [3, 4, 5]
/// Expect: [], [1, 2]
void _diffExtraABegin() {
final diff = list_util.diff([1, 2, 3, 4, 5], [3, 4, 5]);
final diff = getDiff([1, 2, 3, 4, 5], [3, 4, 5]);
expect(diff.onlyInB, []);
expect(diff.onlyInA, [1, 2]);
}
@ -81,7 +81,7 @@ void _diffExtraABegin() {
/// b: [1, 2, 3]
/// Expect: [], [4, 5]
void _diffExtraAEnd() {
final diff = list_util.diff([1, 2, 3, 4, 5], [1, 2, 3]);
final diff = getDiff([1, 2, 3, 4, 5], [1, 2, 3]);
expect(diff.onlyInB, []);
expect(diff.onlyInA, [4, 5]);
}
@ -92,7 +92,7 @@ void _diffExtraAEnd() {
/// b: [1, 2, 5]
/// Expect: [], [3, 4]
void _diffExtraAMid() {
final diff = list_util.diff([1, 2, 3, 4, 5], [1, 2, 5]);
final diff = getDiff([1, 2, 3, 4, 5], [1, 2, 5]);
expect(diff.onlyInB, []);
expect(diff.onlyInA, [3, 4]);
}
@ -103,7 +103,7 @@ void _diffExtraAMid() {
/// b: []
/// Expect: [], [1, 2, 3]
void _diffBEmpty() {
final diff = list_util.diff([1, 2, 3], <int>[]);
final diff = getDiff([1, 2, 3], <int>[]);
expect(diff.onlyInB, []);
expect(diff.onlyInA, [1, 2, 3]);
}
@ -114,7 +114,7 @@ void _diffBEmpty() {
/// b: [2, 4]
/// Expect: [2, 4], [1, 3, 5]
void _diffNoMatches() {
final diff = list_util.diff([1, 3, 5], [2, 4]);
final diff = getDiff([1, 3, 5], [2, 4]);
expect(diff.onlyInB, [2, 4]);
expect(diff.onlyInA, [1, 3, 5]);
}
@ -125,7 +125,7 @@ void _diffNoMatches() {
/// b: [1, 2, 2, 3]
/// Expect: [2], []
void _diffRepeatedElements() {
final diff = list_util.diff([1, 2, 3], [1, 2, 2, 3]);
final diff = getDiff([1, 2, 3], [1, 2, 2, 3]);
expect(diff.onlyInB, [2]);
expect(diff.onlyInA, []);
}
@ -136,7 +136,7 @@ void _diffRepeatedElements() {
/// b: [1, 2, 2, 3, 5]
/// Expect: [2, 2], [4, 4]
void _diffRepeatedElements2() {
final diff = list_util.diff([1, 3, 4, 4, 5], [1, 2, 2, 3, 5]);
final diff = getDiff([1, 3, 4, 4, 5], [1, 2, 2, 3, 5]);
expect(diff.onlyInB, [2, 2]);
expect(diff.onlyInA, [4, 4]);
}
@ -147,7 +147,7 @@ void _diffRepeatedElements2() {
/// b: [1, 3, 4, 8, 13, 14]
/// Expect: [1, 4, 8, 13, 14], [2, 7, 10, 11, 12]
void _diffMix() {
final diff = list_util.diff([2, 3, 7, 10, 11, 12], [1, 3, 4, 8, 13, 14]);
final diff = getDiff([2, 3, 7, 10, 11, 12], [1, 3, 4, 8, 13, 14]);
expect(diff.onlyInB, [1, 4, 8, 13, 14]);
expect(diff.onlyInA, [2, 7, 10, 11, 12]);
}