diff options
Diffstat (limited to 'src/corelib/tools/qmap.cpp')
-rw-r--r-- | src/corelib/tools/qmap.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index 75104e4825..e5de4a1bfd 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -538,6 +538,16 @@ void QMapDataBase::freeData(QMapDataBase *d) \sa toStdMap() */ +/*! \fn QMap::QMap(std::initializer_list<std::pair<Key,T> > list) + \since 5.1 + + Constructs a map with a copy of each of the elements in the + initializer list \a list. + + This function is only available if the program is being + compiled in C++11 mode. +*/ + /*! \fn std::map<Key, T> QMap::toStdMap() const Returns an STL map equivalent to this QMap. @@ -971,6 +981,32 @@ void QMapDataBase::freeData(QMapDataBase *d) \sa insertMulti() */ +/*! \fn QMap::iterator QMap::insert(const_iterator pos, const Key &key, const T &value) + \overload + \since 5.1 + Inserts a new item with the key \a key and value \a value and with hint \a pos + suggesting where to do the insert. + + If constBegin() is used as hint it indicates that the \a key is less than any key in the map + while constEnd() suggests that the \a key is (strictly) larger than any key in the map. + Otherwise the hint should meet the condition (\a pos - 1).key() < \a key <= pos.key(). + If the hint \a pos is wrong it is ignored and a regular insert is done. + + If there is already an item with the key \a key, that item's value + is replaced with \a value. + + If there are multiple items with the key \a key, then exactly one of them + is replaced with \a value. + + When creating a map from sorted data inserting the largest key first with constBegin() + is faster than inserting in sorted order with constEnd() + + \b {Note:} Be careful with the hint. Providing an iterator from an older shared instance might + crash but there is also a risk that it will silently corrupt both the map and the \a pos map. + + \sa insertMulti() +*/ + /*! \fn QMap::iterator QMap::insertMulti(const Key &key, const T &value) Inserts a new item with the key \a key and a value of \a value. @@ -983,6 +1019,26 @@ void QMapDataBase::freeData(QMapDataBase *d) \sa insert(), values() */ +/*! \fn QMap::iterator QMap::insertMulti(const_iterator pos, const Key &key, const T &value) + \overload + \since 5.1 + Inserts a new item with the key \a key and value \a value and with hint \a pos + suggesting where to do the insert. + + If constBegin() is used as hint it indicates that the \a key is less than any key in the map + while constEnd() suggests that the \a key is larger than any key in the map. + Otherwise the hint should meet the condition (\a pos - 1).key() < \a key <= pos.key(). + If the hint \a pos is wrong it is ignored and a regular insertMulti is done. + + If there is already an item with the same key in the map, this function will simply create a new one. + + \b {Note:} Be careful with the hint. Providing an iterator from an older shared instance might + crash but there is also a risk that it will silently corrupt both the map and the \a pos map. + + \sa insert() +*/ + + /*! \fn QMap<Key, T> &QMap::unite(const QMap<Key, T> &other) Inserts all the items in the \a other map into this map. If a @@ -1576,6 +1632,16 @@ void QMapDataBase::freeData(QMapDataBase *d) Constructs an empty map. */ +/*! \fn QMultiMap::QMultiMap(std::initializer_list<std::pair<Key,T> > list) + \since 5.1 + + Constructs a multi map with a copy of each of the elements in the + initializer list \a list. + + This function is only available if the program is being + compiled in C++11 mode. +*/ + /*! \fn QMultiMap::QMultiMap(const QMap<Key, T> &other) Constructs a copy of \a other (which can be a QMap or a @@ -1609,6 +1675,23 @@ void QMapDataBase::freeData(QMapDataBase *d) \sa replace() */ +/*! \fn QMultiMap::iterator QMultiMap::insert(QMap<Key, T>::const_iterator pos, const Key &key, const T &value) + + \since 5.1 + Inserts a new item with the key \a key and value \a value and with hint \a pos + suggesting where to do the insert. + + If constBegin() is used as hint it indicates that the \a key is less than any key in the map + while constEnd() suggests that the \a key is larger than any key in the map. + Otherwise the hint should meet the condition (\a pos - 1).key() < \a key <= pos.key(). + If the hint \a pos is wrong it is ignored and a regular insert is done. + + If there is already an item with the same key in the map, this function will simply create a new one. + + \b {Note:} Be careful with the hint. Providing an iterator from an older shared instance might + crash but there is also a risk that it will silently corrupt both the map and the \a pos map. +*/ + /*! \fn QMultiMap &QMultiMap::operator+=(const QMultiMap &other) Inserts all the items in the \a other map into this map and |