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; | 5 part of dart.collection; |
6 | 6 |
7 /** | 7 /** |
8 * Abstract implementation of a list. | 8 * Abstract implementation of a list. |
9 * | 9 * |
10 * All operations are defined in terms of `length`, `operator[]`, | 10 * All operations are defined in terms of `length`, `operator[]`, |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 if (compare(max, element) < 0) { | 174 if (compare(max, element) < 0) { |
175 max = element; | 175 max = element; |
176 } | 176 } |
177 if (length != this.length) { | 177 if (length != this.length) { |
178 throw new ConcurrentModificationError(this); | 178 throw new ConcurrentModificationError(this); |
179 } | 179 } |
180 } | 180 } |
181 return max; | 181 return max; |
182 } | 182 } |
183 | 183 |
184 String join([String separator]) { | 184 String join([String separator = ""]) { |
185 int length = this.length; | 185 int length = this.length; |
186 if (separator != null && !separator.isEmpty) { | 186 if (!separator.isEmpty) { |
187 if (length == 0) return ""; | 187 if (length == 0) return ""; |
188 String first = "${this[0]}"; | 188 String first = "${this[0]}"; |
189 if (length != this.length) { | 189 if (length != this.length) { |
190 throw new ConcurrentModificationError(this); | 190 throw new ConcurrentModificationError(this); |
191 } | 191 } |
192 StringBuffer buffer = new StringBuffer(first); | 192 StringBuffer buffer = new StringBuffer(first); |
193 for (int i = 1; i < length; i++) { | 193 for (int i = 1; i < length; i++) { |
194 buffer.write(separator); | 194 buffer.write(separator); |
195 buffer.write("${this[i]}"); | 195 buffer.write(this[i]); |
196 if (length != this.length) { | 196 if (length != this.length) { |
197 throw new ConcurrentModificationError(this); | 197 throw new ConcurrentModificationError(this); |
198 } | 198 } |
199 } | 199 } |
200 return buffer.toString(); | 200 return buffer.toString(); |
201 } else { | 201 } else { |
202 StringBuffer buffer = new StringBuffer(); | 202 StringBuffer buffer = new StringBuffer(); |
203 for (int i = 0; i < length; i++) { | 203 for (int i = 0; i < length; i++) { |
204 buffer.write("${this[i]}"); | 204 buffer.write(this[i]); |
205 if (length != this.length) { | 205 if (length != this.length) { |
206 throw new ConcurrentModificationError(this); | 206 throw new ConcurrentModificationError(this); |
207 } | 207 } |
208 } | 208 } |
209 return buffer.toString(); | 209 return buffer.toString(); |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test); | 213 Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test); |
214 | 214 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 for (int i = startIndex; i >= 0; i--) { | 447 for (int i = startIndex; i >= 0; i--) { |
448 if (this[i] == element) { | 448 if (this[i] == element) { |
449 return i; | 449 return i; |
450 } | 450 } |
451 } | 451 } |
452 return -1; | 452 return -1; |
453 } | 453 } |
454 | 454 |
455 Iterable<E> get reversed => new ReversedListIterable(this); | 455 Iterable<E> get reversed => new ReversedListIterable(this); |
456 } | 456 } |
OLD | NEW |