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

Issue 2715433007: Add a flat_map container (Closed)

Created:
3 years, 10 months ago by brettw
Modified:
3 years, 8 months ago
CC:
chromium-reviews, vmpstr+watch_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Add a flat_map container. This works the same as flat_set but corresponding to a std::map. The existing flat_set implementation was factored into a base class called flat_tree with a provision to have a potentially different lookup key type than value type, and a way to convert from a value to a key. flat_set and flat_map can be trivially implemented on top of this API. The existing flat_set tests are moved to flat-tree and some simple type-specific tests were created for the set and map derivations. flat_tree no longer copies the comparison object except when required (when returned by value_comp()). But this requires that the comparison functor be const which was not the case before. Review-Url: https://codereview.chromium.org/2715433007 Cr-Commit-Position: refs/heads/master@{#458796} Committed: https://chromium.googlesource.com/chromium/src/+/9816813a28b7f20ef03ff69d901d3b9a891f0400

Patch Set 1 : Base for review #

Patch Set 2 : New #

Total comments: 18

Patch Set 3 : Fix #

Total comments: 15

Patch Set 4 : Review comments #

Patch Set 5 : Posix #

Patch Set 6 : Fixes #

Total comments: 4

Patch Set 7 : Remove noexcept #

Patch Set 8 : Comments #

Total comments: 3

Patch Set 9 : Merge and unsafe_emplace #

Patch Set 10 : Fix EraseIf #

Total comments: 13

Patch Set 11 : Review comments #

Total comments: 1

Patch Set 12 : Nit #

Total comments: 10

Patch Set 13 : Comments #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+1484 lines, -1997 lines) Patch
M base/BUILD.gn View 1 2 3 4 5 6 7 8 2 chunks +5 lines, -0 lines 0 comments Download
A base/containers/container_test_utils.h View 1 2 3 1 chunk +39 lines, -0 lines 0 comments Download
A base/containers/flat_map.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +266 lines, -0 lines 2 comments Download
A base/containers/flat_map_unittest.cc View 1 2 3 4 5 6 7 8 11 12 1 chunk +140 lines, -0 lines 0 comments Download
M base/containers/flat_set.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +78 lines, -590 lines 0 comments Download
M base/containers/flat_set_unittest.cc View 1 2 3 4 5 6 7 8 2 chunks +40 lines, -1206 lines 0 comments Download
A base/containers/flat_tree.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +717 lines, -0 lines 0 comments Download
A + base/containers/flat_tree_unittest.cc View 1 2 3 4 5 6 7 8 9 10 47 chunks +199 lines, -201 lines 0 comments Download

Messages

