Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: sdk/lib/_collection_dev/iterable.dart

Issue 13945009: Make default argument to Iterable.join be "". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (compare(max, element) < 0) { 159 if (compare(max, element) < 0) {
160 max = element; 160 max = element;
161 } 161 }
162 if (length != this.length) { 162 if (length != this.length) {
163 throw new ConcurrentModificationError(this); 163 throw new ConcurrentModificationError(this);
164 } 164 }
165 } 165 }
166 return max; 166 return max;
167 } 167 }
168 168
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.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.write(separator); 179 buffer.write(separator);
180 buffer.write("${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.write("${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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 660
661 E singleWhere(bool test(E element), { E orElse() }) { 661 E singleWhere(bool test(E element), { E orElse() }) {
662 if (orElse != null) return orElse(); 662 if (orElse != null) return orElse();
663 throw new StateError("No matching element"); 663 throw new StateError("No matching element");
664 } 664 }
665 665
666 E min([int compare(E a, E b)]) => null; 666 E min([int compare(E a, E b)]) => null;
667 667
668 E max([int compare(E a, E b)]) => null; 668 E max([int compare(E a, E b)]) => null;
669 669
670 String join([String separator]) => ""; 670 String join([String separator = ""]) => "";
671 671
672 Iterable<E> where(bool test(E element)) => this; 672 Iterable<E> where(bool test(E element)) => this;
673 673
674 Iterable map(f(E element)) => const EmptyIterable(); 674 Iterable map(f(E element)) => const EmptyIterable();
675 675
676 reduce(var initialValue, combine(var previousValue, E element)) { 676 reduce(var initialValue, combine(var previousValue, E element)) {
677 return fold(initialValue, combine); 677 return fold(initialValue, combine);
678 } 678 }
679 679
680 fold(var initialValue, combine(var previousValue, E element)) { 680 fold(var initialValue, combine(var previousValue, E element)) {
(...skipping 17 matching lines...) Expand all
698 class EmptyIterator<E> implements Iterator<E> { 698 class EmptyIterator<E> implements Iterator<E> {
699 const EmptyIterator(); 699 const EmptyIterator();
700 bool moveNext() => false; 700 bool moveNext() => false;
701 E get current => null; 701 E get current => null;
702 } 702 }
703 703
704 /** An [Iterator] that can move in both directions. */ 704 /** An [Iterator] that can move in both directions. */
705 abstract class BidirectionalIterator<T> implements Iterator<T> { 705 abstract class BidirectionalIterator<T> implements Iterator<T> {
706 bool movePrevious(); 706 bool movePrevious();
707 } 707 }
OLDNEW
« no previous file with comments | « samples/swarm/swarm_ui_lib/observable/observable.dart ('k') | sdk/lib/_internal/compiler/implementation/code_buffer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698