[Development] implicit sharing and iterators in qt containers

Thiago Macieira thiago.macieira at intel.com
Mon Jul 31 23:57:54 CEST 2017


On segunda-feira, 31 de julho de 2017 14:36:59 PDT Mandeep Sandhu wrote:
> > I'd expect to be able to use keys that do not define qHash or qLess.
> 
> Why?

My type key type may be or contain an opaque non-orderable type, which would 
make implementing both qHash and qLess impossible. Right now, if you have such 
a key type, you can't use QMap or QHash. Example type: QVariant.

Therefore, for this new container to add something we currently do not have, 
it MUST NOT require either function.

> > Search would be O(n). So be it.
> 
> Well it wouldn't be much of a "map" then, would it?

Sure it would. There's nothing that requires associative containers to have 
search times better than O(n). It just happens that both std::map and QMap 
implements them at O(log n).

> I see OrderedMap
> similar to a QMap, just with a different key ordering scheme. So in that
> way, constant time lookups would be _must_ I would say (although QMap
> lookups log(n) time). It is after all a key-value store.

No, sorry, I won't accept that container in Qt.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list