OLD | NEW |
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 class ListFactory<E> { | 5 class ListFactory<E> { |
6 factory List.from(Iterable<E> other) { | 6 factory List.from(Iterable<E> other) { |
7 if (other == null) { | 7 if (other == null) { |
8 throw const NullPointerException(); | 8 throw const NullPointerException(); |
9 } | 9 } |
10 List<E> list = new List<E>(); | 10 List<E> list = new List<E>(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 int get length() native; | 69 int get length() native; |
70 void _setLength(int length) native; | 70 void _setLength(int length) native; |
71 void _add(T value) native; | 71 void _add(T value) native; |
72 void _removeRange(int start, int length) native; | 72 void _removeRange(int start, int length) native; |
73 void _insertRange(int start, int length, T initialValue) native; | 73 void _insertRange(int start, int length, T initialValue) native; |
74 | 74 |
75 void forEach(void f(T element)) { | 75 void forEach(void f(T element)) { |
76 Collections.forEach(this, f); | 76 Collections.forEach(this, f); |
77 } | 77 } |
78 | 78 |
| 79 Collection map(f(T element)) { |
| 80 return Collections.map(this, new List(), f); |
| 81 } |
| 82 |
79 Collection<T> filter(bool f(T element)) { | 83 Collection<T> filter(bool f(T element)) { |
80 return Collections.filter(this, new List<T>(), f); | 84 return Collections.filter(this, new List<T>(), f); |
81 } | 85 } |
82 | 86 |
83 bool every(bool f(T element)) { | 87 bool every(bool f(T element)) { |
84 return Collections.every(this, f); | 88 return Collections.every(this, f); |
85 } | 89 } |
86 | 90 |
87 bool some(bool f(T element)) { | 91 bool some(bool f(T element)) { |
88 return Collections.some(this, f); | 92 return Collections.some(this, f); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 269 } |
266 | 270 |
267 static List _newList(int len) native { | 271 static List _newList(int len) native { |
268 return new List(len); | 272 return new List(len); |
269 } | 273 } |
270 | 274 |
271 static void _throwIndexOutOfRangeException(int index) native { | 275 static void _throwIndexOutOfRangeException(int index) native { |
272 throw new IndexOutOfRangeException(index); | 276 throw new IndexOutOfRangeException(index); |
273 } | 277 } |
274 } | 278 } |
OLD | NEW |