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

Issue 277563007: Add MapKeySet and MapValueSet to the collection package. (Closed)

Created:
6 years, 7 months ago by nweiz
Modified:
6 years, 7 months ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add MapKeySet and MapValueSet to the collection package. These classes provide Set views that are implemented as Maps under the covers. BUG=18705 R=floitsch@google.com, lrn@google.com Committed: https://code.google.com/p/dart/source/detail?r=36447

Patch Set 1 #

Total comments: 4

Patch Set 2 : more documentation #

Total comments: 39

Patch Set 3 : code review #

Total comments: 13

Patch Set 4 : code review #

Total comments: 4

Patch Set 5 : code review #

Unified diffs Side-by-side diffs Delta from patch set Stats (+623 lines, -11 lines) Patch
A pkg/collection/CHANGELOG.md View 1 chunk +7 lines, -0 lines 0 comments Download
M pkg/collection/lib/wrappers.dart View 1 2 3 4 3 chunks +238 lines, -10 lines 0 comments Download
M pkg/collection/pubspec.yaml View 1 chunk +1 line, -1 line 0 comments Download
M pkg/collection/test/wrapper_test.dart View 1 2 3 4 2 chunks +377 lines, -0 lines 0 comments Download

Messages

Total messages: 19 (0 generated)
nweiz
6 years, 7 months ago (2014-05-08 20:11:39 UTC) #1
kevmoo
DBC https://codereview.chromium.org/277563007/diff/1/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/1/pkg/collection/lib/wrappers.dart#newcode395 pkg/collection/lib/wrappers.dart:395: * This class can be used to make ...
6 years, 7 months ago (2014-05-08 20:40:14 UTC) #2
nweiz
https://codereview.chromium.org/277563007/diff/1/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/1/pkg/collection/lib/wrappers.dart#newcode395 pkg/collection/lib/wrappers.dart:395: * This class can be used to make a ...
6 years, 7 months ago (2014-05-08 21:14:55 UTC) #3
kevmoo
https://codereview.chromium.org/277563007/diff/1/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/1/pkg/collection/lib/wrappers.dart#newcode395 pkg/collection/lib/wrappers.dart:395: * This class can be used to make a ...
6 years, 7 months ago (2014-05-08 23:01:53 UTC) #4
nweiz
https://codereview.chromium.org/277563007/diff/1/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/1/pkg/collection/lib/wrappers.dart#newcode395 pkg/collection/lib/wrappers.dart:395: * This class can be used to make a ...
6 years, 7 months ago (2014-05-09 02:48:50 UTC) #5
Lasse Reichstein Nielsen
Florian, could you take a look at this and see if I missed something? https://codereview.chromium.org/277563007/diff/20001/pkg/collection/lib/wrappers.dart ...
6 years, 7 months ago (2014-05-09 09:00:17 UTC) #6
floitsch
LGTM. https://codereview.chromium.org/277563007/diff/20001/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/20001/pkg/collection/lib/wrappers.dart#newcode358 pkg/collection/lib/wrappers.dart:358: * is not `O(1)` for this set. On ...
6 years, 7 months ago (2014-05-09 09:49:41 UTC) #7
Lasse Reichstein Nielsen
https://codereview.chromium.org/277563007/diff/20001/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/20001/pkg/collection/lib/wrappers.dart#newcode358 pkg/collection/lib/wrappers.dart:358: * is not `O(1)` for this set. It's not ...
6 years, 7 months ago (2014-05-09 10:50:47 UTC) #8
Lasse Reichstein Nielsen
https://codereview.chromium.org/277563007/diff/20001/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/20001/pkg/collection/lib/wrappers.dart#newcode358 pkg/collection/lib/wrappers.dart:358: * is not `O(1)` for this set. Should ofcourse ...
6 years, 7 months ago (2014-05-09 10:52:51 UTC) #9
nweiz
https://codereview.chromium.org/277563007/diff/20001/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/20001/pkg/collection/lib/wrappers.dart#newcode354 pkg/collection/lib/wrappers.dart:354: * Creates an unmodifiable [Set] that delegates all operations ...
6 years, 7 months ago (2014-05-19 20:58:48 UTC) #10
Lasse Reichstein Nielsen
lgtm https://codereview.chromium.org/277563007/diff/40001/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/40001/pkg/collection/lib/wrappers.dart#newcode394 pkg/collection/lib/wrappers.dart:394: where((element) => !other.contains(element)).toSet(); Maybe do: toSet()..removeWhere(other.contains) and for ...
6 years, 7 months ago (2014-05-20 12:26:31 UTC) #11
nweiz
https://codereview.chromium.org/277563007/diff/40001/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/40001/pkg/collection/lib/wrappers.dart#newcode394 pkg/collection/lib/wrappers.dart:394: where((element) => !other.contains(element)).toSet(); On 2014/05/20 12:26:31, Lasse Reichstein Nielsen ...
6 years, 7 months ago (2014-05-20 21:35:23 UTC) #12
Lasse Reichstein Nielsen
https://codereview.chromium.org/277563007/diff/40001/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/40001/pkg/collection/lib/wrappers.dart#newcode394 pkg/collection/lib/wrappers.dart:394: where((element) => !other.contains(element)).toSet(); I thought about that, but you ...
6 years, 7 months ago (2014-05-21 05:57:43 UTC) #13
nweiz
https://codereview.chromium.org/277563007/diff/40001/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/40001/pkg/collection/lib/wrappers.dart#newcode394 pkg/collection/lib/wrappers.dart:394: where((element) => !other.contains(element)).toSet(); On 2014/05/21 05:57:44, Lasse Reichstein Nielsen ...
6 years, 7 months ago (2014-05-21 18:00:55 UTC) #14
Lasse Reichstein Nielsen
https://codereview.chromium.org/277563007/diff/40001/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/40001/pkg/collection/lib/wrappers.dart#newcode394 pkg/collection/lib/wrappers.dart:394: where((element) => !other.contains(element)).toSet(); It's not impossible to add methods ...
6 years, 7 months ago (2014-05-21 19:01:06 UTC) #15
nweiz
https://codereview.chromium.org/277563007/diff/60001/pkg/collection/lib/wrappers.dart File pkg/collection/lib/wrappers.dart (right): https://codereview.chromium.org/277563007/diff/60001/pkg/collection/lib/wrappers.dart#newcode549 pkg/collection/lib/wrappers.dart:549: _baseMap[pair.first] = pair.last; On 2014/05/21 19:01:06, Lasse Reichstein Nielsen ...
6 years, 7 months ago (2014-05-21 19:28:19 UTC) #16
Lasse Reichstein Nielsen
Yes, lgtm!
6 years, 7 months ago (2014-05-21 20:21:29 UTC) #17
nweiz
Committed patchset #5 manually as r36447 (presubmit successful).
6 years, 7 months ago (2014-05-21 20:26:08 UTC) #18
Lasse Reichstein Nielsen
6 years, 7 months ago (2014-05-22 07:45:56 UTC) #19
Message was sent while issue was closed.
Now I finally got my head wrapped around the MapValueSet.
Sleeping on it might be the thing :)

It's really equivalent to:
  new Set(equals: (a, b) => 
              equals(keyFromValue(a), keyFromValue(b)), 
          hashCode: (a) => hashCode(keyFromValue(a)))
where equals and hashCode form the equality of the underlying map (well, if it
is hash based). 

The only difference is that the MapValueSet caches the results of keyFromValue
and builds the inverse mapping in a map.

I've kept thinking that you put in a pre-filled map as base map, but if you use
an empty map, it is really just representing the equality on the keys.

Powered by Google App Engine
This is Rietveld 408576698