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

Side by Side Diff: sdk/lib/collection/list.dart

Issue 24488004: Implement correct scoping rules for variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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) 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 void _rangeCheck(int start, int end) { 308 void _rangeCheck(int start, int end) {
309 if (start < 0 || start > this.length) { 309 if (start < 0 || start > this.length) {
310 throw new RangeError.range(start, 0, this.length); 310 throw new RangeError.range(start, 0, this.length);
311 } 311 }
312 if (end < start || end > this.length) { 312 if (end < start || end > this.length) {
313 throw new RangeError.range(end, start, this.length); 313 throw new RangeError.range(end, start, this.length);
314 } 314 }
315 } 315 }
316 316
317 List<E> sublist(int start, [int end]) { 317 List<E> sublist(int start, [int end]) {
318 if (end == null) end = length; 318 if (end == null) end = this.length;
319 _rangeCheck(start, end); 319 _rangeCheck(start, end);
320 int length = end - start; 320 int length = end - start;
321 List<E> result = new List<E>()..length = length; 321 List<E> result = new List<E>()..length = length;
322 for (int i = 0; i < length; i++) { 322 for (int i = 0; i < length; i++) {
323 result[i] = this[start + i]; 323 result[i] = this[start + i];
324 } 324 }
325 return result; 325 return result;
326 } 326 }
327 327
328 Iterable<E> getRange(int start, int end) { 328 Iterable<E> getRange(int start, int end) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 result.writeAll(this, ', '); 486 result.writeAll(this, ', ');
487 result.write(']'); 487 result.write(']');
488 } finally { 488 } finally {
489 assert(identical(_toStringList.last, this)); 489 assert(identical(_toStringList.last, this));
490 _toStringList.removeLast(); 490 _toStringList.removeLast();
491 } 491 }
492 492
493 return result.toString(); 493 return result.toString();
494 } 494 }
495 } 495 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698