Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(994)

Unified Diff: pkg/mdv/lib/src/list_diff.dart

Issue 20149004: [mdv] implement Node.createBinding and Node.createBindings (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/mdv/lib/src/list_diff.dart
diff --git a/pkg/mdv/lib/src/list_diff.dart b/pkg/mdv/lib/src/list_diff.dart
index 55246aadf1313767a523cf1bf49754901e29b804..8858c760e6b3dba8e6f033e038a9b9aea699d3e8 100644
--- a/pkg/mdv/lib/src/list_diff.dart
+++ b/pkg/mdv/lib/src/list_diff.dart
@@ -38,6 +38,18 @@ class ListChangeDelta implements ListChangeRecord {
int get removedCount => _removed.length;
+ /** Returns true if the provided index was changed by this operation. */
+ bool changes(key) {
+ // If key isn't an int, or before the index, then it wasn't changed.
+ if (key is! int || key < index) return false;
+
+ // If this was a shift operation, anything after index is changed.
+ if (addedCount != removedCount) return true;
+
+ // Otherwise, anything in the update range was changed.
+ return key < index + addedCount;
+ }
+
String toString() => '#<$runtimeType index: $index, '
'removed: $removed, addedCount: $addedCount>';
}

Powered by Google App Engine
This is Rietveld 408576698