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

Unified Diff: base/containers/README.md

Issue 2944523002: Improving flat containers interface. (Closed)
Patch Set: Removing redundant tests. Created 3 years, 6 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: base/containers/README.md
diff --git a/base/containers/README.md b/base/containers/README.md
index e64e8f3a637162d1b43b7d4df0f90e705289ecc9..2d3a08144a28dfc542b332a5e2277a1ec14f0cfb 100644
--- a/base/containers/README.md
+++ b/base/containers/README.md
@@ -46,7 +46,7 @@ Google naming. Be sure to use the base namespace.
* **base::small\_map** has better runtime memory usage without the poor
mutation performance of large containers that base::flat\_map has. But this
advantage is partially offset by additional code size. Prefer in cases
- where you make many objects so that the code/heap tradeoff is good.
+ where you make many objects so that the code/heap tradeoff is good.
* Use **std::map** and **std::set** if you can't decide. Even if they're not
great, they're unlikely to be bad or surprising.
@@ -124,6 +124,15 @@ strategy and the memory access pattern. Assuming items are being linearly added,
one would expect it to be 3/4 full, so per-item overhead will be 0.25 *
sizeof(T).
+By default they use base::less instead of std::less which adds a few extra
+features:
+a) base::less is based on std::less<> from C++14, therefore you can,for example,
+ lookup base::StringPiece in a set of strings without constructing a temporary
+ string.
+b) base::less operator() is specialized for SmartPointer to pointer comparisons
+ so you can directly use, for example, flat_set<\std::unique\_ptr> and use
+ raw pointers as keys if necessary.
+
### base::small\_map
A small inline buffer that is brute-force searched that overflows into a full
« no previous file with comments | « base/BUILD.gn ('k') | base/containers/flat_map.h » ('j') | base/containers/flat_map.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698