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

Side by Side Diff: sdk/lib/utf/utf_core.dart

Issue 11363252: Extend Iterable instead of implementing it. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Address Stephen's comments. Created 8 years, 1 month 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // TODO(jmesserly): would be nice to have this on String (dartbug.com/6501). 5 // TODO(jmesserly): would be nice to have this on String (dartbug.com/6501).
6 /** 6 /**
7 * Provide a list of Unicode codepoints for a given string. 7 * Provide a list of Unicode codepoints for a given string.
8 */ 8 */
9 List<int> stringToCodepoints(String str) { 9 List<int> stringToCodepoints(String str) {
10 // Note: str.charCodes gives us 16-bit code units on all Dart implementations. 10 // Note: str.charCodes gives us 16-bit code units on all Dart implementations.
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 "Invalid UTF16 at ${utf16CodeUnitIterator.position}"); 197 "Invalid UTF16 at ${utf16CodeUnitIterator.position}");
198 } 198 }
199 } 199 }
200 } 200 }
201 201
202 /** 202 /**
203 * _ListRange in an internal type used to create a lightweight Interable on a 203 * _ListRange in an internal type used to create a lightweight Interable on a
204 * range within a source list. DO NOT MODIFY the underlying list while 204 * range within a source list. DO NOT MODIFY the underlying list while
205 * iterating over it. The results of doing so are undefined. 205 * iterating over it. The results of doing so are undefined.
206 */ 206 */
207 class _ListRange implements Iterable { 207 class _ListRange extends Iterable {
208 final List _source; 208 final List _source;
209 final int _offset; 209 final int _offset;
210 final int _length; 210 final int _length;
211 211
212 _ListRange(source, [offset = 0, length]) : 212 _ListRange(source, [offset = 0, length]) :
213 this._source = source, 213 this._source = source,
214 this._offset = offset, 214 this._offset = offset,
215 this._length = (length == null ? source.length - offset : length) { 215 this._length = (length == null ? source.length - offset : length) {
216 if (_offset < 0 || _offset > _source.length) { 216 if (_offset < 0 || _offset > _source.length) {
217 throw new RangeError.value(_offset); 217 throw new RangeError.value(_offset);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 _offset -= by; 261 _offset -= by;
262 } 262 }
263 263
264 int get remaining => _end - _offset; 264 int get remaining => _end - _offset;
265 265
266 void skip([int count = 1]) { 266 void skip([int count = 1]) {
267 _offset += count; 267 _offset += count;
268 } 268 }
269 } 269 }
270 270
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698