| OLD | NEW |
| 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 library dart.utf; | 5 library dart.utf; |
| 6 import "dart:async"; | 6 import "dart:async"; |
| 7 import "dart:collection"; |
| 7 part "utf_stream.dart"; | 8 part "utf_stream.dart"; |
| 8 part "utf8.dart"; | 9 part "utf8.dart"; |
| 9 part "utf16.dart"; | 10 part "utf16.dart"; |
| 10 part "utf32.dart"; | 11 part "utf32.dart"; |
| 11 | 12 |
| 12 // TODO(jmesserly): would be nice to have this on String (dartbug.com/6501). | 13 // TODO(jmesserly): would be nice to have this on String (dartbug.com/6501). |
| 13 /** | 14 /** |
| 14 * Provide a list of Unicode codepoints for a given string. | 15 * Provide a list of Unicode codepoints for a given string. |
| 15 */ | 16 */ |
| 16 List<int> stringToCodepoints(String str) { | 17 List<int> stringToCodepoints(String str) { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } | 191 } |
| 191 } | 192 } |
| 192 | 193 |
| 193 /** | 194 /** |
| 194 * _ListRange in an internal type used to create a lightweight Interable on a | 195 * _ListRange in an internal type used to create a lightweight Interable on a |
| 195 * range within a source list. DO NOT MODIFY the underlying list while | 196 * range within a source list. DO NOT MODIFY the underlying list while |
| 196 * iterating over it. The results of doing so are undefined. | 197 * iterating over it. The results of doing so are undefined. |
| 197 */ | 198 */ |
| 198 // TODO(floitsch): Consider removing the extend and switch to implements since | 199 // TODO(floitsch): Consider removing the extend and switch to implements since |
| 199 // that's cheaper to allocate. | 200 // that's cheaper to allocate. |
| 200 class _ListRange extends Iterable { | 201 class _ListRange extends IterableBase { |
| 201 final List _source; | 202 final List _source; |
| 202 final int _offset; | 203 final int _offset; |
| 203 final int _length; | 204 final int _length; |
| 204 | 205 |
| 205 _ListRange(source, [offset = 0, length]) : | 206 _ListRange(source, [offset = 0, length]) : |
| 206 this._source = source, | 207 this._source = source, |
| 207 this._offset = offset, | 208 this._offset = offset, |
| 208 this._length = (length == null ? source.length - offset : length) { | 209 this._length = (length == null ? source.length - offset : length) { |
| 209 if (_offset < 0 || _offset > _source.length) { | 210 if (_offset < 0 || _offset > _source.length) { |
| 210 throw new RangeError.value(_offset); | 211 throw new RangeError.value(_offset); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 _offset -= by; | 256 _offset -= by; |
| 256 } | 257 } |
| 257 | 258 |
| 258 int get remaining => _end - _offset - 1; | 259 int get remaining => _end - _offset - 1; |
| 259 | 260 |
| 260 void skip([int count = 1]) { | 261 void skip([int count = 1]) { |
| 261 _offset += count; | 262 _offset += count; |
| 262 } | 263 } |
| 263 } | 264 } |
| 264 | 265 |
| OLD | NEW |