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 part of intl; | 5 part of intl; |
6 /** | 6 /** |
7 * Provides the ability to format a number in a locale-specific way. The | 7 * Provides the ability to format a number in a locale-specific way. The |
8 * format is specified as a pattern using a subset of the ICU formatting | 8 * format is specified as a pattern using a subset of the ICU formatting |
9 * patterns. | 9 * patterns. |
10 * | 10 * |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 /** | 692 /** |
693 * Return an iterator on the string as a list of substrings. | 693 * Return an iterator on the string as a list of substrings. |
694 */ | 694 */ |
695 Iterator _iterator(String s) => new _StringIterator(s); | 695 Iterator _iterator(String s) => new _StringIterator(s); |
696 | 696 |
697 // TODO(nweiz): remove this when issue 3780 is fixed. | 697 // TODO(nweiz): remove this when issue 3780 is fixed. |
698 /** | 698 /** |
699 * Provides an Iterable that wraps [_iterator] so it can be used in a `for` | 699 * Provides an Iterable that wraps [_iterator] so it can be used in a `for` |
700 * loop. | 700 * loop. |
701 */ | 701 */ |
702 class _StringIterable extends Iterable<String> { | 702 class _StringIterable extends IterableBase<String> { |
703 final Iterator<String> iterator; | 703 final Iterator<String> iterator; |
704 | 704 |
705 _StringIterable(String s) | 705 _StringIterable(String s) |
706 : iterator = _iterator(s); | 706 : iterator = _iterator(s); |
707 } | 707 } |
708 | 708 |
709 /** | 709 /** |
710 * Provides an iterator over a string as a list of substrings, and also | 710 * Provides an iterator over a string as a list of substrings, and also |
711 * gives us a lookahead of one via the [peek] method. | 711 * gives us a lookahead of one via the [peek] method. |
712 */ | 712 */ |
713 class _StringIterator implements Iterator<String> { | 713 class _StringIterator implements Iterator<String> { |
714 String input; | 714 String input; |
715 var index = -1; | 715 var index = -1; |
716 inBounds(i) => i >= 0 && i < input.length; | 716 inBounds(i) => i >= 0 && i < input.length; |
717 _StringIterator(this.input); | 717 _StringIterator(this.input); |
718 String get current => inBounds(index) ? input[index] : null; | 718 String get current => inBounds(index) ? input[index] : null; |
719 | 719 |
720 bool moveNext() => inBounds(++index); | 720 bool moveNext() => inBounds(++index); |
721 String get peek => inBounds(index + 1) ? input[index + 1] : null; | 721 String get peek => inBounds(index + 1) ? input[index + 1] : null; |
722 Iterator<String> get iterator => this; | 722 Iterator<String> get iterator => this; |
723 } | 723 } |
OLD | NEW |