[Development] Views

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Tue Jun 11 11:44:49 CEST 2019

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.dangelo at 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20190611/f567cbd0/attachment.bin>

More information about the Development mailing list