QMap doesn't have equal_range?



  • Hello all,

    According to the docs, "QMap":http://qt-project.org/doc/qt-5/qmap.html#equal_range includes the equal_range algorithm, but actually it doesn't (Qt 5.2). Is it deliberately left out? In that case, an update to the doc is needed. For the time being I'm mixing QMap and std::multimap to get the functionality I want, but I would rather avoid it.

    Anyway, where/who should I ask to have it included?


  • Moderators

    You need to check on "JIRA":https://bugreports.qt-project.org/secure/Dashboard.jspa if it has been reported already otherwise you need to report it.
    The doc-link you are providing points to Qt 5.2 documentation. So there is a problem.



  • This method exists in Qt 5.2.1 but according to git it was there for ages.
    qmap.h, line 861 contains this:
    @template <class Key, class T>
    QPair<typename QMap<Key, T>::iterator, typename QMap<Key, T>::iterator> QMap<Key, T>::equal_range(const Key &akey)
    {
    detach();
    Node *firstNode, *lastNode;
    d->nodeRange(akey, &firstNode, &lastNode);
    return QPair<iterator, iterator>(iterator(firstNode), iterator(lastNode));
    }
    @


  • Moderators

    [quote author="koval" date="1393070848"]This method exists in Qt 5.2.1 but according to git it was there for ages.
    qmap.h, line 861 contains this:
    @template <class Key, class T>
    QPair<typename QMap<Key, T>::iterator, typename QMap<Key, T>::iterator> QMap<Key, T>::equal_range(const Key &akey)
    {
    detach();
    Node *firstNode, *lastNode;
    d->nodeRange(akey, &firstNode, &lastNode);
    return QPair<iterator, iterator>(iterator(firstNode), iterator(lastNode));
    }
    @[/quote]

    Thanks for checking

    [quote author="panosk" date="1393068764"]Hello all,

    According to the docs, "QMap":http://qt-project.org/doc/qt-5/qmap.html#equal_range includes the equal_range algorithm, but actually it doesn't (Qt 5.2). Is it deliberately left out? In that case, an update to the doc is needed. For the time being I'm mixing QMap and std::multimap to get the functionality I want, but I would rather avoid it.

    Anyway, where/who should I ask to have it included?[/quote]

    So, it should be problem with your installation or your code.



  • Thank you both.

    Indeed, equal_range works if I type it manually, but Qt Creator 3 doesn't offer it or recognize it as a token for some reason, so it may be a bug with Qt Creator. Another issue with Qt Creator is that it doesn't offer the iterators for nested containers that don't have a space between the closing >> (no longer necessary in C++11).

    Can sb else confirm these issues too so I can file relative bugs? I've took a look in the bug tracker and couldn't find anything related.

    Thanks.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.