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

Side by Side Diff: sdk/lib/_collection_dev/list.dart

Issue 15263004: Adding isNotEmpty property to collection and string. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix template generation Created 7 years, 7 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) 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 dart._collection.dev; 5 part of dart._collection.dev;
6 6
7 /** 7 /**
8 * Mixin that throws on the length changing operations of [List]. 8 * Mixin that throws on the length changing operations of [List].
9 * 9 *
10 * Intended to mix-in on top of [ListMixin] for fixed-length lists. 10 * Intended to mix-in on top of [ListMixin] for fixed-length lists.
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 ListMapView(this._values); 232 ListMapView(this._values);
233 233
234 E operator[] (int key) => containsKey(key) ? _values[key] : null; 234 E operator[] (int key) => containsKey(key) ? _values[key] : null;
235 int get length => _values.length; 235 int get length => _values.length;
236 236
237 Iterable<E> get values => new SubListIterable<E>(_values, 0, null); 237 Iterable<E> get values => new SubListIterable<E>(_values, 0, null);
238 Iterable<int> get keys => new _ListIndicesIterable(_values); 238 Iterable<int> get keys => new _ListIndicesIterable(_values);
239 239
240 bool get isEmpty => _values.isEmpty; 240 bool get isEmpty => _values.isEmpty;
241 bool get isNotEmpty => _values.isNotEmpty;
241 bool containsValue(E value) => _values.contains(value); 242 bool containsValue(E value) => _values.contains(value);
242 bool containsKey(int key) => key is int && key >= 0 && key < length; 243 bool containsKey(int key) => key is int && key >= 0 && key < length;
243 244
244 void forEach(void f(int key, E value)) { 245 void forEach(void f(int key, E value)) {
245 int length = _values.length; 246 int length = _values.length;
246 for (int i = 0; i < length; i++) { 247 for (int i = 0; i < length; i++) {
247 f(i, _values[i]); 248 f(i, _values[i]);
248 if (length != _values.length) { 249 if (length != _values.length) {
249 throw new ConcurrentModificationError(_values); 250 throw new ConcurrentModificationError(_values);
250 } 251 }
(...skipping 18 matching lines...) Expand all
269 } 270 }
270 271
271 class ReversedListIterable<E> extends ListIterable<E> { 272 class ReversedListIterable<E> extends ListIterable<E> {
272 Iterable<E> _source; 273 Iterable<E> _source;
273 ReversedListIterable(this._source); 274 ReversedListIterable(this._source);
274 275
275 int get length => _source.length; 276 int get length => _source.length;
276 277
277 E elementAt(int index) => _source.elementAt(_source.length - 1 - index); 278 E elementAt(int index) => _source.elementAt(_source.length - 1 - index);
278 } 279 }
OLDNEW
« no previous file with comments | « samples/swarm/swarm_ui_lib/observable/observable.dart ('k') | sdk/lib/_internal/compiler/implementation/code_buffer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698