[Development] Views
Konstantin Shegunov
kshegunov at gmail.com
Tue Jun 11 10:42:32 CEST 2019
On Tue, Jun 11, 2019 at 11:31 AM Ulf Hermann <ulf.hermann at qt.io> wrote:
> 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.
>
I though about this as well. There's one caveat though. It can't be
(easily) made COW (if we require it). If your lookup is non-mutable (i.e.
`constFind` or w/e it's named), it'd mean that you have to mutate the data
in a const method. This implies doing it (thread-)safely is going to get
rather clumsy as there are 2 possibilities I see:
1) Detach in the `const` lookup if the data's dirty (i.e. not sorted) and
then sort it, and then do the lookup.
2) Lock the data block, sort it and then do the lookup.
Do I miss something?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20190611/9a5059be/attachment.html>
More information about the Development
mailing list