QMap: find exact or lower
-
Hi All,
Do you know if there is QMap function to search for exact or lower value ? I'm aware of QMap::lower_bound() but this returns exact or upper.
Also, in terms of C++, if I do:
auto it = mymap.lower_bound(val);
Do you know which implementation is chosen ? it is the const or the non const one ?
If it is the non const one, what are the consequences (is the whole list duplicated ? I see a detach() in the code).Thanks
-
Hi All,
Do you know if there is QMap function to search for exact or lower value ? I'm aware of QMap::lower_bound() but this returns exact or upper.
Also, in terms of C++, if I do:
auto it = mymap.lower_bound(val);
Do you know which implementation is chosen ? it is the const or the non const one ?
If it is the non const one, what are the consequences (is the whole list duplicated ? I see a detach() in the code).Thanks
@dextermagnific said in QMap: find exact or lower:
Do you know which implementation is chosen ? it is the const or the non const one ?
If mymap is const then the const version, if not then the non-const version.
If it is the non const one, what are the consequences (is the whole list duplicated ? I see a detach() in the code).
It's only duplicated when it's needed (e.g. the ref count is greater than one).
-
Thanks a lot
-
@dextermagnific said in QMap: find exact or lower:
Do you know if there is QMap function to search for exact or lower value ? I'm aware of QMap::lower_bound() but this returns exact or upper.
Can you take the result of QMap::lower_bound() and, with appropriate checks, move the iterator to the previous position?
-
Yes I was planning to do it like this. Just asked to be sure that there was no way to get it (and also rationale behind this: in std lib there is also lower_bound() but not what I'm looking for. So had some doubt about doing something wrong).