| 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 part of dart._collection.dev; | 5 part of dart._collection.dev; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An [Iterable] for classes that have efficient [length] and [elementAt]. | 8 * An [Iterable] for classes that have efficient [length] and [elementAt]. |
| 9 * | 9 * |
| 10 * All other methods are implemented in terms of [length] and [elementAt], | 10 * All other methods are implemented in terms of [length] and [elementAt], |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 String join([String separator]) { | 169 String join([String separator]) { |
| 170 int length = this.length; | 170 int length = this.length; |
| 171 if (separator != null && !separator.isEmpty) { | 171 if (separator != null && !separator.isEmpty) { |
| 172 if (length == 0) return ""; | 172 if (length == 0) return ""; |
| 173 String first = "${elementAt(0)}"; | 173 String first = "${elementAt(0)}"; |
| 174 if (length != this.length) { | 174 if (length != this.length) { |
| 175 throw new ConcurrentModificationError(this); | 175 throw new ConcurrentModificationError(this); |
| 176 } | 176 } |
| 177 StringBuffer buffer = new StringBuffer(first); | 177 StringBuffer buffer = new StringBuffer(first); |
| 178 for (int i = 1; i < length; i++) { | 178 for (int i = 1; i < length; i++) { |
| 179 buffer.add(separator); | 179 buffer.write(separator); |
| 180 buffer.add("${elementAt(i)}"); | 180 buffer.write("${elementAt(i)}"); |
| 181 if (length != this.length) { | 181 if (length != this.length) { |
| 182 throw new ConcurrentModificationError(this); | 182 throw new ConcurrentModificationError(this); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 return buffer.toString(); | 185 return buffer.toString(); |
| 186 } else { | 186 } else { |
| 187 StringBuffer buffer = new StringBuffer(); | 187 StringBuffer buffer = new StringBuffer(); |
| 188 for (int i = 0; i < length; i++) { | 188 for (int i = 0; i < length; i++) { |
| 189 buffer.add("${elementAt(i)}"); | 189 buffer.write("${elementAt(i)}"); |
| 190 if (length != this.length) { | 190 if (length != this.length) { |
| 191 throw new ConcurrentModificationError(this); | 191 throw new ConcurrentModificationError(this); |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 return buffer.toString(); | 194 return buffer.toString(); |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 | 197 |
| 198 Iterable<E> where(bool test(E element)) => super.where(test); | 198 Iterable<E> where(bool test(E element)) => super.where(test); |
| 199 | 199 |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 class EmptyIterator<E> implements Iterator<E> { | 690 class EmptyIterator<E> implements Iterator<E> { |
| 691 const EmptyIterator(); | 691 const EmptyIterator(); |
| 692 bool moveNext() => false; | 692 bool moveNext() => false; |
| 693 E get current => null; | 693 E get current => null; |
| 694 } | 694 } |
| 695 | 695 |
| 696 /** An [Iterator] that can move in both directions. */ | 696 /** An [Iterator] that can move in both directions. */ |
| 697 abstract class BidirectionalIterator<T> implements Iterator<T> { | 697 abstract class BidirectionalIterator<T> implements Iterator<T> { |
| 698 bool movePrevious(); | 698 bool movePrevious(); |
| 699 } | 699 } |
| OLD | NEW |