OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library template_binding.src.list_diff; | 5 library template_binding.src.list_diff; |
6 | 6 |
7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
8 import 'package:observe/observe.dart' show ListChangeRecord; | 8 import 'package:observe/observe.dart' show ListChangeRecord; |
9 | 9 |
10 /** | 10 /** |
(...skipping 21 matching lines...) Expand all Loading... |
32 // TODO(jmesserly): freeze remove list before handing it out? | 32 // TODO(jmesserly): freeze remove list before handing it out? |
33 /** The items removed, if any. Otherwise this will be an empty list. */ | 33 /** The items removed, if any. Otherwise this will be an empty list. */ |
34 List get removed => _removed; | 34 List get removed => _removed; |
35 | 35 |
36 /** The number of items added. */ | 36 /** The number of items added. */ |
37 int get addedCount => _addedCount; | 37 int get addedCount => _addedCount; |
38 | 38 |
39 int get removedCount => _removed.length; | 39 int get removedCount => _removed.length; |
40 | 40 |
41 /** Returns true if the provided index was changed by this operation. */ | 41 /** Returns true if the provided index was changed by this operation. */ |
42 bool changes(key) { | 42 bool indexChanged(key) { |
43 // If key isn't an int, or before the index, then it wasn't changed. | 43 // If key isn't an int, or before the index, then it wasn't changed. |
44 if (key is! int || key < index) return false; | 44 if (key is! int || key < index) return false; |
45 | 45 |
46 // If this was a shift operation, anything after index is changed. | 46 // If this was a shift operation, anything after index is changed. |
47 if (addedCount != removedCount) return true; | 47 if (addedCount != removedCount) return true; |
48 | 48 |
49 // Otherwise, anything in the update range was changed. | 49 // Otherwise, anything in the update range was changed. |
50 return key < index + addedCount; | 50 return key < index + addedCount; |
51 } | 51 } |
52 | 52 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 oldIndex++; | 259 oldIndex++; |
260 break; | 260 break; |
261 } | 261 } |
262 } | 262 } |
263 | 263 |
264 if (splice != null) { | 264 if (splice != null) { |
265 splices.add(splice); | 265 splices.add(splice); |
266 } | 266 } |
267 return splices; | 267 return splices; |
268 } | 268 } |
OLD | NEW |