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

Side by Side Diff: samples/swarm/swarm_ui_lib/observable/observable.dart

Issue 11727007: Add min and max to Iterable and Stream. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Created 7 years, 11 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 observable; 5 library observable;
6 6
7 part 'ChangeEvent.dart'; 7 part 'ChangeEvent.dart';
8 part 'EventBatch.dart'; 8 part 'EventBatch.dart';
9 9
10 /** 10 /**
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 int push(T element) { 184 int push(T element) {
185 recordListInsert(length, element); 185 recordListInsert(length, element);
186 _internal.add(element); 186 _internal.add(element);
187 return _internal.length; 187 return _internal.length;
188 } 188 }
189 189
190 T get first => _internal.first; 190 T get first => _internal.first;
191 T get last => _internal.last; 191 T get last => _internal.last;
192 T get single => _internal.single; 192 T get single => _internal.single;
193 193
194 T min([int compare(T a, T b)]) => _internal.min(compare);
195 T max([int compare(T a, T b)]) => _internal.max(compare);
196
194 T removeLast() { 197 T removeLast() {
195 final result = _internal.removeLast(); 198 final result = _internal.removeLast();
196 recordListRemove(length, result); 199 recordListRemove(length, result);
197 return result; 200 return result;
198 } 201 }
199 202
200 T removeAt(int index) { 203 T removeAt(int index) {
201 int i = 0; 204 int i = 0;
202 T found = null; 205 T found = null;
203 _internal = _internal.where(bool _(element) { 206 _internal = _internal.where(bool _(element) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // Only fire on an actual change. 307 // Only fire on an actual change.
305 if (!identical(newValue, _value)) { 308 if (!identical(newValue, _value)) {
306 final oldValue = _value; 309 final oldValue = _value;
307 _value = newValue; 310 _value = newValue;
308 recordPropertyUpdate("value", newValue, oldValue); 311 recordPropertyUpdate("value", newValue, oldValue);
309 } 312 }
310 } 313 }
311 314
312 T _value; 315 T _value;
313 } 316 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698