Total messages: 123 (61 generated)
brettw
Set tests pass:
3 years, 10 months ago (2017-02-24 00:31:27 UTC) #1
brettw
New
3 years, 10 months ago (2017-02-24 21:22:45 UTC) #8
brettw
new
3 years, 10 months ago (2017-02-24 21:24:20 UTC) #9
brettw
New
3 years, 10 months ago (2017-02-24 21:25:46 UTC) #10
brettw
I was doing some container research and we also want to experiment with this class ...
3 years, 10 months ago (2017-02-24 21:26:56 UTC) #15
dyaroshev
Really glad that you've decided to do this! >But this requires that the comparison functor ...
3 years, 10 months ago (2017-02-24 22:55:49 UTC) #24
dyaroshev
https://codereview.chromium.org/2715433007/diff/180001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/180001/base/containers/flat_map.h#newcode440 base/containers/flat_map.h:440: } As written this seems to do an extra ...
3 years, 10 months ago (2017-02-25 06:15:04 UTC) #25
dyaroshev
On 2017/02/24 22:55:49, dyaroshev wrote: > My main conscern is: have you thought of possibly ...
3 years, 9 months ago (2017-02-26 06:54:59 UTC) #26
dyaroshev
https://codereview.chromium.org/2715433007/diff/180001/base/containers/flat_tree.h File base/containers/flat_tree.h (right): https://codereview.chromium.org/2715433007/diff/180001/base/containers/flat_tree.h#newcode83 base/containers/flat_tree.h:83: flat_tree(flat_tree&&); I recently realised, that this won't be noexcept. ...
3 years, 9 months ago (2017-02-27 07:26:39 UTC) #27
brettw
New snap up. I implemented flat_set as a typedef and flat_map as a derived class. ...
3 years, 9 months ago (2017-02-27 19:20:15 UTC) #28
brettw
Posix
3 years, 9 months ago (2017-02-27 20:50:45 UTC) #33
brettw
Posix
3 years, 9 months ago (2017-02-27 20:53:48 UTC) #34
dyaroshev
On brettw said: I implemented flat_set as a typedef and flat_map as a derived class. ...
3 years, 9 months ago (2017-02-27 22:23:38 UTC) #40
dyaroshev
On 2017/02/27 22:23:38, dyaroshev wrote: > On brettw said: > ============================= > > I'd rather ...
3 years, 9 months ago (2017-02-28 00:07:52 UTC) #41
brettw
Fixes
3 years, 9 months ago (2017-02-28 18:01:27 UTC) #42
brettw
New snap up. I actually started implementing map on top of set. I found it ...
3 years, 9 months ago (2017-02-28 18:05:59 UTC) #45
dyaroshev
On 2017/02/28 18:05:59, brettw (plz ping after 24h) wrote: > New snap up. > > ...
3 years, 9 months ago (2017-02-28 18:11:11 UTC) #46
brettw
Remove noexcept
3 years, 9 months ago (2017-02-28 18:26:12 UTC) #49
brettw
noexcept didn't go well so I removed the specifications. The problem was in flat_tree::Impl's constructor. ...
3 years, 9 months ago (2017-02-28 18:29:04 UTC) #50
brettw
Comments
3 years, 9 months ago (2017-02-28 18:31:03 UTC) #51
dyaroshev
On 2017/02/28 18:29:04, brettw (plz ping after 24h) wrote: > noexcept didn't go well so ...
3 years, 9 months ago (2017-02-28 18:31:19 UTC) #52
brettw
New snap up with more "not stable" comments in the constructors.
3 years, 9 months ago (2017-02-28 18:32:31 UTC) #53
dyaroshev
https://codereview.chromium.org/2715433007/diff/260001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/260001/base/containers/flat_map.h#newcode76 base/containers/flat_map.h:76: const Compare& comp = Compare()); It would be nice ...
3 years, 9 months ago (2017-02-28 18:40:53 UTC) #56
dyaroshev
LGTM https://codereview.chromium.org/2715433007/diff/260001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/260001/base/containers/flat_map.h#newcode76 base/containers/flat_map.h:76: const Compare& comp = Compare()); On 2017/02/28 18:40:53, ...
3 years, 9 months ago (2017-03-06 17:41:55 UTC) #58
dyaroshev
ping @brettew.
3 years, 9 months ago (2017-03-13 18:03:45 UTC) #59
brettw
Merge and unsafe_emplace
3 years, 9 months ago (2017-03-20 22:41:32 UTC) #60
brettw
Was distracted by other work for a while. I uploaded a new patch. There was ...
3 years, 9 months ago (2017-03-20 22:42:19 UTC) #61
brettw
We should provide an EraseIf override for flat_map, but I would prefer to do that ...
3 years, 9 months ago (2017-03-20 22:47:58 UTC) #64
brettw
Fix EraseIf
3 years, 9 months ago (2017-03-20 23:04:36 UTC) #67
dyaroshev
Great that you are back! Just some nits. https://codereview.chromium.org/2715433007/diff/340001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/340001/base/containers/flat_map.h#newcode18 base/containers/flat_map.h:18: // ...
3 years, 9 months ago (2017-03-21 16:03:57 UTC) #72
brettw
Review comments
3 years, 9 months ago (2017-03-21 18:32:14 UTC) #73
brettw
https://codereview.chromium.org/2715433007/diff/340001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/340001/base/containers/flat_map.h#newcode39 base/containers/flat_map.h:39: class flat_map : public ::base::internal::flat_tree< On 2017/03/21 16:03:57, dyaroshev ...
3 years, 9 months ago (2017-03-21 18:32:51 UTC) #76
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2715433007/360001
3 years, 9 months ago (2017-03-21 18:33:25 UTC) #77
commit-bot: I haz the power
No L-G-T-M from a valid reviewer yet. CQ run can only be started once the ...
3 years, 9 months ago (2017-03-21 18:33:28 UTC) #79
dyaroshev
The smallest nit possible) https://codereview.chromium.org/2715433007/diff/360001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/360001/base/containers/flat_map.h#newcode105 base/containers/flat_map.h:105: const Mapped& at(const Key& key) ...
3 years, 9 months ago (2017-03-21 18:40:37 UTC) #80
brettw
Nit
3 years, 9 months ago (2017-03-21 19:42:37 UTC) #81
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2715433007/380001
3 years, 9 months ago (2017-03-21 19:43:09 UTC) #84
commit-bot: I haz the power
No L-G-T-M from a valid reviewer yet. CQ run can only be started once the ...
3 years, 9 months ago (2017-03-21 19:43:12 UTC) #86
dyaroshev
On 2017/03/21 19:43:12, commit-bot: I haz the power wrote: > No L-G-T-M from a valid ...
3 years, 9 months ago (2017-03-21 19:45:00 UTC) #89
danakj
https://codereview.chromium.org/2715433007/diff/380001/base/containers/container_test_utils.h File base/containers/container_test_utils.h (right): https://codereview.chromium.org/2715433007/diff/380001/base/containers/container_test_utils.h#newcode1 base/containers/container_test_utils.h:1: // Copyright 2017 The Chromium Authors. All rights reserved. ...
3 years, 9 months ago (2017-03-21 20:28:56 UTC) #90
dyaroshev
https://codereview.chromium.org/2715433007/diff/380001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/380001/base/containers/flat_map.h#newcode189 base/containers/flat_map.h:189: CHECK(found != tree::end()); On 2017/03/21 20:28:56, danakj wrote: > ...
3 years, 9 months ago (2017-03-21 20:34:46 UTC) #91
danakj
https://codereview.chromium.org/2715433007/diff/380001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/380001/base/containers/flat_map.h#newcode189 base/containers/flat_map.h:189: CHECK(found != tree::end()); On 2017/03/21 20:34:46, dyaroshev wrote: > ...
3 years, 9 months ago (2017-03-21 21:38:39 UTC) #94
dyaroshev
On 2017/03/21 21:38:39, danakj wrote: > https://codereview.chromium.org/2715433007/diff/380001/base/containers/flat_map.h > File base/containers/flat_map.h (right): > > https://codereview.chromium.org/2715433007/diff/380001/base/containers/flat_map.h#newcode189 > ...
3 years, 9 months ago (2017-03-21 21:42:56 UTC) #95
danakj
On Tue, Mar 21, 2017 at 5:42 PM, <dyaroshev@yandex-team.ru> wrote: > On 2017/03/21 21:38:39, danakj ...
3 years, 9 months ago (2017-03-21 22:03:58 UTC) #96
danakj
On Tue, Mar 21, 2017 at 6:03 PM, <danakj+reviewer@chromium.org> wrote: > On Tue, Mar 21, ...
3 years, 9 months ago (2017-03-21 22:10:55 UTC) #97
danakj
On Tue, Mar 21, 2017 at 6:10 PM, <danakj+reviewer@chromium.org> wrote: > > > On Tue, ...
3 years, 9 months ago (2017-03-21 22:27:29 UTC) #98
brettw
https://codereview.chromium.org/2715433007/diff/380001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/380001/base/containers/flat_map.h#newcode95 base/containers/flat_map.h:95: // Normal insert() functions are inherited from flat_tree. On ...
3 years, 9 months ago (2017-03-21 23:19:54 UTC) #99
danakj
LGTM https://codereview.chromium.org/2715433007/diff/380001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/380001/base/containers/flat_map.h#newcode95 base/containers/flat_map.h:95: // Normal insert() functions are inherited from flat_tree. ...
3 years, 9 months ago (2017-03-21 23:25:01 UTC) #100
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2715433007/400001
3 years, 9 months ago (2017-03-21 23:30:32 UTC) #103
commit-bot: I haz the power
Try jobs failed on following builders: chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_chromium_compile_only_ng/builds/303171)
3 years, 9 months ago (2017-03-22 00:03:26 UTC) #105
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2715433007/400001
3 years, 9 months ago (2017-03-22 03:10:27 UTC) #107
commit-bot: I haz the power
Try jobs failed on following builders: ios-simulator on master.tryserver.chromium.mac (JOB_TIMED_OUT, build hasn't started yet, builder ...
3 years, 9 months ago (2017-03-22 05:12:11 UTC) #109
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2715433007/400001
3 years, 9 months ago (2017-03-22 17:15:00 UTC) #111
commit-bot: I haz the power
Committed patchset #13 (id:400001) as https://chromium.googlesource.com/chromium/src/+/9816813a28b7f20ef03ff69d901d3b9a891f0400
3 years, 9 months ago (2017-03-22 17:57:10 UTC) #114
brettw
FYI I'm adding back "noexcept" to the move constructors in a separate change. I assumed ...
3 years, 9 months ago (2017-03-22 21:44:57 UTC) #115
brettw
On 2017/03/22 21:44:57, brettw (plz ping after 24h) wrote: > FYI I'm adding back "noexcept" ...
3 years, 9 months ago (2017-03-22 22:14:39 UTC) #116
dyaroshev
On 2017/03/22 22:14:39, brettw (plz ping after 24h) wrote: > On 2017/03/22 21:44:57, brettw (plz ...
3 years, 9 months ago (2017-03-23 09:54:27 UTC) #117
dyaroshev
On 2017/03/22 22:14:39, brettw (plz ping after 24h) wrote: > On 2017/03/22 21:44:57, brettw (plz ...
3 years, 9 months ago (2017-03-23 09:54:34 UTC) #118
brettw
noexcept on Windows is blocked on this landing: https://codereview.chromium.org/2769283002/ which should hopefully go in today. ...
3 years, 9 months ago (2017-03-23 22:06:24 UTC) #119
DaleCurtis
https://codereview.chromium.org/2715433007/diff/400001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/400001/base/containers/flat_map.h#newcode243 base/containers/flat_map.h:243: found = unsafe_emplace(found, key, Mapped()); Did you mean tree::unsafe_emplace() ...
3 years, 8 months ago (2017-03-29 01:16:42 UTC) #121
dyaroshev
https://codereview.chromium.org/2715433007/diff/400001/base/containers/flat_map.h File base/containers/flat_map.h (right): https://codereview.chromium.org/2715433007/diff/400001/base/containers/flat_map.h#newcode243 base/containers/flat_map.h:243: found = unsafe_emplace(found, key, Mapped()); On 2017/03/29 01:16:42, DaleCurtis ...
3 years, 8 months ago (2017-03-29 11:13:22 UTC) #122
dyaroshev
3 years, 8 months ago (2017-03-31 17:20:42 UTC) #123
Message was sent while issue was closed.
And we broke this usage:

template <typename ... Args>
using this_set = base::flat_set<Args...>;

Usings are not OK with unpacking.

Powered by Google App Engine
This is Rietveld 408576698