| 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 library collections; | 5 library collections; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Returns the concatentation of the input iterables. | 8 * Returns the concatenation of the input [iterables]. |
| 9 * | 9 * |
| 10 * The returned iterable is a lazily-evaluated view on the input iterables. | 10 * The returned iterable is a lazily-evaluated view on the input iterables. |
| 11 */ | 11 */ |
| 12 Iterable concat(Iterable<Iterable> iterables) => iterables.expand((x) => x); | 12 Iterable/*<E>*/ concat/*<E>*/(Iterable<Iterable/*<E>*/ > iterables) => |
| 13 iterables.expand((x) => x); |
| 13 | 14 |
| 14 /** | 15 /** |
| 15 * Returns the concatentation of the input iterables as a [List]. | 16 * Returns the concatenation of the input [iterables] as a [List]. |
| 16 */ | 17 */ |
| 17 List concatToList(Iterable<Iterable> iterables) => concat(iterables).toList(); | 18 List/*<E>*/ concatToList/*<E>*/(Iterable<Iterable/*<E>*/ > iterables) => |
| 19 concat(iterables).toList(); |
| 18 | 20 |
| 19 /** | 21 /** |
| 20 * Returns the given [list] if it is not empty, or `null` otherwise. | 22 * Returns the given [list] if it is not empty, or `null` otherwise. |
| 21 */ | 23 */ |
| 22 List nullIfEmpty(List list) { | 24 List/*<E>*/ nullIfEmpty/*<E>*/(List/*<E>*/ list) { |
| 23 if (list == null) { | 25 if (list == null) { |
| 24 return null; | 26 return null; |
| 25 } | 27 } |
| 26 if (list.isEmpty) { | 28 if (list.isEmpty) { |
| 27 return null; | 29 return null; |
| 28 } | 30 } |
| 29 return list; | 31 return list; |
| 30 } | 32 } |
| 31 | 33 |
| 32 /// A pair of values. | 34 /// A pair of values. |
| 33 class Pair<E, F> { | 35 class Pair<E, F> { |
| 34 final E first; | 36 final E first; |
| 35 final F last; | 37 final F last; |
| 36 | 38 |
| 37 Pair(this.first, this.last); | 39 Pair(this.first, this.last); |
| 38 | 40 |
| 39 int get hashCode => first.hashCode ^ last.hashCode; | 41 int get hashCode => first.hashCode ^ last.hashCode; |
| 40 | 42 |
| 41 bool operator ==(other) { | 43 bool operator ==(other) { |
| 42 if (other is! Pair) return false; | 44 if (other is! Pair) return false; |
| 43 return other.first == first && other.last == last; | 45 return other.first == first && other.last == last; |
| 44 } | 46 } |
| 45 | 47 |
| 46 String toString() => '($first, $last)'; | 48 String toString() => '($first, $last)'; |
| 47 } | 49 } |
| OLD | NEW |