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

Side by Side Diff: runtime/lib/arrays.dart

Issue 8276005: Implement List.getRange. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 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
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/growable_array.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class Arrays { 5 class Arrays {
6 6
7 static String asString(Array array) { 7 static String asString(Array array) {
8 String result = "["; 8 String result = "[";
9 int len = array.length; 9 int len = array.length;
10 for (int i = 0; i < len; i++) { 10 for (int i = 0; i < len; i++) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 if (startIndex >= a.length) { 79 if (startIndex >= a.length) {
80 startIndex = a.length - 1; 80 startIndex = a.length - 1;
81 } 81 }
82 for (int i = startIndex; i >= 0; i--) { 82 for (int i = startIndex; i >= 0; i--) {
83 if (a[i] == element) { 83 if (a[i] == element) {
84 return i; 84 return i;
85 } 85 }
86 } 86 }
87 return -1; 87 return -1;
88 } 88 }
89
90 static void rangeCheck(Array a, int start, int length) {
91 if (length < 0) {
92 throw new IllegalArgumentException("negative length $length");
93 }
94 if (start < 0 || start > a.length) {
95 throw new IndexOutOfRangeException(start);
96 }
97 if (start + length > a.length) {
98 throw new IndexOutOfRangeException(start + length);
99 }
100 }
89 } 101 }
90 102
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/growable_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698