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

Side by Side Diff: pkg/observe/lib/src/observable_list.dart

Issue 18267005: Fix bug in pkg:observe (observable_list.remove(Object)) (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/observe/test/observable_list_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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> {}
OLDNEW
« no previous file with comments | « no previous file | pkg/observe/test/observable_list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698