On 11/06/2019 10:28, Ulf Hermann wrote:

So, not having read the discussion about the equivalent container in
std, I'll make a naive suggestion here:

What about finding a QSortedVector that works for 90% of our internal
cases and adding that as private API (for now). The remaining 10% will
need custom solutions or keep using QHash/QMap, but replacing the 90%
will give us most of the possible efficiency gains already.

I imagine that a vector which automatically sorts itself on the first
lookup after any changes if it's larger than X items could be a drop-in
replacement for most of the places where I misuse QHash or QMap. X could
be a template parameter or found by some heuristic.

It's fun to write containers and everything, but this stuff already exists, and it's ready to be used (under liberal licenses): boost::container::flat_map, absl::flat_hash_map, and so on. Maybe the only thing missing is a flat unordered container that doesn't use hashing at all (just a vector of elements compared with op== for detecting duplicates, for very small workloads).

Anyhow, given all of this isn't meant for public APIs, let's just use them and move on?

My 2 c,
--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to