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

Side by Side Diff: compiler/lib/implementation/regexp.dart

Issue 9114021: Added method map to Collection interface and all its implementations (except classes generated fr... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 | « compiler/lib/implementation/collections.dart ('k') | corelib/src/collection.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 JSSyntaxRegExp implements RegExp { 5 class JSSyntaxRegExp implements RegExp {
6 const JSSyntaxRegExp( 6 const JSSyntaxRegExp(
7 String this.pattern, 7 String this.pattern,
8 [bool this.multiLine = false, 8 [bool this.multiLine = false,
9 bool this.ignoreCase = false]); 9 bool this.ignoreCase = false]);
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 final String _str; 68 final String _str;
69 69
70 const _LazyAllMatches(this._regexp, this._str); 70 const _LazyAllMatches(this._regexp, this._str);
71 71
72 void forEach(void f(Match match)) { 72 void forEach(void f(Match match)) {
73 for (Match match in this) { 73 for (Match match in this) {
74 f(match); 74 f(match);
75 } 75 }
76 } 76 }
77 77
78 Collection map(f(Match match)) {
79 List result = new List();
80 for (Match match in this) {
81 result.add(f(match));
82 }
83 return result;
84 }
85
78 Collection<Match> filter(bool f(Match match)) { 86 Collection<Match> filter(bool f(Match match)) {
79 List<Match> result = new List<Match>(); 87 List<Match> result = new List<Match>();
80 for (Match match in this) { 88 for (Match match in this) {
81 if (f(match)) result.add(match); 89 if (f(match)) result.add(match);
82 } 90 }
83 return result; 91 return result;
84 } 92 }
85 93
86 bool every(bool f(Match match)) { 94 bool every(bool f(Match match)) {
87 for (Match match in this) { 95 for (Match match in this) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 140
133 bool hasNext() { 141 bool hasNext() {
134 if (_nextMatch != null) return true; 142 if (_nextMatch != null) return true;
135 _nextMatch = _computeNextMatch(_regexp, _str); 143 _nextMatch = _computeNextMatch(_regexp, _str);
136 return (_nextMatch != null); 144 return (_nextMatch != null);
137 } 145 }
138 146
139 void _jsInit(JSSyntaxRegExp regexp) native; 147 void _jsInit(JSSyntaxRegExp regexp) native;
140 Match _computeNextMatch(JSSyntaxRegExp regexp, String str) native; 148 Match _computeNextMatch(JSSyntaxRegExp regexp, String str) native;
141 } 149 }
OLDNEW
« no previous file with comments | « compiler/lib/implementation/collections.dart ('k') | corelib/src/collection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698