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

Unified Diff: frog/minfrog

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, 12 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 side-by-side diff with in-line comments
Download patch
Index: frog/minfrog
===================================================================
--- frog/minfrog (revision 2973)
+++ frog/minfrog (working copy)
@@ -247,6 +247,9 @@
Object.prototype.last$0 = function() {
return this.noSuchMethod("last", []);
};
+Object.prototype.map$1 = function($0) {
+ return this.noSuchMethod("map", [$0]);
+};
Object.prototype.markUsed$0 = function() {
return this.noSuchMethod("markUsed", []);
};
@@ -600,6 +603,9 @@
ListFactory.prototype.isEmpty$0 = ListFactory.prototype.isEmpty;
ListFactory.prototype.iterator$0 = ListFactory.prototype.iterator;
ListFactory.prototype.last$0 = ListFactory.prototype.last;
+ListFactory.prototype.map$1 = function($0) {
+ return this.map(to$call$1($0));
+};
ListFactory.prototype.removeLast$0 = ListFactory.prototype.removeLast;
ListFactory.prototype.some$1 = function($0) {
return this.some(to$call$1($0));
@@ -1101,6 +1107,14 @@
}
);
}
+HashSetImplementation.prototype.map = function(f) {
+ var result = new HashSetImplementation();
+ this._backingMap.forEach(function _(key, value) {
+ result.add(f(key));
+ }
+ );
+ return result;
+}
HashSetImplementation.prototype.filter = function(f) {
var result = new HashSetImplementation();
this._backingMap.forEach(function _(key, value) {
@@ -1140,6 +1154,9 @@
};
HashSetImplementation.prototype.isEmpty$0 = HashSetImplementation.prototype.isEmpty;
HashSetImplementation.prototype.iterator$0 = HashSetImplementation.prototype.iterator;
+HashSetImplementation.prototype.map$1 = function($0) {
+ return this.map(to$call$1($0));
+};
HashSetImplementation.prototype.some$1 = function($0) {
return this.some(to$call$1($0));
};
@@ -1472,6 +1489,16 @@
}
return false;
}
+DoubleLinkedQueue.prototype.map = function(f) {
+ var other = new DoubleLinkedQueue();
+ var entry = this._sentinel._next;
+ while (entry !== this._sentinel) {
+ var nextEntry = entry._next;
+ other.addLast(f(entry._element));
+ entry = nextEntry;
+ }
+ return other;
+}
DoubleLinkedQueue.prototype.filter = function(f) {
var other = new DoubleLinkedQueue();
var entry = this._sentinel._next;
@@ -1499,6 +1526,9 @@
DoubleLinkedQueue.prototype.isEmpty$0 = DoubleLinkedQueue.prototype.isEmpty;
DoubleLinkedQueue.prototype.iterator$0 = DoubleLinkedQueue.prototype.iterator;
DoubleLinkedQueue.prototype.last$0 = DoubleLinkedQueue.prototype.last;
+DoubleLinkedQueue.prototype.map$1 = function($0) {
+ return this.map(to$call$1($0));
+};
DoubleLinkedQueue.prototype.removeLast$0 = DoubleLinkedQueue.prototype.removeLast;
DoubleLinkedQueue.prototype.some$1 = function($0) {
return this.some(to$call$1($0));
@@ -1757,6 +1787,13 @@
}
return destination;
}
+Collections.map = function(source, destination, f) {
+ for (var $$i = source.iterator(); $$i.hasNext$0(); ) {
+ var e = $$i.next$0();
+ destination.add(f(e));
+ }
+ return destination;
+}
// ********** Code for _Worker **************
// ********** Code for _ArgumentMismatchException **************
$inherits(_ArgumentMismatchException, ClosureArgumentMismatchException);

Powered by Google App Engine
This is Rietveld 408576698