| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /** | 5 /** |
| 6 * Returns the concatenation of the input [iterables]. | 6 * Returns the concatenation of the input [iterables]. |
| 7 * | 7 * |
| 8 * The returned iterable is a lazily-evaluated view on the input iterables. | 8 * The returned iterable is a lazily-evaluated view on the input iterables. |
| 9 */ | 9 */ |
| 10 Iterable/*<E>*/ concat/*<E>*/(Iterable<Iterable/*<E>*/ > iterables) => | 10 Iterable<E> concat<E>(Iterable<Iterable<E>> iterables) => |
| 11 iterables.expand((x) => x); | 11 iterables.expand((x) => x); |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Returns the concatenation of the input [iterables] as a [List]. | 14 * Returns the concatenation of the input [iterables] as a [List]. |
| 15 */ | 15 */ |
| 16 List/*<E>*/ concatToList/*<E>*/(Iterable<Iterable/*<E>*/ > iterables) => | 16 List<E> concatToList<E>(Iterable<Iterable<E>> iterables) => |
| 17 concat(iterables).toList(); | 17 concat(iterables).toList(); |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * Returns the given [list] if it is not empty, or `null` otherwise. | 20 * Returns the given [list] if it is not empty, or `null` otherwise. |
| 21 */ | 21 */ |
| 22 List/*<E>*/ nullIfEmpty/*<E>*/(List/*<E>*/ list) { | 22 List<E> nullIfEmpty<E>(List<E> list) { |
| 23 if (list == null) { | 23 if (list == null) { |
| 24 return null; | 24 return null; |
| 25 } | 25 } |
| 26 if (list.isEmpty) { | 26 if (list.isEmpty) { |
| 27 return null; | 27 return null; |
| 28 } | 28 } |
| 29 return list; | 29 return list; |
| 30 } | 30 } |
| 31 | 31 |
| 32 /// A pair of values. | 32 /// A pair of values. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 62 Iterable<T> get items => _buffer.reversed; | 62 Iterable<T> get items => _buffer.reversed; |
| 63 | 63 |
| 64 void add(T item) { | 64 void add(T item) { |
| 65 _buffer.add(item); | 65 _buffer.add(item); |
| 66 | 66 |
| 67 if (_buffer.length > capacity) { | 67 if (_buffer.length > capacity) { |
| 68 _buffer.removeAt(0); | 68 _buffer.removeAt(0); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 } | 71 } |
| OLD | NEW |