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

Issue 10832060: Add reduce to Collection. (Closed)

Created:
8 years, 4 months ago by Anders Johnsen
Modified:
8 years, 1 month ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add reduce to Collection. BUG= TEST= Committed: https://code.google.com/p/dart/source/detail?r=10548

Patch Set 1 #

Total comments: 24

Patch Set 2 : Comment and style fixes. #

Patch Set 3 : Use Dynamic as type. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+79 lines, -2 lines) Patch
M corelib/src/collection.dart View 1 2 1 chunk +15 lines, -2 lines 0 comments Download
M corelib/src/implementation/collections.dart View 1 2 1 chunk +9 lines, -0 lines 0 comments Download
M corelib/src/implementation/hash_map_set.dart View 1 2 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/lib/array.dart View 1 2 2 chunks +10 lines, -0 lines 0 comments Download
M runtime/lib/growable_array.dart View 1 2 1 chunk +5 lines, -0 lines 0 comments Download
A tests/corelib/collection_test.dart View 1 chunk +35 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Anders Johnsen
8 years, 4 months ago (2012-07-30 06:24:54 UTC) #1
Anders Johnsen
Florian pointed out that we should consider changing this to foldLeft/foldRight. However, Set is a ...
8 years, 4 months ago (2012-07-30 07:52:07 UTC) #2
Sean Eagan
On 2012/07/30 07:52:07, ajohnsen wrote: > Florian pointed out that we should consider changing this ...
8 years, 4 months ago (2012-08-06 21:32:18 UTC) #3
Lasse Reichstein Nielsen
The values should still be accessed in iteration order. That makes foldRight harder to define ...
8 years, 4 months ago (2012-08-08 07:00:31 UTC) #4
Lasse Reichstein Nielsen
LGTM https://chromiumcodereview.appspot.com/10832060/diff/1/corelib/src/collection.dart File corelib/src/collection.dart (right): https://chromiumcodereview.appspot.com/10832060/diff/1/corelib/src/collection.dart#newcode17 corelib/src/collection.dart:17: * for each element [e] of this collection. ...
8 years, 4 months ago (2012-08-08 07:19:14 UTC) #5
Anders Johnsen
PTAL https://chromiumcodereview.appspot.com/10832060/diff/1/corelib/src/collection.dart File corelib/src/collection.dart (right): https://chromiumcodereview.appspot.com/10832060/diff/1/corelib/src/collection.dart#newcode17 corelib/src/collection.dart:17: * for each element [e] of this collection. ...
8 years, 4 months ago (2012-08-08 07:56:14 UTC) #6
Lasse Reichstein Nielsen
LGTM https://chromiumcodereview.appspot.com/10832060/diff/1/corelib/src/collection.dart File corelib/src/collection.dart (right): https://chromiumcodereview.appspot.com/10832060/diff/1/corelib/src/collection.dart#newcode17 corelib/src/collection.dart:17: * for each element [e] of this collection. ...
8 years, 4 months ago (2012-08-10 11:26:56 UTC) #7
Anders Johnsen
8 years, 1 month ago (2012-11-12 12:02:56 UTC) #8
https://codereview.chromium.org/10832060/diff/1/corelib/src/collection.dart
File corelib/src/collection.dart (right):

https://codereview.chromium.org/10832060/diff/1/corelib/src/collection.dart#n...
corelib/src/collection.dart:17: * for each element [e] of this collection.
On 2012/08/10 11:26:56, Lasse Reichstein Nielsen wrote:
> Just fix the [:e:] while you are here, and it'll be fine.
> You better get used to comments on surrounding code, even if it isn't yours :)

Done.

https://codereview.chromium.org/10832060/diff/1/corelib/src/collection.dart#n...
corelib/src/collection.dart:31: reduce(var init, f(var prev, E element));
On 2012/08/10 11:26:56, Lasse Reichstein Nielsen wrote:
> Accepted. Use Dynamic or var then.

Done.

https://codereview.chromium.org/10832060/diff/1/corelib/src/implementation/co...
File corelib/src/implementation/collections.dart (right):

https://codereview.chromium.org/10832060/diff/1/corelib/src/implementation/co...
corelib/src/implementation/collections.dart:10: class Collections {
On 2012/08/08 07:19:14, Lasse Reichstein Nielsen wrote:
> This class should die. Horribly.
> Instead there should be:
>   class Collection<T> {
>     factory Collection.from(Iterable<T> iterable);
>     ...
>   }
> so instad of:
>  Collections.forEach(iterable, f)
> you do:
>  new Collection.from(iterable).forEach(f);
> for the *rare* case where all you have is an iterable.

Agreed. I'll gladly create a CL for this in a weeks time!

https://codereview.chromium.org/10832060/diff/1/corelib/src/implementation/co...
corelib/src/implementation/collections.dart:39: for (final e in iterable) {
On 2012/08/10 11:26:56, Lasse Reichstein Nielsen wrote:
> We do. We shoud. Please start here :)

Done.

Powered by Google App Engine
This is Rietveld 408576698