| 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 part of observe; | 5 part of observe; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Represents an observable list of model values. If any items are added, | 8 * Represents an observable list of model values. If any items are added, |
| 9 * removed, or replaced, then observers that are listening to [changes] | 9 * removed, or replaced, then observers that are listening to [changes] |
| 10 * will be notified. | 10 * will be notified. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 _list.addAll(iterable); | 95 _list.addAll(iterable); |
| 96 int added = _list.length - len; | 96 int added = _list.length - len; |
| 97 if (hasObservers && added > 0) { | 97 if (hasObservers && added > 0) { |
| 98 _recordChange(new ListChangeRecord(len, addedCount: added)); | 98 _recordChange(new ListChangeRecord(len, addedCount: added)); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool remove(Object element) { | 102 bool remove(Object element) { |
| 103 for (int i = 0; i < this.length; i++) { | 103 for (int i = 0; i < this.length; i++) { |
| 104 if (this[i] == element) { | 104 if (this[i] == element) { |
| 105 removeRange(i, 1); | 105 removeRange(i, i + 1); |
| 106 return true; | 106 return true; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 void removeRange(int start, int end) { | 112 void removeRange(int start, int end) { |
| 113 _rangeCheck(start, end); | 113 _rangeCheck(start, end); |
| 114 int length = end - start; | 114 int length = end - start; |
| 115 _list.setRange(start, this.length - length, this, end); | 115 _list.setRange(start, this.length - length, this, end); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 271 } |
| 272 | 272 |
| 273 offset += removed - added; | 273 offset += removed - added; |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 | 277 |
| 278 // TODO(jmesserly): bogus type to workaround spurious VM bug with generic base | 278 // TODO(jmesserly): bogus type to workaround spurious VM bug with generic base |
| 279 // class and mixins. | 279 // class and mixins. |
| 280 abstract class _ListBaseWorkaround extends ListBase<dynamic> {} | 280 abstract class _ListBaseWorkaround extends ListBase<dynamic> {} |
| OLD | NEW |