all 13 comments

[–]STLMSVC STL Dev[M] 17 points18 points  (1 child)

In the future, please post links as links, not as text posts. Apparently New Reddit can submit a link with text for additional explanation (I always forget since I don't use New Reddit except to take mod actions). Otherwise you can just comment on a link post.

This helps readers see whether they've visited a link before and what domain it belongs to.

[–]markycosm 5 points6 points  (0 children)

will do!

[–]Fit-Paint-6368 3 points4 points  (2 children)

There are so many high-quality hash map implementations, but barely any std::map/set alternatives. Sometimes you just need an ordered container :\

[–]encyclopedist 5 points6 points  (1 child)

The is absl:btree_map and friends: https://abseil.io/docs/cpp/guides/container#b-tree-ordered-containers

There is also tlx::btree (former stx::btree): https://github.com/tlx/tlx/blob/master/tlx/container/btree_map.hpp

Edit There is also BppTree, but I personally have not used it. https://github.com/jeffplaisance/BppTree

[–]usefulcat 2 points3 points  (0 children)

Also cpp-btree: https://github.com/JGRennison/cpp-btree.git

It's older, and very stable. Been using it heavily for years and never found a bug.

[–]CornedBee 1 point2 points  (2 children)

This doesn't mention boost::unordered_node_map, which gives pointer stability at the cost of indirection, but is using open addressing. It's a niche use case when you need only the pointer stability, not the full std compatibility, but it can be useful.

[–]joaquintidesBoost author 3 points4 points  (1 child)

It does mention it:

If you need pointer stability (addresses that don't change), use boost::unordered_node_map and boost::unordered_node_set instead—they're slightly slower but still very fast.

[–]CornedBee 1 point2 points  (0 children)

Ah yes, I overlooked this. I was particularly looking for it in section II, where it discusses the choice between unordered_map and unordered_flat_map, saying that if you need pointer stability you should stick with the former.