| 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 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |