| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qmap.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||
| 24 | ** | - | ||||||||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||
| 35 | ** | - | ||||||||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
| 37 | ** | - | ||||||||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | #include "qmap.h" | - | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | #include <stdlib.h> | - | ||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | #ifdef QT_QMAP_DEBUG | - | ||||||||||||||||||
| 45 | # include <qstring.h> | - | ||||||||||||||||||
| 46 | # include <qvector.h> | - | ||||||||||||||||||
| 47 | #endif | - | ||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | const QMapDataBase QMapDataBase::shared_null = { Q_REFCOUNT_INITIALIZE_STATIC, 0, { 0, 0, 0 }, 0 }; | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | const QMapNodeBase *QMapNodeBase::nextNode() const | - | ||||||||||||||||||
| 54 | { | - | ||||||||||||||||||
| 55 | const QMapNodeBase *n = this; | - | ||||||||||||||||||
| 56 | if (n->right) {
| 363001-776272 | ||||||||||||||||||
| 57 | n = n->right; | - | ||||||||||||||||||
| 58 | while (n->left)
| 317537-363001 | ||||||||||||||||||
| 59 | n = n->left; executed 317537 times by 175 tests: n = n->left;Executed by:
| 317537 | ||||||||||||||||||
| 60 | } else { executed 363001 times by 333 tests: end of blockExecuted by:
| 363001 | ||||||||||||||||||
| 61 | const QMapNodeBase *y = n->parent(); | - | ||||||||||||||||||
| 62 | while (y && n == y->right) {
| 0-1230563 | ||||||||||||||||||
| 63 | n = y; | - | ||||||||||||||||||
| 64 | y = n->parent(); | - | ||||||||||||||||||
| 65 | } executed 454291 times by 329 tests: end of blockExecuted by:
| 454291 | ||||||||||||||||||
| 66 | n = y; | - | ||||||||||||||||||
| 67 | } executed 776272 times by 372 tests: end of blockExecuted by:
| 776272 | ||||||||||||||||||
| 68 | return n; executed 1139273 times by 372 tests: return n;Executed by:
| 1139273 | ||||||||||||||||||
| 69 | } | - | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | const QMapNodeBase *QMapNodeBase::previousNode() const | - | ||||||||||||||||||
| 72 | { | - | ||||||||||||||||||
| 73 | const QMapNodeBase *n = this; | - | ||||||||||||||||||
| 74 | if (n->left) {
| 35601-73229 | ||||||||||||||||||
| 75 | n = n->left; | - | ||||||||||||||||||
| 76 | while (n->right)
| 73229-92042 | ||||||||||||||||||
| 77 | n = n->right; executed 92042 times by 28 tests: n = n->right;Executed by:
| 92042 | ||||||||||||||||||
| 78 | } else { executed 73229 times by 34 tests: end of blockExecuted by:
| 73229 | ||||||||||||||||||
| 79 | const QMapNodeBase *y = n->parent(); | - | ||||||||||||||||||
| 80 | while (y && n == y->left) {
| 24-58796 | ||||||||||||||||||
| 81 | n = y; | - | ||||||||||||||||||
| 82 | y = n->parent(); | - | ||||||||||||||||||
| 83 | } executed 23219 times by 12 tests: end of blockExecuted by:
| 23219 | ||||||||||||||||||
| 84 | n = y; | - | ||||||||||||||||||
| 85 | } executed 35601 times by 23 tests: end of blockExecuted by:
| 35601 | ||||||||||||||||||
| 86 | return n; executed 108830 times by 34 tests: return n;Executed by:
| 108830 | ||||||||||||||||||
| 87 | } | - | ||||||||||||||||||
| 88 | - | |||||||||||||||||||
| 89 | - | |||||||||||||||||||
| 90 | void QMapDataBase::rotateLeft(QMapNodeBase *x) | - | ||||||||||||||||||
| 91 | { | - | ||||||||||||||||||
| 92 | QMapNodeBase *&root = header.left; | - | ||||||||||||||||||
| 93 | QMapNodeBase *y = x->right; | - | ||||||||||||||||||
| 94 | x->right = y->left; | - | ||||||||||||||||||
| 95 | if (y->left != 0)
| 90196-168671 | ||||||||||||||||||
| 96 | y->left->setParent(x); executed 90196 times by 343 tests: y->left->setParent(x);Executed by:
| 90196 | ||||||||||||||||||
| 97 | y->setParent(x->parent()); | - | ||||||||||||||||||
| 98 | if (x == root)
| 42071-216796 | ||||||||||||||||||
| 99 | root = y; executed 42071 times by 470 tests: root = y;Executed by:
| 42071 | ||||||||||||||||||
| 100 | else if (x == x->parent()->left)
| 21189-195607 | ||||||||||||||||||
| 101 | x->parent()->left = y; executed 21189 times by 276 tests: x->parent()->left = y;Executed by:
| 21189 | ||||||||||||||||||
| 102 | else | - | ||||||||||||||||||
| 103 | x->parent()->right = y; executed 195607 times by 160 tests: x->parent()->right = y;Executed by:
| 195607 | ||||||||||||||||||
| 104 | y->left = x; | - | ||||||||||||||||||
| 105 | x->setParent(y); | - | ||||||||||||||||||
| 106 | } executed 258867 times by 475 tests: end of blockExecuted by:
| 258867 | ||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | - | |||||||||||||||||||
| 109 | void QMapDataBase::rotateRight(QMapNodeBase *x) | - | ||||||||||||||||||
| 110 | { | - | ||||||||||||||||||
| 111 | QMapNodeBase *&root = header.left; | - | ||||||||||||||||||
| 112 | QMapNodeBase *y = x->left; | - | ||||||||||||||||||
| 113 | x->left = y->right; | - | ||||||||||||||||||
| 114 | if (y->right != 0)
| 109841-156511 | ||||||||||||||||||
| 115 | y->right->setParent(x); executed 109841 times by 115 tests: y->right->setParent(x);Executed by:
| 109841 | ||||||||||||||||||
| 116 | y->setParent(x->parent()); | - | ||||||||||||||||||
| 117 | if (x == root)
| 2172-264180 | ||||||||||||||||||
| 118 | root = y; executed 2172 times by 94 tests: root = y;Executed by:
| 2172 | ||||||||||||||||||
| 119 | else if (x == x->parent()->right)
| 47522-216658 | ||||||||||||||||||
| 120 | x->parent()->right = y; executed 47522 times by 249 tests: x->parent()->right = y;Executed by:
| 47522 | ||||||||||||||||||
| 121 | else | - | ||||||||||||||||||
| 122 | x->parent()->left = y; executed 216658 times by 190 tests: x->parent()->left = y;Executed by:
| 216658 | ||||||||||||||||||
| 123 | y->right = x; | - | ||||||||||||||||||
| 124 | x->setParent(y); | - | ||||||||||||||||||
| 125 | } executed 266352 times by 310 tests: end of blockExecuted by:
| 266352 | ||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | void QMapDataBase::rebalance(QMapNodeBase *x) | - | ||||||||||||||||||
| 129 | { | - | ||||||||||||||||||
| 130 | QMapNodeBase *&root = header.left; | - | ||||||||||||||||||
| 131 | x->setColor(QMapNodeBase::Red); | - | ||||||||||||||||||
| 132 | while (x != root && x->parent()->color() == QMapNodeBase::Red) {
| 387005-1480966 | ||||||||||||||||||
| 133 | if (x->parent() == x->parent()->parent()->left) {
| 451226-469892 | ||||||||||||||||||
| 134 | QMapNodeBase *y = x->parent()->parent()->right; | - | ||||||||||||||||||
| 135 | if (y && y->color() == QMapNodeBase::Red) {
| 108866-331793 | ||||||||||||||||||
| 136 | x->parent()->setColor(QMapNodeBase::Black); | - | ||||||||||||||||||
| 137 | y->setColor(QMapNodeBase::Black); | - | ||||||||||||||||||
| 138 | x->parent()->parent()->setColor(QMapNodeBase::Red); | - | ||||||||||||||||||
| 139 | x = x->parent()->parent(); | - | ||||||||||||||||||
| 140 | } else { executed 222927 times by 197 tests: end of blockExecuted by:
| 222927 | ||||||||||||||||||
| 141 | if (x == x->parent()->right) {
| 12492-215807 | ||||||||||||||||||
| 142 | x = x->parent(); | - | ||||||||||||||||||
| 143 | rotateLeft(x); | - | ||||||||||||||||||
| 144 | } executed 12492 times by 190 tests: end of blockExecuted by:
| 12492 | ||||||||||||||||||
| 145 | x->parent()->setColor(QMapNodeBase::Black); | - | ||||||||||||||||||
| 146 | x->parent()->parent()->setColor(QMapNodeBase::Red); | - | ||||||||||||||||||
| 147 | rotateRight (x->parent()->parent()); | - | ||||||||||||||||||
| 148 | } executed 228299 times by 208 tests: end of blockExecuted by:
| 228299 | ||||||||||||||||||
| 149 | } else { | - | ||||||||||||||||||
| 150 | QMapNodeBase *y = x->parent()->parent()->left; | - | ||||||||||||||||||
| 151 | if (y && y->color() == QMapNodeBase::Red) {
| 87051-312878 | ||||||||||||||||||
| 152 | x->parent()->setColor(QMapNodeBase::Black); | - | ||||||||||||||||||
| 153 | y->setColor(QMapNodeBase::Black); | - | ||||||||||||||||||
| 154 | x->parent()->parent()->setColor(QMapNodeBase::Red); | - | ||||||||||||||||||
| 155 | x = x->parent()->parent(); | - | ||||||||||||||||||
| 156 | } else { executed 225827 times by 178 tests: end of blockExecuted by:
| 225827 | ||||||||||||||||||
| 157 | if (x == x->parent()->left) {
| 37660-206405 | ||||||||||||||||||
| 158 | x = x->parent(); | - | ||||||||||||||||||
| 159 | rotateRight(x); | - | ||||||||||||||||||
| 160 | } executed 37660 times by 158 tests: end of blockExecuted by:
| 37660 | ||||||||||||||||||
| 161 | x->parent()->setColor(QMapNodeBase::Black); | - | ||||||||||||||||||
| 162 | x->parent()->parent()->setColor(QMapNodeBase::Red); | - | ||||||||||||||||||
| 163 | rotateLeft(x->parent()->parent()); | - | ||||||||||||||||||
| 164 | } executed 244065 times by 239 tests: end of blockExecuted by:
| 244065 | ||||||||||||||||||
| 165 | } | - | ||||||||||||||||||
| 166 | } | - | ||||||||||||||||||
| 167 | root->setColor(QMapNodeBase::Black); | - | ||||||||||||||||||
| 168 | } executed 946853 times by 293 tests: end of blockExecuted by:
| 946853 | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | void QMapDataBase::freeNodeAndRebalance(QMapNodeBase *z) | - | ||||||||||||||||||
| 171 | { | - | ||||||||||||||||||
| 172 | QMapNodeBase *&root = header.left; | - | ||||||||||||||||||
| 173 | QMapNodeBase *y = z; | - | ||||||||||||||||||
| 174 | QMapNodeBase *x; | - | ||||||||||||||||||
| 175 | QMapNodeBase *x_parent; | - | ||||||||||||||||||
| 176 | if (y->left == 0) {
| 2826-43294 | ||||||||||||||||||
| 177 | x = y->right; | - | ||||||||||||||||||
| 178 | if (y == mostLeftNode) {
| 2448-40846 | ||||||||||||||||||
| 179 | if (x)
| 4762-36084 | ||||||||||||||||||
| 180 | mostLeftNode = x; // It cannot have (left) children due the red black invariant. executed 4762 times by 344 tests: mostLeftNode = x;Executed by:
| 4762 | ||||||||||||||||||
| 181 | else | - | ||||||||||||||||||
| 182 | mostLeftNode = y->parent(); executed 36084 times by 417 tests: mostLeftNode = y->parent();Executed by:
| 36084 | ||||||||||||||||||
| 183 | } | - | ||||||||||||||||||
| 184 | } else { executed 43294 times by 435 tests: end of blockExecuted by:
| 43294 | ||||||||||||||||||
| 185 | if (y->right == 0) {
| 1197-1629 | ||||||||||||||||||
| 186 | x = y->left; | - | ||||||||||||||||||
| 187 | } else { executed 1197 times by 57 tests: end of blockExecuted by:
| 1197 | ||||||||||||||||||
| 188 | y = y->right; | - | ||||||||||||||||||
| 189 | while (y->left != 0)
| 569-1629 | ||||||||||||||||||
| 190 | y = y->left; executed 569 times by 21 tests: y = y->left;Executed by:
| 569 | ||||||||||||||||||
| 191 | x = y->right; | - | ||||||||||||||||||
| 192 | } executed 1629 times by 111 tests: end of blockExecuted by:
| 1629 | ||||||||||||||||||
| 193 | } | - | ||||||||||||||||||
| 194 | if (y != z) {
| 1629-44491 | ||||||||||||||||||
| 195 | z->left->setParent(y); | - | ||||||||||||||||||
| 196 | y->left = z->left; | - | ||||||||||||||||||
| 197 | if (y != z->right) {
| 442-1187 | ||||||||||||||||||
| 198 | x_parent = y->parent(); | - | ||||||||||||||||||
| 199 | if (x)
| 89-353 | ||||||||||||||||||
| 200 | x->setParent(y->parent()); executed 89 times by 7 tests: x->setParent(y->parent());Executed by:
| 89 | ||||||||||||||||||
| 201 | y->parent()->left = x; | - | ||||||||||||||||||
| 202 | y->right = z->right; | - | ||||||||||||||||||
| 203 | z->right->setParent(y); | - | ||||||||||||||||||
| 204 | } else { executed 442 times by 21 tests: end of blockExecuted by:
| 442 | ||||||||||||||||||
| 205 | x_parent = y; | - | ||||||||||||||||||
| 206 | } executed 1187 times by 110 tests: end of blockExecuted by:
| 1187 | ||||||||||||||||||
| 207 | if (root == z)
| 811-818 | ||||||||||||||||||
| 208 | root = y; executed 818 times by 42 tests: root = y;Executed by:
| 818 | ||||||||||||||||||
| 209 | else if (z->parent()->left == z)
| 383-428 | ||||||||||||||||||
| 210 | z->parent()->left = y; executed 428 times by 92 tests: z->parent()->left = y;Executed by:
| 428 | ||||||||||||||||||
| 211 | else | - | ||||||||||||||||||
| 212 | z->parent()->right = y; executed 383 times by 103 tests: z->parent()->right = y;Executed by:
| 383 | ||||||||||||||||||
| 213 | y->setParent(z->parent()); | - | ||||||||||||||||||
| 214 | // Swap the colors | - | ||||||||||||||||||
| 215 | QMapNodeBase::Color c = y->color(); | - | ||||||||||||||||||
| 216 | y->setColor(z->color()); | - | ||||||||||||||||||
| 217 | z->setColor(c); | - | ||||||||||||||||||
| 218 | y = z; | - | ||||||||||||||||||
| 219 | } else { executed 1629 times by 111 tests: end of blockExecuted by:
| 1629 | ||||||||||||||||||
| 220 | x_parent = y->parent(); | - | ||||||||||||||||||
| 221 | if (x)
| 6381-38110 | ||||||||||||||||||
| 222 | x->setParent(y->parent()); executed 6381 times by 355 tests: x->setParent(y->parent());Executed by:
| 6381 | ||||||||||||||||||
| 223 | if (root == z)
| 10600-33891 | ||||||||||||||||||
| 224 | root = x; executed 33891 times by 404 tests: root = x;Executed by:
| 33891 | ||||||||||||||||||
| 225 | else if (z->parent()->left == z)
| 2155-8445 | ||||||||||||||||||
| 226 | z->parent()->left = x; executed 8445 times by 391 tests: z->parent()->left = x;Executed by:
| 8445 | ||||||||||||||||||
| 227 | else | - | ||||||||||||||||||
| 228 | z->parent()->right = x; executed 2155 times by 298 tests: z->parent()->right = x;Executed by:
| 2155 | ||||||||||||||||||
| 229 | } | - | ||||||||||||||||||
| 230 | if (y->color() != QMapNodeBase::Red) {
| 4020-42100 | ||||||||||||||||||
| 231 | while (x != root && (x == 0 || x->color() == QMapNodeBase::Black)) {
| 425-36273 | ||||||||||||||||||
| 232 | if (x == x_parent->left) {
| 979-5128 | ||||||||||||||||||
| 233 | QMapNodeBase *w = x_parent->right; | - | ||||||||||||||||||
| 234 | if (w->color() == QMapNodeBase::Red) {
| 543-4585 | ||||||||||||||||||
| 235 | w->setColor(QMapNodeBase::Black); | - | ||||||||||||||||||
| 236 | x_parent->setColor(QMapNodeBase::Red); | - | ||||||||||||||||||
| 237 | rotateLeft(x_parent); | - | ||||||||||||||||||
| 238 | w = x_parent->right; | - | ||||||||||||||||||
| 239 | } executed 543 times by 241 tests: end of blockExecuted by:
| 543 | ||||||||||||||||||
| 240 | if ((w->left == 0 || w->left->color() == QMapNodeBase::Black) &&
| 364-4342 | ||||||||||||||||||
| 241 | (w->right == 0 || w->right->color() == QMapNodeBase::Black)) {
| 343-3137 | ||||||||||||||||||
| 242 | w->setColor(QMapNodeBase::Red); | - | ||||||||||||||||||
| 243 | x = x_parent; | - | ||||||||||||||||||
| 244 | x_parent = x_parent->parent(); | - | ||||||||||||||||||
| 245 | } else { executed 3480 times by 278 tests: end of blockExecuted by:
| 3480 | ||||||||||||||||||
| 246 | if (w->right == 0 || w->right->color() == QMapNodeBase::Black) {
| 5-1520 | ||||||||||||||||||
| 247 | if (w->left)
| 0-133 | ||||||||||||||||||
| 248 | w->left->setColor(QMapNodeBase::Black); executed 133 times by 100 tests: w->left->setColor(QMapNodeBase::Black);Executed by:
| 133 | ||||||||||||||||||
| 249 | w->setColor(QMapNodeBase::Red); | - | ||||||||||||||||||
| 250 | rotateRight(w); | - | ||||||||||||||||||
| 251 | w = x_parent->right; | - | ||||||||||||||||||
| 252 | } executed 133 times by 100 tests: end of blockExecuted by:
| 133 | ||||||||||||||||||
| 253 | w->setColor(x_parent->color()); | - | ||||||||||||||||||
| 254 | x_parent->setColor(QMapNodeBase::Black); | - | ||||||||||||||||||
| 255 | if (w->right)
| 0-1648 | ||||||||||||||||||
| 256 | w->right->setColor(QMapNodeBase::Black); executed 1648 times by 122 tests: w->right->setColor(QMapNodeBase::Black);Executed by:
| 1648 | ||||||||||||||||||
| 257 | rotateLeft(x_parent); | - | ||||||||||||||||||
| 258 | break; executed 1648 times by 122 tests: break;Executed by:
| 1648 | ||||||||||||||||||
| 259 | } | - | ||||||||||||||||||
| 260 | } else { | - | ||||||||||||||||||
| 261 | QMapNodeBase *w = x_parent->left; | - | ||||||||||||||||||
| 262 | if (w->color() == QMapNodeBase::Red) {
| 36-943 | ||||||||||||||||||
| 263 | w->setColor(QMapNodeBase::Black); | - | ||||||||||||||||||
| 264 | x_parent->setColor(QMapNodeBase::Red); | - | ||||||||||||||||||
| 265 | rotateRight(x_parent); | - | ||||||||||||||||||
| 266 | w = x_parent->left; | - | ||||||||||||||||||
| 267 | } executed 36 times by 9 tests: end of blockExecuted by:
| 36 | ||||||||||||||||||
| 268 | if ((w->right == 0 || w->right->color() == QMapNodeBase::Black) &&
| 37-775 | ||||||||||||||||||
| 269 | (w->left == 0 || w->left->color() == QMapNodeBase::Black)) {
| 35-720 | ||||||||||||||||||
| 270 | w->setColor(QMapNodeBase::Red); | - | ||||||||||||||||||
| 271 | x = x_parent; | - | ||||||||||||||||||
| 272 | x_parent = x_parent->parent(); | - | ||||||||||||||||||
| 273 | } else { executed 755 times by 33 tests: end of blockExecuted by:
| 755 | ||||||||||||||||||
| 274 | if (w->left == 0 || w->left->color() == QMapNodeBase::Black) {
| 2-117 | ||||||||||||||||||
| 275 | if (w->right)
| 0-119 | ||||||||||||||||||
| 276 | w->right->setColor(QMapNodeBase::Black); executed 119 times by 15 tests: w->right->setColor(QMapNodeBase::Black);Executed by:
| 119 | ||||||||||||||||||
| 277 | w->setColor(QMapNodeBase::Red); | - | ||||||||||||||||||
| 278 | rotateLeft(w); | - | ||||||||||||||||||
| 279 | w = x_parent->left; | - | ||||||||||||||||||
| 280 | } executed 119 times by 15 tests: end of blockExecuted by:
| 119 | ||||||||||||||||||
| 281 | w->setColor(x_parent->color()); | - | ||||||||||||||||||
| 282 | x_parent->setColor(QMapNodeBase::Black); | - | ||||||||||||||||||
| 283 | if (w->left)
| 0-224 | ||||||||||||||||||
| 284 | w->left->setColor(QMapNodeBase::Black); executed 224 times by 24 tests: w->left->setColor(QMapNodeBase::Black);Executed by:
| 224 | ||||||||||||||||||
| 285 | rotateRight(x_parent); | - | ||||||||||||||||||
| 286 | break; executed 224 times by 24 tests: break;Executed by:
| 224 | ||||||||||||||||||
| 287 | } | - | ||||||||||||||||||
| 288 | } | - | ||||||||||||||||||
| 289 | } | - | ||||||||||||||||||
| 290 | if (x)
| 10498-31602 | ||||||||||||||||||
| 291 | x->setColor(QMapNodeBase::Black); executed 10498 times by 355 tests: x->setColor(QMapNodeBase::Black);Executed by:
| 10498 | ||||||||||||||||||
| 292 | } executed 42100 times by 419 tests: end of blockExecuted by:
| 42100 | ||||||||||||||||||
| 293 | free(y); | - | ||||||||||||||||||
| 294 | --size; | - | ||||||||||||||||||
| 295 | } executed 46120 times by 437 tests: end of blockExecuted by:
| 46120 | ||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | void QMapDataBase::recalcMostLeftNode() | - | ||||||||||||||||||
| 298 | { | - | ||||||||||||||||||
| 299 | mostLeftNode = &header; | - | ||||||||||||||||||
| 300 | while (mostLeftNode->left)
| 870-384653 | ||||||||||||||||||
| 301 | mostLeftNode = mostLeftNode->left; executed 870 times by 24 tests: mostLeftNode = mostLeftNode->left;Executed by:
| 870 | ||||||||||||||||||
| 302 | } executed 384653 times by 300 tests: end of blockExecuted by:
| 384653 | ||||||||||||||||||
| 303 | - | |||||||||||||||||||
| 304 | static inline int qMapAlignmentThreshold() | - | ||||||||||||||||||
| 305 | { | - | ||||||||||||||||||
| 306 | // malloc on 32-bit platforms should return pointers that are 8-byte | - | ||||||||||||||||||
| 307 | // aligned or more while on 64-bit platforms they should be 16-byte aligned | - | ||||||||||||||||||
| 308 | // or more | - | ||||||||||||||||||
| 309 | return 2 * sizeof(void*); executed 1907712 times by 551 tests: return 2 * sizeof(void*);Executed by:
| 1907712 | ||||||||||||||||||
| 310 | } | - | ||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | static inline void *qMapAllocate(int alloc, int alignment) | - | ||||||||||||||||||
| 313 | { | - | ||||||||||||||||||
| 314 | return alignment > qMapAlignmentThreshold() executed 949571 times by 293 tests: return alignment > qMapAlignmentThreshold() ? qMallocAligned(alloc, alignment) : ::malloc(alloc);Executed by:
| 949571 | ||||||||||||||||||
| 315 | ? qMallocAligned(alloc, alignment) executed 949571 times by 293 tests: return alignment > qMapAlignmentThreshold() ? qMallocAligned(alloc, alignment) : ::malloc(alloc);Executed by:
| 949571 | ||||||||||||||||||
| 316 | : ::malloc(alloc); executed 949571 times by 293 tests: return alignment > qMapAlignmentThreshold() ? qMallocAligned(alloc, alignment) : ::malloc(alloc);Executed by:
| 949571 | ||||||||||||||||||
| 317 | } | - | ||||||||||||||||||
| 318 | - | |||||||||||||||||||
| 319 | static inline void qMapDeallocate(QMapNodeBase *node, int alignment) | - | ||||||||||||||||||
| 320 | { | - | ||||||||||||||||||
| 321 | if (alignment > qMapAlignmentThreshold())
| 600-957541 | ||||||||||||||||||
| 322 | qFreeAligned(node); executed 600 times by 1 test: qFreeAligned(node);Executed by:
| 600 | ||||||||||||||||||
| 323 | else | - | ||||||||||||||||||
| 324 | ::free(node); executed 957541 times by 481 tests: ::free(node);Executed by:
| 957541 | ||||||||||||||||||
| 325 | } | - | ||||||||||||||||||
| 326 | - | |||||||||||||||||||
| 327 | QMapNodeBase *QMapDataBase::createNode(int alloc, int alignment, QMapNodeBase *parent, bool left) | - | ||||||||||||||||||
| 328 | { | - | ||||||||||||||||||
| 329 | QMapNodeBase *node = static_cast<QMapNodeBase *>(qMapAllocate(alloc, alignment)); | - | ||||||||||||||||||
| 330 | Q_CHECK_PTR(node); never executed: qBadAlloc();
| 0-949571 | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | memset(node, 0, alloc); | - | ||||||||||||||||||
| 333 | ++size; | - | ||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | if (parent) {
| 2718-946853 | ||||||||||||||||||
| 336 | if (left) {
| 316176-630677 | ||||||||||||||||||
| 337 | parent->left = node; | - | ||||||||||||||||||
| 338 | if (parent == mostLeftNode)
| 63970-566707 | ||||||||||||||||||
| 339 | mostLeftNode = node; executed 566707 times by 293 tests: mostLeftNode = node;Executed by:
| 566707 | ||||||||||||||||||
| 340 | } else { executed 630677 times by 293 tests: end of blockExecuted by:
| 630677 | ||||||||||||||||||
| 341 | parent->right = node; | - | ||||||||||||||||||
| 342 | } executed 316176 times by 261 tests: end of blockExecuted by:
| 316176 | ||||||||||||||||||
| 343 | node->setParent(parent); | - | ||||||||||||||||||
| 344 | rebalance(node); | - | ||||||||||||||||||
| 345 | } executed 946853 times by 293 tests: end of blockExecuted by:
| 946853 | ||||||||||||||||||
| 346 | return node; executed 949571 times by 293 tests: return node;Executed by:
| 949571 | ||||||||||||||||||
| 347 | } | - | ||||||||||||||||||
| 348 | - | |||||||||||||||||||
| 349 | void QMapDataBase::freeTree(QMapNodeBase *root, int alignment) | - | ||||||||||||||||||
| 350 | { | - | ||||||||||||||||||
| 351 | if (root->left)
| 316052-642089 | ||||||||||||||||||
| 352 | freeTree(root->left, alignment); executed 316052 times by 428 tests: freeTree(root->left, alignment);Executed by:
| 316052 | ||||||||||||||||||
| 353 | if (root->right)
| 324411-633730 | ||||||||||||||||||
| 354 | freeTree(root->right, alignment); executed 324411 times by 436 tests: freeTree(root->right, alignment);Executed by:
| 324411 | ||||||||||||||||||
| 355 | qMapDeallocate(root, alignment); | - | ||||||||||||||||||
| 356 | } executed 958141 times by 481 tests: end of blockExecuted by:
| 958141 | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | QMapDataBase *QMapDataBase::createData() | - | ||||||||||||||||||
| 359 | { | - | ||||||||||||||||||
| 360 | QMapDataBase *d = new QMapDataBase; | - | ||||||||||||||||||
| 361 | - | |||||||||||||||||||
| 362 | d->ref.initializeOwned(); | - | ||||||||||||||||||
| 363 | d->size = 0; | - | ||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | d->header.p = 0; | - | ||||||||||||||||||
| 366 | d->header.left = 0; | - | ||||||||||||||||||
| 367 | d->header.right = 0; | - | ||||||||||||||||||
| 368 | d->mostLeftNode = &(d->header); | - | ||||||||||||||||||
| 369 | - | |||||||||||||||||||
| 370 | return d; executed 384655 times by 300 tests: return d;Executed by:
| 384655 | ||||||||||||||||||
| 371 | } | - | ||||||||||||||||||
| 372 | - | |||||||||||||||||||
| 373 | void QMapDataBase::freeData(QMapDataBase *d) | - | ||||||||||||||||||
| 374 | { | - | ||||||||||||||||||
| 375 | delete d; | - | ||||||||||||||||||
| 376 | } executed 385410 times by 510 tests: end of blockExecuted by:
| 385410 | ||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | /*! | - | ||||||||||||||||||
| 379 | \class QMap | - | ||||||||||||||||||
| 380 | \inmodule QtCore | - | ||||||||||||||||||
| 381 | \brief The QMap class is a template class that provides a red-black-tree-based dictionary. | - | ||||||||||||||||||
| 382 | - | |||||||||||||||||||
| 383 | \ingroup tools | - | ||||||||||||||||||
| 384 | \ingroup shared | - | ||||||||||||||||||
| 385 | - | |||||||||||||||||||
| 386 | \reentrant | - | ||||||||||||||||||
| 387 | - | |||||||||||||||||||
| 388 | QMap\<Key, T\> is one of Qt's generic \l{container classes}. It | - | ||||||||||||||||||
| 389 | stores (key, value) pairs and provides fast lookup of the | - | ||||||||||||||||||
| 390 | value associated with a key. | - | ||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | QMap and QHash provide very similar functionality. The | - | ||||||||||||||||||
| 393 | differences are: | - | ||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | \list | - | ||||||||||||||||||
| 396 | \li QHash provides average faster lookups than QMap. (See \l{Algorithmic | - | ||||||||||||||||||
| 397 | Complexity} for details.) | - | ||||||||||||||||||
| 398 | \li When iterating over a QHash, the items are arbitrarily ordered. | - | ||||||||||||||||||
| 399 | With QMap, the items are always sorted by key. | - | ||||||||||||||||||
| 400 | \li The key type of a QHash must provide operator==() and a global | - | ||||||||||||||||||
| 401 | qHash(Key) function. The key type of a QMap must provide | - | ||||||||||||||||||
| 402 | operator<() specifying a total order. | - | ||||||||||||||||||
| 403 | \endlist | - | ||||||||||||||||||
| 404 | - | |||||||||||||||||||
| 405 | Here's an example QMap with QString keys and \c int values: | - | ||||||||||||||||||
| 406 | \snippet code/src_corelib_tools_qmap.cpp 0 | - | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | To insert a (key, value) pair into the map, you can use operator[](): | - | ||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | \snippet code/src_corelib_tools_qmap.cpp 1 | - | ||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | This inserts the following three (key, value) pairs into the | - | ||||||||||||||||||
| 413 | QMap: ("one", 1), ("three", 3), and ("seven", 7). Another way to | - | ||||||||||||||||||
| 414 | insert items into the map is to use insert(): | - | ||||||||||||||||||
| 415 | - | |||||||||||||||||||
| 416 | \snippet code/src_corelib_tools_qmap.cpp 2 | - | ||||||||||||||||||
| 417 | - | |||||||||||||||||||
| 418 | To look up a value, use operator[]() or value(): | - | ||||||||||||||||||
| 419 | - | |||||||||||||||||||
| 420 | \snippet code/src_corelib_tools_qmap.cpp 3 | - | ||||||||||||||||||
| 421 | - | |||||||||||||||||||
| 422 | If there is no item with the specified key in the map, these | - | ||||||||||||||||||
| 423 | functions return a \l{default-constructed value}. | - | ||||||||||||||||||
| 424 | - | |||||||||||||||||||
| 425 | If you want to check whether the map contains a certain key, use | - | ||||||||||||||||||
| 426 | contains(): | - | ||||||||||||||||||
| 427 | - | |||||||||||||||||||
| 428 | \snippet code/src_corelib_tools_qmap.cpp 4 | - | ||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | There is also a value() overload that uses its second argument as | - | ||||||||||||||||||
| 431 | a default value if there is no item with the specified key: | - | ||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | \snippet code/src_corelib_tools_qmap.cpp 5 | - | ||||||||||||||||||
| 434 | - | |||||||||||||||||||
| 435 | In general, we recommend that you use contains() and value() | - | ||||||||||||||||||
| 436 | rather than operator[]() for looking up a key in a map. The | - | ||||||||||||||||||
| 437 | reason is that operator[]() silently inserts an item into the | - | ||||||||||||||||||
| 438 | map if no item exists with the same key (unless the map is | - | ||||||||||||||||||
| 439 | const). For example, the following code snippet will create 1000 | - | ||||||||||||||||||
| 440 | items in memory: | - | ||||||||||||||||||
| 441 | - | |||||||||||||||||||
| 442 | \snippet code/src_corelib_tools_qmap.cpp 6 | - | ||||||||||||||||||
| 443 | - | |||||||||||||||||||
| 444 | To avoid this problem, replace \c map[i] with \c map.value(i) | - | ||||||||||||||||||
| 445 | in the code above. | - | ||||||||||||||||||
| 446 | - | |||||||||||||||||||
| 447 | If you want to navigate through all the (key, value) pairs stored | - | ||||||||||||||||||
| 448 | in a QMap, you can use an iterator. QMap provides both | - | ||||||||||||||||||
| 449 | \l{Java-style iterators} (QMapIterator and QMutableMapIterator) | - | ||||||||||||||||||
| 450 | and \l{STL-style iterators} (QMap::const_iterator and | - | ||||||||||||||||||
| 451 | QMap::iterator). Here's how to iterate over a QMap<QString, int> | - | ||||||||||||||||||
| 452 | using a Java-style iterator: | - | ||||||||||||||||||
| 453 | - | |||||||||||||||||||
| 454 | \snippet code/src_corelib_tools_qmap.cpp 7 | - | ||||||||||||||||||
| 455 | - | |||||||||||||||||||
| 456 | Here's the same code, but using an STL-style iterator this time: | - | ||||||||||||||||||
| 457 | - | |||||||||||||||||||
| 458 | \snippet code/src_corelib_tools_qmap.cpp 8 | - | ||||||||||||||||||
| 459 | - | |||||||||||||||||||
| 460 | The items are traversed in ascending key order. | - | ||||||||||||||||||
| 461 | - | |||||||||||||||||||
| 462 | Normally, a QMap allows only one value per key. If you call | - | ||||||||||||||||||
| 463 | insert() with a key that already exists in the QMap, the | - | ||||||||||||||||||
| 464 | previous value will be erased. For example: | - | ||||||||||||||||||
| 465 | - | |||||||||||||||||||
| 466 | \snippet code/src_corelib_tools_qmap.cpp 9 | - | ||||||||||||||||||
| 467 | - | |||||||||||||||||||
| 468 | However, you can store multiple values per key by using | - | ||||||||||||||||||
| 469 | insertMulti() instead of insert() (or using the convenience | - | ||||||||||||||||||
| 470 | subclass QMultiMap). If you want to retrieve all the values for a | - | ||||||||||||||||||
| 471 | single key, you can use values(const Key &key), which returns a | - | ||||||||||||||||||
| 472 | QList<T>: | - | ||||||||||||||||||
| 473 | - | |||||||||||||||||||
| 474 | \snippet code/src_corelib_tools_qmap.cpp 10 | - | ||||||||||||||||||
| 475 | - | |||||||||||||||||||
| 476 | The items that share the same key are available from most | - | ||||||||||||||||||
| 477 | recently to least recently inserted. Another approach is to call | - | ||||||||||||||||||
| 478 | find() to get the STL-style iterator for the first item with a | - | ||||||||||||||||||
| 479 | key and iterate from there: | - | ||||||||||||||||||
| 480 | - | |||||||||||||||||||
| 481 | \snippet code/src_corelib_tools_qmap.cpp 11 | - | ||||||||||||||||||
| 482 | - | |||||||||||||||||||
| 483 | If you only need to extract the values from a map (not the keys), | - | ||||||||||||||||||
| 484 | you can also use \l{foreach}: | - | ||||||||||||||||||
| 485 | - | |||||||||||||||||||
| 486 | \snippet code/src_corelib_tools_qmap.cpp 12 | - | ||||||||||||||||||
| 487 | - | |||||||||||||||||||
| 488 | Items can be removed from the map in several ways. One way is to | - | ||||||||||||||||||
| 489 | call remove(); this will remove any item with the given key. | - | ||||||||||||||||||
| 490 | Another way is to use QMutableMapIterator::remove(). In addition, | - | ||||||||||||||||||
| 491 | you can clear the entire map using clear(). | - | ||||||||||||||||||
| 492 | - | |||||||||||||||||||
| 493 | QMap's key and value data types must be \l{assignable data | - | ||||||||||||||||||
| 494 | types}. This covers most data types you are likely to encounter, | - | ||||||||||||||||||
| 495 | but the compiler won't let you, for example, store a QWidget as a | - | ||||||||||||||||||
| 496 | value; instead, store a QWidget *. In addition, QMap's key type | - | ||||||||||||||||||
| 497 | must provide operator<(). QMap uses it to keep its items sorted, | - | ||||||||||||||||||
| 498 | and assumes that two keys \c x and \c y are equal if neither \c{x | - | ||||||||||||||||||
| 499 | < y} nor \c{y < x} is true. | - | ||||||||||||||||||
| 500 | - | |||||||||||||||||||
| 501 | Example: | - | ||||||||||||||||||
| 502 | \snippet code/src_corelib_tools_qmap.cpp 13 | - | ||||||||||||||||||
| 503 | - | |||||||||||||||||||
| 504 | In the example, we start by comparing the employees' names. If | - | ||||||||||||||||||
| 505 | they're equal, we compare their dates of birth to break the tie. | - | ||||||||||||||||||
| 506 | - | |||||||||||||||||||
| 507 | \sa QMapIterator, QMutableMapIterator, QHash, QSet | - | ||||||||||||||||||
| 508 | */ | - | ||||||||||||||||||
| 509 | - | |||||||||||||||||||
| 510 | /*! \fn QMap::QMap() | - | ||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | Constructs an empty map. | - | ||||||||||||||||||
| 513 | - | |||||||||||||||||||
| 514 | \sa clear() | - | ||||||||||||||||||
| 515 | */ | - | ||||||||||||||||||
| 516 | - | |||||||||||||||||||
| 517 | /*! | - | ||||||||||||||||||
| 518 | \fn QMap::QMap(QMap<Key, T> &&other) | - | ||||||||||||||||||
| 519 | - | |||||||||||||||||||
| 520 | Move-constructs a QMap instance, making it point at the same | - | ||||||||||||||||||
| 521 | object that \a other was pointing to. | - | ||||||||||||||||||
| 522 | - | |||||||||||||||||||
| 523 | \since 5.2 | - | ||||||||||||||||||
| 524 | */ | - | ||||||||||||||||||
| 525 | - | |||||||||||||||||||
| 526 | /*! \fn QMap::QMap(const QMap<Key, T> &other) | - | ||||||||||||||||||
| 527 | - | |||||||||||||||||||
| 528 | Constructs a copy of \a other. | - | ||||||||||||||||||
| 529 | - | |||||||||||||||||||
| 530 | This operation occurs in \l{constant time}, because QMap is | - | ||||||||||||||||||
| 531 | \l{implicitly shared}. This makes returning a QMap from a | - | ||||||||||||||||||
| 532 | function very fast. If a shared instance is modified, it will be | - | ||||||||||||||||||
| 533 | copied (copy-on-write), and this takes \l{linear time}. | - | ||||||||||||||||||
| 534 | - | |||||||||||||||||||
| 535 | \sa operator=() | - | ||||||||||||||||||
| 536 | */ | - | ||||||||||||||||||
| 537 | - | |||||||||||||||||||
| 538 | /*! \fn QMap::QMap(const std::map<Key, T> & other) | - | ||||||||||||||||||
| 539 | - | |||||||||||||||||||
| 540 | Constructs a copy of \a other. | - | ||||||||||||||||||
| 541 | - | |||||||||||||||||||
| 542 | \sa toStdMap() | - | ||||||||||||||||||
| 543 | */ | - | ||||||||||||||||||
| 544 | - | |||||||||||||||||||
| 545 | /*! \fn QMap::QMap(std::initializer_list<std::pair<Key,T> > list) | - | ||||||||||||||||||
| 546 | \since 5.1 | - | ||||||||||||||||||
| 547 | - | |||||||||||||||||||
| 548 | Constructs a map with a copy of each of the elements in the | - | ||||||||||||||||||
| 549 | initializer list \a list. | - | ||||||||||||||||||
| 550 | - | |||||||||||||||||||
| 551 | This function is only available if the program is being | - | ||||||||||||||||||
| 552 | compiled in C++11 mode. | - | ||||||||||||||||||
| 553 | */ | - | ||||||||||||||||||
| 554 | - | |||||||||||||||||||
| 555 | /*! \fn std::map<Key, T> QMap::toStdMap() const | - | ||||||||||||||||||
| 556 | - | |||||||||||||||||||
| 557 | Returns an STL map equivalent to this QMap. | - | ||||||||||||||||||
| 558 | */ | - | ||||||||||||||||||
| 559 | - | |||||||||||||||||||
| 560 | /*! \fn QMap::~QMap() | - | ||||||||||||||||||
| 561 | - | |||||||||||||||||||
| 562 | Destroys the map. References to the values in the map, and all | - | ||||||||||||||||||
| 563 | iterators over this map, become invalid. | - | ||||||||||||||||||
| 564 | */ | - | ||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | /*! \fn QMap<Key, T> &QMap::operator=(const QMap<Key, T> &other) | - | ||||||||||||||||||
| 567 | - | |||||||||||||||||||
| 568 | Assigns \a other to this map and returns a reference to this map. | - | ||||||||||||||||||
| 569 | */ | - | ||||||||||||||||||
| 570 | - | |||||||||||||||||||
| 571 | /*! | - | ||||||||||||||||||
| 572 | \fn QMap<Key, T> &QMap::operator=(QMap<Key, T> &&other) | - | ||||||||||||||||||
| 573 | - | |||||||||||||||||||
| 574 | Move-assigns \a other to this QMap instance. | - | ||||||||||||||||||
| 575 | - | |||||||||||||||||||
| 576 | \since 5.2 | - | ||||||||||||||||||
| 577 | */ | - | ||||||||||||||||||
| 578 | - | |||||||||||||||||||
| 579 | /*! \fn void QMap::swap(QMap<Key, T> &other) | - | ||||||||||||||||||
| 580 | \since 4.8 | - | ||||||||||||||||||
| 581 | - | |||||||||||||||||||
| 582 | Swaps map \a other with this map. This operation is very | - | ||||||||||||||||||
| 583 | fast and never fails. | - | ||||||||||||||||||
| 584 | */ | - | ||||||||||||||||||
| 585 | - | |||||||||||||||||||
| 586 | /*! \fn void QMultiMap::swap(QMultiMap<Key, T> &other) | - | ||||||||||||||||||
| 587 | \since 4.8 | - | ||||||||||||||||||
| 588 | - | |||||||||||||||||||
| 589 | Swaps map \a other with this map. This operation is very | - | ||||||||||||||||||
| 590 | fast and never fails. | - | ||||||||||||||||||
| 591 | */ | - | ||||||||||||||||||
| 592 | - | |||||||||||||||||||
| 593 | /*! \fn bool QMap::operator==(const QMap<Key, T> &other) const | - | ||||||||||||||||||
| 594 | - | |||||||||||||||||||
| 595 | Returns \c true if \a other is equal to this map; otherwise returns | - | ||||||||||||||||||
| 596 | false. | - | ||||||||||||||||||
| 597 | - | |||||||||||||||||||
| 598 | Two maps are considered equal if they contain the same (key, | - | ||||||||||||||||||
| 599 | value) pairs. | - | ||||||||||||||||||
| 600 | - | |||||||||||||||||||
| 601 | This function requires the value type to implement \c | - | ||||||||||||||||||
| 602 | operator==(). | - | ||||||||||||||||||
| 603 | - | |||||||||||||||||||
| 604 | \sa operator!=() | - | ||||||||||||||||||
| 605 | */ | - | ||||||||||||||||||
| 606 | - | |||||||||||||||||||
| 607 | /*! \fn bool QMap::operator!=(const QMap<Key, T> &other) const | - | ||||||||||||||||||
| 608 | - | |||||||||||||||||||
| 609 | Returns \c true if \a other is not equal to this map; otherwise | - | ||||||||||||||||||
| 610 | returns \c false. | - | ||||||||||||||||||
| 611 | - | |||||||||||||||||||
| 612 | Two maps are considered equal if they contain the same (key, | - | ||||||||||||||||||
| 613 | value) pairs. | - | ||||||||||||||||||
| 614 | - | |||||||||||||||||||
| 615 | This function requires the value type to implement \c | - | ||||||||||||||||||
| 616 | operator==(). | - | ||||||||||||||||||
| 617 | - | |||||||||||||||||||
| 618 | \sa operator==() | - | ||||||||||||||||||
| 619 | */ | - | ||||||||||||||||||
| 620 | - | |||||||||||||||||||
| 621 | /*! \fn int QMap::size() const | - | ||||||||||||||||||
| 622 | - | |||||||||||||||||||
| 623 | Returns the number of (key, value) pairs in the map. | - | ||||||||||||||||||
| 624 | - | |||||||||||||||||||
| 625 | \sa isEmpty(), count() | - | ||||||||||||||||||
| 626 | */ | - | ||||||||||||||||||
| 627 | - | |||||||||||||||||||
| 628 | /*! | - | ||||||||||||||||||
| 629 | \fn bool QMap::isEmpty() const | - | ||||||||||||||||||
| 630 | - | |||||||||||||||||||
| 631 | Returns \c true if the map contains no items; otherwise returns | - | ||||||||||||||||||
| 632 | false. | - | ||||||||||||||||||
| 633 | - | |||||||||||||||||||
| 634 | \sa size() | - | ||||||||||||||||||
| 635 | */ | - | ||||||||||||||||||
| 636 | - | |||||||||||||||||||
| 637 | /*! \fn void QMap::detach() | - | ||||||||||||||||||
| 638 | - | |||||||||||||||||||
| 639 | \internal | - | ||||||||||||||||||
| 640 | - | |||||||||||||||||||
| 641 | Detaches this map from any other maps with which it may share | - | ||||||||||||||||||
| 642 | data. | - | ||||||||||||||||||
| 643 | - | |||||||||||||||||||
| 644 | \sa isDetached() | - | ||||||||||||||||||
| 645 | */ | - | ||||||||||||||||||
| 646 | - | |||||||||||||||||||
| 647 | /*! \fn bool QMap::isDetached() const | - | ||||||||||||||||||
| 648 | - | |||||||||||||||||||
| 649 | \internal | - | ||||||||||||||||||
| 650 | - | |||||||||||||||||||
| 651 | Returns \c true if the map's internal data isn't shared with any | - | ||||||||||||||||||
| 652 | other map object; otherwise returns \c false. | - | ||||||||||||||||||
| 653 | - | |||||||||||||||||||
| 654 | \sa detach() | - | ||||||||||||||||||
| 655 | */ | - | ||||||||||||||||||
| 656 | - | |||||||||||||||||||
| 657 | /*! \fn void QMap::setSharable(bool sharable) | - | ||||||||||||||||||
| 658 | - | |||||||||||||||||||
| 659 | \internal | - | ||||||||||||||||||
| 660 | */ | - | ||||||||||||||||||
| 661 | - | |||||||||||||||||||
| 662 | /*! \fn bool QMap::isSharedWith(const QMap<Key, T> &other) const | - | ||||||||||||||||||
| 663 | - | |||||||||||||||||||
| 664 | \internal | - | ||||||||||||||||||
| 665 | */ | - | ||||||||||||||||||
| 666 | - | |||||||||||||||||||
| 667 | /*! \fn void QMap::clear() | - | ||||||||||||||||||
| 668 | - | |||||||||||||||||||
| 669 | Removes all items from the map. | - | ||||||||||||||||||
| 670 | - | |||||||||||||||||||
| 671 | \sa remove() | - | ||||||||||||||||||
| 672 | */ | - | ||||||||||||||||||
| 673 | - | |||||||||||||||||||
| 674 | /*! \fn int QMap::remove(const Key &key) | - | ||||||||||||||||||
| 675 | - | |||||||||||||||||||
| 676 | Removes all the items that have the key \a key from the map. | - | ||||||||||||||||||
| 677 | Returns the number of items removed which is usually 1 but will be | - | ||||||||||||||||||
| 678 | 0 if the key isn't in the map, or \> 1 if insertMulti() has been | - | ||||||||||||||||||
| 679 | used with the \a key. | - | ||||||||||||||||||
| 680 | - | |||||||||||||||||||
| 681 | \sa clear(), take(), QMultiMap::remove() | - | ||||||||||||||||||
| 682 | */ | - | ||||||||||||||||||
| 683 | - | |||||||||||||||||||
| 684 | /*! \fn T QMap::take(const Key &key) | - | ||||||||||||||||||
| 685 | - | |||||||||||||||||||
| 686 | Removes the item with the key \a key from the map and returns | - | ||||||||||||||||||
| 687 | the value associated with it. | - | ||||||||||||||||||
| 688 | - | |||||||||||||||||||
| 689 | If the item does not exist in the map, the function simply | - | ||||||||||||||||||
| 690 | returns a \l{default-constructed value}. If there are multiple | - | ||||||||||||||||||
| 691 | items for \a key in the map, only the most recently inserted one | - | ||||||||||||||||||
| 692 | is removed and returned. | - | ||||||||||||||||||
| 693 | - | |||||||||||||||||||
| 694 | If you don't use the return value, remove() is more efficient. | - | ||||||||||||||||||
| 695 | - | |||||||||||||||||||
| 696 | \sa remove() | - | ||||||||||||||||||
| 697 | */ | - | ||||||||||||||||||
| 698 | - | |||||||||||||||||||
| 699 | /*! \fn bool QMap::contains(const Key &key) const | - | ||||||||||||||||||
| 700 | - | |||||||||||||||||||
| 701 | Returns \c true if the map contains an item with key \a key; | - | ||||||||||||||||||
| 702 | otherwise returns \c false. | - | ||||||||||||||||||
| 703 | - | |||||||||||||||||||
| 704 | \sa count(), QMultiMap::contains() | - | ||||||||||||||||||
| 705 | */ | - | ||||||||||||||||||
| 706 | - | |||||||||||||||||||
| 707 | /*! \fn const T QMap::value(const Key &key, const T &defaultValue) const | - | ||||||||||||||||||
| 708 | - | |||||||||||||||||||
| 709 | Returns the value associated with the key \a key. | - | ||||||||||||||||||
| 710 | - | |||||||||||||||||||
| 711 | If the map contains no item with key \a key, the function returns | - | ||||||||||||||||||
| 712 | \a defaultValue. If no \a defaultValue is specified, the function | - | ||||||||||||||||||
| 713 | returns a \l{default-constructed value}. If there are multiple | - | ||||||||||||||||||
| 714 | items for \a key in the map, the value of the most recently | - | ||||||||||||||||||
| 715 | inserted one is returned. | - | ||||||||||||||||||
| 716 | - | |||||||||||||||||||
| 717 | \sa key(), values(), contains(), operator[]() | - | ||||||||||||||||||
| 718 | */ | - | ||||||||||||||||||
| 719 | - | |||||||||||||||||||
| 720 | /*! \fn T &QMap::operator[](const Key &key) | - | ||||||||||||||||||
| 721 | - | |||||||||||||||||||
| 722 | Returns the value associated with the key \a key as a modifiable | - | ||||||||||||||||||
| 723 | reference. | - | ||||||||||||||||||
| 724 | - | |||||||||||||||||||
| 725 | If the map contains no item with key \a key, the function inserts | - | ||||||||||||||||||
| 726 | a \l{default-constructed value} into the map with key \a key, and | - | ||||||||||||||||||
| 727 | returns a reference to it. If the map contains multiple items | - | ||||||||||||||||||
| 728 | with key \a key, this function returns a reference to the most | - | ||||||||||||||||||
| 729 | recently inserted value. | - | ||||||||||||||||||
| 730 | - | |||||||||||||||||||
| 731 | \sa insert(), value() | - | ||||||||||||||||||
| 732 | */ | - | ||||||||||||||||||
| 733 | - | |||||||||||||||||||
| 734 | /*! \fn const T QMap::operator[](const Key &key) const | - | ||||||||||||||||||
| 735 | - | |||||||||||||||||||
| 736 | \overload | - | ||||||||||||||||||
| 737 | - | |||||||||||||||||||
| 738 | Same as value(). | - | ||||||||||||||||||
| 739 | */ | - | ||||||||||||||||||
| 740 | - | |||||||||||||||||||
| 741 | /*! \fn QList<Key> QMap::uniqueKeys() const | - | ||||||||||||||||||
| 742 | \since 4.2 | - | ||||||||||||||||||
| 743 | - | |||||||||||||||||||
| 744 | Returns a list containing all the keys in the map in ascending | - | ||||||||||||||||||
| 745 | order. Keys that occur multiple times in the map (because items | - | ||||||||||||||||||
| 746 | were inserted with insertMulti(), or unite() was used) occur only | - | ||||||||||||||||||
| 747 | once in the returned list. | - | ||||||||||||||||||
| 748 | - | |||||||||||||||||||
| 749 | \sa keys(), values() | - | ||||||||||||||||||
| 750 | */ | - | ||||||||||||||||||
| 751 | - | |||||||||||||||||||
| 752 | /*! \fn QList<Key> QMap::keys() const | - | ||||||||||||||||||
| 753 | - | |||||||||||||||||||
| 754 | Returns a list containing all the keys in the map in ascending | - | ||||||||||||||||||
| 755 | order. Keys that occur multiple times in the map (because items | - | ||||||||||||||||||
| 756 | were inserted with insertMulti(), or unite() was used) also | - | ||||||||||||||||||
| 757 | occur multiple times in the list. | - | ||||||||||||||||||
| 758 | - | |||||||||||||||||||
| 759 | To obtain a list of unique keys, where each key from the map only | - | ||||||||||||||||||
| 760 | occurs once, use uniqueKeys(). | - | ||||||||||||||||||
| 761 | - | |||||||||||||||||||
| 762 | The order is guaranteed to be the same as that used by values(). | - | ||||||||||||||||||
| 763 | - | |||||||||||||||||||
| 764 | \sa uniqueKeys(), values(), key() | - | ||||||||||||||||||
| 765 | */ | - | ||||||||||||||||||
| 766 | - | |||||||||||||||||||
| 767 | /*! \fn QList<Key> QMap::keys(const T &value) const | - | ||||||||||||||||||
| 768 | - | |||||||||||||||||||
| 769 | \overload | - | ||||||||||||||||||
| 770 | - | |||||||||||||||||||
| 771 | Returns a list containing all the keys associated with value \a | - | ||||||||||||||||||
| 772 | value in ascending order. | - | ||||||||||||||||||
| 773 | - | |||||||||||||||||||
| 774 | This function can be slow (\l{linear time}), because QMap's | - | ||||||||||||||||||
| 775 | internal data structure is optimized for fast lookup by key, not | - | ||||||||||||||||||
| 776 | by value. | - | ||||||||||||||||||
| 777 | */ | - | ||||||||||||||||||
| 778 | - | |||||||||||||||||||
| 779 | /*! | - | ||||||||||||||||||
| 780 | \fn Key QMap::key(const T &value, const Key &defaultKey) const | - | ||||||||||||||||||
| 781 | \since 4.3 | - | ||||||||||||||||||
| 782 | \overload | - | ||||||||||||||||||
| 783 | - | |||||||||||||||||||
| 784 | Returns the first key with value \a value, or \a defaultKey if | - | ||||||||||||||||||
| 785 | the map contains no item with value \a value. If no \a defaultKey | - | ||||||||||||||||||
| 786 | is provided the function returns a | - | ||||||||||||||||||
| 787 | \l{default-constructed value}{default-constructed key}. | - | ||||||||||||||||||
| 788 | - | |||||||||||||||||||
| 789 | This function can be slow (\l{linear time}), because QMap's | - | ||||||||||||||||||
| 790 | internal data structure is optimized for fast lookup by key, not | - | ||||||||||||||||||
| 791 | by value. | - | ||||||||||||||||||
| 792 | - | |||||||||||||||||||
| 793 | \sa value(), keys() | - | ||||||||||||||||||
| 794 | */ | - | ||||||||||||||||||
| 795 | - | |||||||||||||||||||
| 796 | /*! \fn QList<T> QMap::values() const | - | ||||||||||||||||||
| 797 | - | |||||||||||||||||||
| 798 | Returns a list containing all the values in the map, in ascending | - | ||||||||||||||||||
| 799 | order of their keys. If a key is associated with multiple values, | - | ||||||||||||||||||
| 800 | all of its values will be in the list, and not just the most | - | ||||||||||||||||||
| 801 | recently inserted one. | - | ||||||||||||||||||
| 802 | - | |||||||||||||||||||
| 803 | \sa keys(), value() | - | ||||||||||||||||||
| 804 | */ | - | ||||||||||||||||||
| 805 | - | |||||||||||||||||||
| 806 | /*! \fn QList<T> QMap::values(const Key &key) const | - | ||||||||||||||||||
| 807 | - | |||||||||||||||||||
| 808 | \overload | - | ||||||||||||||||||
| 809 | - | |||||||||||||||||||
| 810 | Returns a list containing all the values associated with key | - | ||||||||||||||||||
| 811 | \a key, from the most recently inserted to the least recently | - | ||||||||||||||||||
| 812 | inserted one. | - | ||||||||||||||||||
| 813 | - | |||||||||||||||||||
| 814 | \sa count(), insertMulti() | - | ||||||||||||||||||
| 815 | */ | - | ||||||||||||||||||
| 816 | - | |||||||||||||||||||
| 817 | /*! \fn int QMap::count(const Key &key) const | - | ||||||||||||||||||
| 818 | - | |||||||||||||||||||
| 819 | Returns the number of items associated with key \a key. | - | ||||||||||||||||||
| 820 | - | |||||||||||||||||||
| 821 | \sa contains(), insertMulti(), QMultiMap::count() | - | ||||||||||||||||||
| 822 | */ | - | ||||||||||||||||||
| 823 | - | |||||||||||||||||||
| 824 | /*! \fn int QMap::count() const | - | ||||||||||||||||||
| 825 | - | |||||||||||||||||||
| 826 | \overload | - | ||||||||||||||||||
| 827 | - | |||||||||||||||||||
| 828 | Same as size(). | - | ||||||||||||||||||
| 829 | */ | - | ||||||||||||||||||
| 830 | - | |||||||||||||||||||
| 831 | /*! \fn QMap::iterator QMap::begin() | - | ||||||||||||||||||
| 832 | - | |||||||||||||||||||
| 833 | Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in | - | ||||||||||||||||||
| 834 | the map. | - | ||||||||||||||||||
| 835 | - | |||||||||||||||||||
| 836 | \sa constBegin(), end() | - | ||||||||||||||||||
| 837 | */ | - | ||||||||||||||||||
| 838 | - | |||||||||||||||||||
| 839 | /*! \fn QMap::const_iterator QMap::begin() const | - | ||||||||||||||||||
| 840 | - | |||||||||||||||||||
| 841 | \overload | - | ||||||||||||||||||
| 842 | */ | - | ||||||||||||||||||
| 843 | - | |||||||||||||||||||
| 844 | /*! \fn QMap::const_iterator QMap::cbegin() const | - | ||||||||||||||||||
| 845 | \since 5.0 | - | ||||||||||||||||||
| 846 | - | |||||||||||||||||||
| 847 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item | - | ||||||||||||||||||
| 848 | in the map. | - | ||||||||||||||||||
| 849 | - | |||||||||||||||||||
| 850 | \sa begin(), cend() | - | ||||||||||||||||||
| 851 | */ | - | ||||||||||||||||||
| 852 | - | |||||||||||||||||||
| 853 | /*! \fn QMap::const_iterator QMap::constBegin() const | - | ||||||||||||||||||
| 854 | - | |||||||||||||||||||
| 855 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item | - | ||||||||||||||||||
| 856 | in the map. | - | ||||||||||||||||||
| 857 | - | |||||||||||||||||||
| 858 | \sa begin(), constEnd() | - | ||||||||||||||||||
| 859 | */ | - | ||||||||||||||||||
| 860 | - | |||||||||||||||||||
| 861 | /*! \fn QMap::key_iterator QMap::keyBegin() const | - | ||||||||||||||||||
| 862 | \since 5.6 | - | ||||||||||||||||||
| 863 | - | |||||||||||||||||||
| 864 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first key | - | ||||||||||||||||||
| 865 | in the map. | - | ||||||||||||||||||
| 866 | - | |||||||||||||||||||
| 867 | \sa keyEnd(), firstKey() | - | ||||||||||||||||||
| 868 | */ | - | ||||||||||||||||||
| 869 | - | |||||||||||||||||||
| 870 | /*! \fn QMap::iterator QMap::end() | - | ||||||||||||||||||
| 871 | - | |||||||||||||||||||
| 872 | Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item | - | ||||||||||||||||||
| 873 | after the last item in the map. | - | ||||||||||||||||||
| 874 | - | |||||||||||||||||||
| 875 | \sa begin(), constEnd() | - | ||||||||||||||||||
| 876 | */ | - | ||||||||||||||||||
| 877 | - | |||||||||||||||||||
| 878 | /*! \fn QMap::const_iterator QMap::end() const | - | ||||||||||||||||||
| 879 | - | |||||||||||||||||||
| 880 | \overload | - | ||||||||||||||||||
| 881 | */ | - | ||||||||||||||||||
| 882 | - | |||||||||||||||||||
| 883 | /*! \fn QMap::const_iterator QMap::cend() const | - | ||||||||||||||||||
| 884 | \since 5.0 | - | ||||||||||||||||||
| 885 | - | |||||||||||||||||||
| 886 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary | - | ||||||||||||||||||
| 887 | item after the last item in the map. | - | ||||||||||||||||||
| 888 | - | |||||||||||||||||||
| 889 | \sa cbegin(), end() | - | ||||||||||||||||||
| 890 | */ | - | ||||||||||||||||||
| 891 | - | |||||||||||||||||||
| 892 | /*! \fn QMap::const_iterator QMap::constEnd() const | - | ||||||||||||||||||
| 893 | - | |||||||||||||||||||
| 894 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary | - | ||||||||||||||||||
| 895 | item after the last item in the map. | - | ||||||||||||||||||
| 896 | - | |||||||||||||||||||
| 897 | \sa constBegin(), end() | - | ||||||||||||||||||
| 898 | */ | - | ||||||||||||||||||
| 899 | - | |||||||||||||||||||
| 900 | /*! \fn QMap::key_iterator QMap::keyEnd() const | - | ||||||||||||||||||
| 901 | \since 5.6 | - | ||||||||||||||||||
| 902 | - | |||||||||||||||||||
| 903 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary | - | ||||||||||||||||||
| 904 | item after the last key in the map. | - | ||||||||||||||||||
| 905 | - | |||||||||||||||||||
| 906 | \sa keyBegin(), lastKey() | - | ||||||||||||||||||
| 907 | */ | - | ||||||||||||||||||
| 908 | - | |||||||||||||||||||
| 909 | /*! \fn const Key &QMap::firstKey() const | - | ||||||||||||||||||
| 910 | \since 5.2 | - | ||||||||||||||||||
| 911 | - | |||||||||||||||||||
| 912 | Returns a reference to the smallest key in the map. | - | ||||||||||||||||||
| 913 | This function assumes that the map is not empty. | - | ||||||||||||||||||
| 914 | - | |||||||||||||||||||
| 915 | This executes in \l{constant time}. | - | ||||||||||||||||||
| 916 | - | |||||||||||||||||||
| 917 | \sa lastKey(), first(), keyBegin(), isEmpty() | - | ||||||||||||||||||
| 918 | */ | - | ||||||||||||||||||
| 919 | - | |||||||||||||||||||
| 920 | /*! \fn const Key &QMap::lastKey() const | - | ||||||||||||||||||
| 921 | \since 5.2 | - | ||||||||||||||||||
| 922 | - | |||||||||||||||||||
| 923 | Returns a reference to the largest key in the map. | - | ||||||||||||||||||
| 924 | This function assumes that the map is not empty. | - | ||||||||||||||||||
| 925 | - | |||||||||||||||||||
| 926 | This executes in \l{logarithmic time}. | - | ||||||||||||||||||
| 927 | - | |||||||||||||||||||
| 928 | \sa firstKey(), last(), keyEnd(), isEmpty() | - | ||||||||||||||||||
| 929 | */ | - | ||||||||||||||||||
| 930 | - | |||||||||||||||||||
| 931 | /*! \fn T &QMap::first() | - | ||||||||||||||||||
| 932 | \since 5.2 | - | ||||||||||||||||||
| 933 | - | |||||||||||||||||||
| 934 | Returns a reference to the first value in the map, that is the value mapped | - | ||||||||||||||||||
| 935 | to the smallest key. This function assumes that the map is not empty. | - | ||||||||||||||||||
| 936 | - | |||||||||||||||||||
| 937 | When unshared (or const version is called), this executes in \l{constant time}. | - | ||||||||||||||||||
| 938 | - | |||||||||||||||||||
| 939 | \sa last(), firstKey(), isEmpty() | - | ||||||||||||||||||
| 940 | */ | - | ||||||||||||||||||
| 941 | - | |||||||||||||||||||
| 942 | /*! \fn const T &QMap::first() const | - | ||||||||||||||||||
| 943 | \since 5.2 | - | ||||||||||||||||||
| 944 | - | |||||||||||||||||||
| 945 | \overload | - | ||||||||||||||||||
| 946 | */ | - | ||||||||||||||||||
| 947 | - | |||||||||||||||||||
| 948 | /*! \fn T &QMap::last() | - | ||||||||||||||||||
| 949 | \since 5.2 | - | ||||||||||||||||||
| 950 | - | |||||||||||||||||||
| 951 | Returns a reference to the last value in the map, that is the value mapped | - | ||||||||||||||||||
| 952 | to the largest key. This function assumes that the map is not empty. | - | ||||||||||||||||||
| 953 | - | |||||||||||||||||||
| 954 | When unshared (or const version is called), this executes in \l{logarithmic time}. | - | ||||||||||||||||||
| 955 | - | |||||||||||||||||||
| 956 | \sa first(), lastKey(), isEmpty() | - | ||||||||||||||||||
| 957 | */ | - | ||||||||||||||||||
| 958 | - | |||||||||||||||||||
| 959 | /*! \fn const T &QMap::last() const | - | ||||||||||||||||||
| 960 | \since 5.2 | - | ||||||||||||||||||
| 961 | - | |||||||||||||||||||
| 962 | \overload | - | ||||||||||||||||||
| 963 | */ | - | ||||||||||||||||||
| 964 | - | |||||||||||||||||||
| 965 | /*! \fn QMap::iterator QMap::erase(iterator pos) | - | ||||||||||||||||||
| 966 | - | |||||||||||||||||||
| 967 | Removes the (key, value) pair pointed to by the iterator \a pos | - | ||||||||||||||||||
| 968 | from the map, and returns an iterator to the next item in the | - | ||||||||||||||||||
| 969 | map. | - | ||||||||||||||||||
| 970 | - | |||||||||||||||||||
| 971 | \sa remove() | - | ||||||||||||||||||
| 972 | */ | - | ||||||||||||||||||
| 973 | - | |||||||||||||||||||
| 974 | /*! \fn QMap::iterator QMap::find(const Key &key) | - | ||||||||||||||||||
| 975 | - | |||||||||||||||||||
| 976 | Returns an iterator pointing to the item with key \a key in the | - | ||||||||||||||||||
| 977 | map. | - | ||||||||||||||||||
| 978 | - | |||||||||||||||||||
| 979 | If the map contains no item with key \a key, the function | - | ||||||||||||||||||
| 980 | returns end(). | - | ||||||||||||||||||
| 981 | - | |||||||||||||||||||
| 982 | If the map contains multiple items with key \a key, this | - | ||||||||||||||||||
| 983 | function returns an iterator that points to the most recently | - | ||||||||||||||||||
| 984 | inserted value. The other values are accessible by incrementing | - | ||||||||||||||||||
| 985 | the iterator. For example, here's some code that iterates over all | - | ||||||||||||||||||
| 986 | the items with the same key: | - | ||||||||||||||||||
| 987 | - | |||||||||||||||||||
| 988 | \snippet code/src_corelib_tools_qmap.cpp 14 | - | ||||||||||||||||||
| 989 | - | |||||||||||||||||||
| 990 | \sa constFind(), value(), values(), lowerBound(), upperBound(), QMultiMap::find() | - | ||||||||||||||||||
| 991 | */ | - | ||||||||||||||||||
| 992 | - | |||||||||||||||||||
| 993 | /*! \fn QMap::const_iterator QMap::find(const Key &key) const | - | ||||||||||||||||||
| 994 | - | |||||||||||||||||||
| 995 | \overload | - | ||||||||||||||||||
| 996 | */ | - | ||||||||||||||||||
| 997 | - | |||||||||||||||||||
| 998 | /*! \fn QMap::const_iterator QMap::constFind(const Key &key) const | - | ||||||||||||||||||
| 999 | \since 4.1 | - | ||||||||||||||||||
| 1000 | - | |||||||||||||||||||
| 1001 | Returns an const iterator pointing to the item with key \a key in the | - | ||||||||||||||||||
| 1002 | map. | - | ||||||||||||||||||
| 1003 | - | |||||||||||||||||||
| 1004 | If the map contains no item with key \a key, the function | - | ||||||||||||||||||
| 1005 | returns constEnd(). | - | ||||||||||||||||||
| 1006 | - | |||||||||||||||||||
| 1007 | \sa find(), QMultiMap::constFind() | - | ||||||||||||||||||
| 1008 | */ | - | ||||||||||||||||||
| 1009 | - | |||||||||||||||||||
| 1010 | /*! \fn QMap::iterator QMap::lowerBound(const Key &key) | - | ||||||||||||||||||
| 1011 | - | |||||||||||||||||||
| 1012 | Returns an iterator pointing to the first item with key \a key in | - | ||||||||||||||||||
| 1013 | the map. If the map contains no item with key \a key, the | - | ||||||||||||||||||
| 1014 | function returns an iterator to the nearest item with a greater | - | ||||||||||||||||||
| 1015 | key. | - | ||||||||||||||||||
| 1016 | - | |||||||||||||||||||
| 1017 | Example: | - | ||||||||||||||||||
| 1018 | \snippet code/src_corelib_tools_qmap.cpp 15 | - | ||||||||||||||||||
| 1019 | - | |||||||||||||||||||
| 1020 | If the map contains multiple items with key \a key, this | - | ||||||||||||||||||
| 1021 | function returns an iterator that points to the most recently | - | ||||||||||||||||||
| 1022 | inserted value. The other values are accessible by incrementing | - | ||||||||||||||||||
| 1023 | the iterator. For example, here's some code that iterates over all | - | ||||||||||||||||||
| 1024 | the items with the same key: | - | ||||||||||||||||||
| 1025 | - | |||||||||||||||||||
| 1026 | \snippet code/src_corelib_tools_qmap.cpp 16 | - | ||||||||||||||||||
| 1027 | - | |||||||||||||||||||
| 1028 | \sa upperBound(), find() | - | ||||||||||||||||||
| 1029 | */ | - | ||||||||||||||||||
| 1030 | - | |||||||||||||||||||
| 1031 | /*! \fn QMap::const_iterator QMap::lowerBound(const Key &key) const | - | ||||||||||||||||||
| 1032 | - | |||||||||||||||||||
| 1033 | \overload | - | ||||||||||||||||||
| 1034 | */ | - | ||||||||||||||||||
| 1035 | - | |||||||||||||||||||
| 1036 | /*! \fn QMap::iterator QMap::upperBound(const Key &key) | - | ||||||||||||||||||
| 1037 | - | |||||||||||||||||||
| 1038 | Returns an iterator pointing to the item that immediately follows | - | ||||||||||||||||||
| 1039 | the last item with key \a key in the map. If the map contains no | - | ||||||||||||||||||
| 1040 | item with key \a key, the function returns an iterator to the | - | ||||||||||||||||||
| 1041 | nearest item with a greater key. | - | ||||||||||||||||||
| 1042 | - | |||||||||||||||||||
| 1043 | Example: | - | ||||||||||||||||||
| 1044 | \snippet code/src_corelib_tools_qmap.cpp 17 | - | ||||||||||||||||||
| 1045 | - | |||||||||||||||||||
| 1046 | \sa lowerBound(), find() | - | ||||||||||||||||||
| 1047 | */ | - | ||||||||||||||||||
| 1048 | - | |||||||||||||||||||
| 1049 | /*! \fn QMap::const_iterator QMap::upperBound(const Key &key) const | - | ||||||||||||||||||
| 1050 | - | |||||||||||||||||||
| 1051 | \overload | - | ||||||||||||||||||
| 1052 | */ | - | ||||||||||||||||||
| 1053 | - | |||||||||||||||||||
| 1054 | /*! \fn QMap::iterator QMap::insert(const Key &key, const T &value) | - | ||||||||||||||||||
| 1055 | - | |||||||||||||||||||
| 1056 | Inserts a new item with the key \a key and a value of \a value. | - | ||||||||||||||||||
| 1057 | - | |||||||||||||||||||
| 1058 | If there is already an item with the key \a key, that item's value | - | ||||||||||||||||||
| 1059 | is replaced with \a value. | - | ||||||||||||||||||
| 1060 | - | |||||||||||||||||||
| 1061 | If there are multiple items with the key \a key, the most | - | ||||||||||||||||||
| 1062 | recently inserted item's value is replaced with \a value. | - | ||||||||||||||||||
| 1063 | - | |||||||||||||||||||
| 1064 | \sa insertMulti() | - | ||||||||||||||||||
| 1065 | */ | - | ||||||||||||||||||
| 1066 | - | |||||||||||||||||||
| 1067 | /*! \fn QMap::iterator QMap::insert(const_iterator pos, const Key &key, const T &value) | - | ||||||||||||||||||
| 1068 | \overload | - | ||||||||||||||||||
| 1069 | \since 5.1 | - | ||||||||||||||||||
| 1070 | Inserts a new item with the key \a key and value \a value and with hint \a pos | - | ||||||||||||||||||
| 1071 | suggesting where to do the insert. | - | ||||||||||||||||||
| 1072 | - | |||||||||||||||||||
| 1073 | If constBegin() is used as hint it indicates that the \a key is less than any key in the map | - | ||||||||||||||||||
| 1074 | while constEnd() suggests that the \a key is (strictly) larger than any key in the map. | - | ||||||||||||||||||
| 1075 | Otherwise the hint should meet the condition (\a pos - 1).key() < \a key <= pos.key(). | - | ||||||||||||||||||
| 1076 | If the hint \a pos is wrong it is ignored and a regular insert is done. | - | ||||||||||||||||||
| 1077 | - | |||||||||||||||||||
| 1078 | If there is already an item with the key \a key, that item's value | - | ||||||||||||||||||
| 1079 | is replaced with \a value. | - | ||||||||||||||||||
| 1080 | - | |||||||||||||||||||
| 1081 | If there are multiple items with the key \a key, then exactly one of them | - | ||||||||||||||||||
| 1082 | is replaced with \a value. | - | ||||||||||||||||||
| 1083 | - | |||||||||||||||||||
| 1084 | If the hint is correct and the map is unshared, the insert executes in amortized \l{constant time}. | - | ||||||||||||||||||
| 1085 | - | |||||||||||||||||||
| 1086 | When creating a map from sorted data inserting the largest key first with constBegin() | - | ||||||||||||||||||
| 1087 | is faster than inserting in sorted order with constEnd(), since constEnd() - 1 (which is needed | - | ||||||||||||||||||
| 1088 | to check if the hint is valid) needs \l{logarithmic time}. | - | ||||||||||||||||||
| 1089 | - | |||||||||||||||||||
| 1090 | \b {Note:} Be careful with the hint. Providing an iterator from an older shared instance might | - | ||||||||||||||||||
| 1091 | crash but there is also a risk that it will silently corrupt both the map and the \a pos map. | - | ||||||||||||||||||
| 1092 | - | |||||||||||||||||||
| 1093 | \sa insertMulti() | - | ||||||||||||||||||
| 1094 | */ | - | ||||||||||||||||||
| 1095 | - | |||||||||||||||||||
| 1096 | /*! \fn QMap::iterator QMap::insertMulti(const Key &key, const T &value) | - | ||||||||||||||||||
| 1097 | - | |||||||||||||||||||
| 1098 | Inserts a new item with the key \a key and a value of \a value. | - | ||||||||||||||||||
| 1099 | - | |||||||||||||||||||
| 1100 | If there is already an item with the same key in the map, this | - | ||||||||||||||||||
| 1101 | function will simply create a new one. (This behavior is | - | ||||||||||||||||||
| 1102 | different from insert(), which overwrites the value of an | - | ||||||||||||||||||
| 1103 | existing item.) | - | ||||||||||||||||||
| 1104 | - | |||||||||||||||||||
| 1105 | \sa insert(), values() | - | ||||||||||||||||||
| 1106 | */ | - | ||||||||||||||||||
| 1107 | - | |||||||||||||||||||
| 1108 | /*! \fn QMap::iterator QMap::insertMulti(const_iterator pos, const Key &key, const T &value) | - | ||||||||||||||||||
| 1109 | \overload | - | ||||||||||||||||||
| 1110 | \since 5.1 | - | ||||||||||||||||||
| 1111 | Inserts a new item with the key \a key and value \a value and with hint \a pos | - | ||||||||||||||||||
| 1112 | suggesting where to do the insert. | - | ||||||||||||||||||
| 1113 | - | |||||||||||||||||||
| 1114 | If constBegin() is used as hint it indicates that the \a key is less than any key in the map | - | ||||||||||||||||||
| 1115 | while constEnd() suggests that the \a key is larger than any key in the map. | - | ||||||||||||||||||
| 1116 | Otherwise the hint should meet the condition (\a pos - 1).key() < \a key <= pos.key(). | - | ||||||||||||||||||
| 1117 | If the hint \a pos is wrong it is ignored and a regular insertMulti is done. | - | ||||||||||||||||||
| 1118 | - | |||||||||||||||||||
| 1119 | If there is already an item with the same key in the map, this function will simply create a new one. | - | ||||||||||||||||||
| 1120 | - | |||||||||||||||||||
| 1121 | \b {Note:} Be careful with the hint. Providing an iterator from an older shared instance might | - | ||||||||||||||||||
| 1122 | crash but there is also a risk that it will silently corrupt both the map and the \a pos map. | - | ||||||||||||||||||
| 1123 | - | |||||||||||||||||||
| 1124 | \sa insert() | - | ||||||||||||||||||
| 1125 | */ | - | ||||||||||||||||||
| 1126 | - | |||||||||||||||||||
| 1127 | - | |||||||||||||||||||
| 1128 | /*! \fn QMap<Key, T> &QMap::unite(const QMap<Key, T> &other) | - | ||||||||||||||||||
| 1129 | - | |||||||||||||||||||
| 1130 | Inserts all the items in the \a other map into this map. If a | - | ||||||||||||||||||
| 1131 | key is common to both maps, the resulting map will contain the | - | ||||||||||||||||||
| 1132 | key multiple times. | - | ||||||||||||||||||
| 1133 | - | |||||||||||||||||||
| 1134 | \sa insertMulti() | - | ||||||||||||||||||
| 1135 | */ | - | ||||||||||||||||||
| 1136 | - | |||||||||||||||||||
| 1137 | /*! \typedef QMap::Iterator | - | ||||||||||||||||||
| 1138 | - | |||||||||||||||||||
| 1139 | Qt-style synonym for QMap::iterator. | - | ||||||||||||||||||
| 1140 | */ | - | ||||||||||||||||||
| 1141 | - | |||||||||||||||||||
| 1142 | /*! \typedef QMap::ConstIterator | - | ||||||||||||||||||
| 1143 | - | |||||||||||||||||||
| 1144 | Qt-style synonym for QMap::const_iterator. | - | ||||||||||||||||||
| 1145 | */ | - | ||||||||||||||||||
| 1146 | - | |||||||||||||||||||
| 1147 | /*! \typedef QMap::difference_type | - | ||||||||||||||||||
| 1148 | - | |||||||||||||||||||
| 1149 | Typedef for ptrdiff_t. Provided for STL compatibility. | - | ||||||||||||||||||
| 1150 | */ | - | ||||||||||||||||||
| 1151 | - | |||||||||||||||||||
| 1152 | /*! \typedef QMap::key_type | - | ||||||||||||||||||
| 1153 | - | |||||||||||||||||||
| 1154 | Typedef for Key. Provided for STL compatibility. | - | ||||||||||||||||||
| 1155 | */ | - | ||||||||||||||||||
| 1156 | - | |||||||||||||||||||
| 1157 | /*! \typedef QMap::mapped_type | - | ||||||||||||||||||
| 1158 | - | |||||||||||||||||||
| 1159 | Typedef for T. Provided for STL compatibility. | - | ||||||||||||||||||
| 1160 | */ | - | ||||||||||||||||||
| 1161 | - | |||||||||||||||||||
| 1162 | /*! \typedef QMap::size_type | - | ||||||||||||||||||
| 1163 | - | |||||||||||||||||||
| 1164 | Typedef for int. Provided for STL compatibility. | - | ||||||||||||||||||
| 1165 | */ | - | ||||||||||||||||||
| 1166 | - | |||||||||||||||||||
| 1167 | /*! | - | ||||||||||||||||||
| 1168 | \fn bool QMap::empty() const | - | ||||||||||||||||||
| 1169 | - | |||||||||||||||||||
| 1170 | This function is provided for STL compatibility. It is equivalent | - | ||||||||||||||||||
| 1171 | to isEmpty(), returning true if the map is empty; otherwise | - | ||||||||||||||||||
| 1172 | returning false. | - | ||||||||||||||||||
| 1173 | */ | - | ||||||||||||||||||
| 1174 | - | |||||||||||||||||||
| 1175 | /*! | - | ||||||||||||||||||
| 1176 | \fn QPair<iterator, iterator> QMap::equal_range(const Key &key) | - | ||||||||||||||||||
| 1177 | - | |||||||||||||||||||
| 1178 | Returns a pair of iterators delimiting the range of values \c{[first, second)}, that | - | ||||||||||||||||||
| 1179 | are stored under \a key. | - | ||||||||||||||||||
| 1180 | */ | - | ||||||||||||||||||
| 1181 | - | |||||||||||||||||||
| 1182 | /*! | - | ||||||||||||||||||
| 1183 | \fn QPair<const_iterator, const_iterator> QMap::equal_range(const Key &key) const | - | ||||||||||||||||||
| 1184 | \overload | - | ||||||||||||||||||
| 1185 | \since 5.6 | - | ||||||||||||||||||
| 1186 | */ | - | ||||||||||||||||||
| 1187 | - | |||||||||||||||||||
| 1188 | - | |||||||||||||||||||
| 1189 | /*! \class QMap::iterator | - | ||||||||||||||||||
| 1190 | \inmodule QtCore | - | ||||||||||||||||||
| 1191 | \brief The QMap::iterator class provides an STL-style non-const iterator for QMap and QMultiMap. | - | ||||||||||||||||||
| 1192 | - | |||||||||||||||||||
| 1193 | QMap features both \l{STL-style iterators} and \l{Java-style | - | ||||||||||||||||||
| 1194 | iterators}. The STL-style iterators are more low-level and more | - | ||||||||||||||||||
| 1195 | cumbersome to use; on the other hand, they are slightly faster | - | ||||||||||||||||||
| 1196 | and, for developers who already know STL, have the advantage of | - | ||||||||||||||||||
| 1197 | familiarity. | - | ||||||||||||||||||
| 1198 | - | |||||||||||||||||||
| 1199 | QMap\<Key, T\>::iterator allows you to iterate over a QMap (or | - | ||||||||||||||||||
| 1200 | QMultiMap) and to modify the value (but not the key) stored under | - | ||||||||||||||||||
| 1201 | a particular key. If you want to iterate over a const QMap, you | - | ||||||||||||||||||
| 1202 | should use QMap::const_iterator. It is generally good practice to | - | ||||||||||||||||||
| 1203 | use QMap::const_iterator on a non-const QMap as well, unless you | - | ||||||||||||||||||
| 1204 | need to change the QMap through the iterator. Const iterators are | - | ||||||||||||||||||
| 1205 | slightly faster, and can improve code readability. | - | ||||||||||||||||||
| 1206 | - | |||||||||||||||||||
| 1207 | The default QMap::iterator constructor creates an uninitialized | - | ||||||||||||||||||
| 1208 | iterator. You must initialize it using a QMap function like | - | ||||||||||||||||||
| 1209 | QMap::begin(), QMap::end(), or QMap::find() before you can | - | ||||||||||||||||||
| 1210 | start iterating. Here's a typical loop that prints all the (key, | - | ||||||||||||||||||
| 1211 | value) pairs stored in a map: | - | ||||||||||||||||||
| 1212 | - | |||||||||||||||||||
| 1213 | \snippet code/src_corelib_tools_qmap.cpp 18 | - | ||||||||||||||||||
| 1214 | - | |||||||||||||||||||
| 1215 | Unlike QHash, which stores its items in an arbitrary order, QMap | - | ||||||||||||||||||
| 1216 | stores its items ordered by key. Items that share the same key | - | ||||||||||||||||||
| 1217 | (because they were inserted using QMap::insertMulti(), or due to a | - | ||||||||||||||||||
| 1218 | unite()) will appear consecutively, from the most recently to the | - | ||||||||||||||||||
| 1219 | least recently inserted value. | - | ||||||||||||||||||
| 1220 | - | |||||||||||||||||||
| 1221 | Let's see a few examples of things we can do with a | - | ||||||||||||||||||
| 1222 | QMap::iterator that we cannot do with a QMap::const_iterator. | - | ||||||||||||||||||
| 1223 | Here's an example that increments every value stored in the QMap | - | ||||||||||||||||||
| 1224 | by 2: | - | ||||||||||||||||||
| 1225 | - | |||||||||||||||||||
| 1226 | \snippet code/src_corelib_tools_qmap.cpp 19 | - | ||||||||||||||||||
| 1227 | - | |||||||||||||||||||
| 1228 | Here's an example that removes all the items whose key is a | - | ||||||||||||||||||
| 1229 | string that starts with an underscore character: | - | ||||||||||||||||||
| 1230 | - | |||||||||||||||||||
| 1231 | \snippet code/src_corelib_tools_qmap.cpp 20 | - | ||||||||||||||||||
| 1232 | - | |||||||||||||||||||
| 1233 | The call to QMap::erase() removes the item pointed to by the | - | ||||||||||||||||||
| 1234 | iterator from the map, and returns an iterator to the next item. | - | ||||||||||||||||||
| 1235 | Here's another way of removing an item while iterating: | - | ||||||||||||||||||
| 1236 | - | |||||||||||||||||||
| 1237 | \snippet code/src_corelib_tools_qmap.cpp 21 | - | ||||||||||||||||||
| 1238 | - | |||||||||||||||||||
| 1239 | It might be tempting to write code like this: | - | ||||||||||||||||||
| 1240 | - | |||||||||||||||||||
| 1241 | \snippet code/src_corelib_tools_qmap.cpp 22 | - | ||||||||||||||||||
| 1242 | - | |||||||||||||||||||
| 1243 | However, this will potentially crash in \c{++i}, because \c i is | - | ||||||||||||||||||
| 1244 | a dangling iterator after the call to erase(). | - | ||||||||||||||||||
| 1245 | - | |||||||||||||||||||
| 1246 | Multiple iterators can be used on the same map. If you add items | - | ||||||||||||||||||
| 1247 | to the map, existing iterators will remain valid. If you remove | - | ||||||||||||||||||
| 1248 | items from the map, iterators that point to the removed items | - | ||||||||||||||||||
| 1249 | will become dangling iterators. | - | ||||||||||||||||||
| 1250 | - | |||||||||||||||||||
| 1251 | \warning Iterators on implicitly shared containers do not work | - | ||||||||||||||||||
| 1252 | exactly like STL-iterators. You should avoid copying a container | - | ||||||||||||||||||
| 1253 | while iterators are active on that container. For more information, | - | ||||||||||||||||||
| 1254 | read \l{Implicit sharing iterator problem}. | - | ||||||||||||||||||
| 1255 | - | |||||||||||||||||||
| 1256 | \sa QMap::const_iterator, QMap::key_iterator, QMutableMapIterator | - | ||||||||||||||||||
| 1257 | */ | - | ||||||||||||||||||
| 1258 | - | |||||||||||||||||||
| 1259 | /*! \typedef QMap::iterator::difference_type | - | ||||||||||||||||||
| 1260 | - | |||||||||||||||||||
| 1261 | \internal | - | ||||||||||||||||||
| 1262 | */ | - | ||||||||||||||||||
| 1263 | - | |||||||||||||||||||
| 1264 | /*! \typedef QMap::iterator::iterator_category | - | ||||||||||||||||||
| 1265 | - | |||||||||||||||||||
| 1266 | A synonym for \e {std::bidirectional_iterator_tag} indicating | - | ||||||||||||||||||
| 1267 | this iterator is a bidirectional iterator. | - | ||||||||||||||||||
| 1268 | */ | - | ||||||||||||||||||
| 1269 | - | |||||||||||||||||||
| 1270 | /*! \typedef QMap::iterator::pointer | - | ||||||||||||||||||
| 1271 | - | |||||||||||||||||||
| 1272 | \internal | - | ||||||||||||||||||
| 1273 | */ | - | ||||||||||||||||||
| 1274 | - | |||||||||||||||||||
| 1275 | /*! \typedef QMap::iterator::reference | - | ||||||||||||||||||
| 1276 | - | |||||||||||||||||||
| 1277 | \internal | - | ||||||||||||||||||
| 1278 | */ | - | ||||||||||||||||||
| 1279 | - | |||||||||||||||||||
| 1280 | /*! \typedef QMap::iterator::value_type | - | ||||||||||||||||||
| 1281 | - | |||||||||||||||||||
| 1282 | \internal | - | ||||||||||||||||||
| 1283 | */ | - | ||||||||||||||||||
| 1284 | - | |||||||||||||||||||
| 1285 | /*! \fn QMap::iterator::iterator() | - | ||||||||||||||||||
| 1286 | - | |||||||||||||||||||
| 1287 | Constructs an uninitialized iterator. | - | ||||||||||||||||||
| 1288 | - | |||||||||||||||||||
| 1289 | Functions like key(), value(), and operator++() must not be | - | ||||||||||||||||||
| 1290 | called on an uninitialized iterator. Use operator=() to assign a | - | ||||||||||||||||||
| 1291 | value to it before using it. | - | ||||||||||||||||||
| 1292 | - | |||||||||||||||||||
| 1293 | \sa QMap::begin(), QMap::end() | - | ||||||||||||||||||
| 1294 | */ | - | ||||||||||||||||||
| 1295 | - | |||||||||||||||||||
| 1296 | /*! \fn QMap::iterator::iterator(Node *) | - | ||||||||||||||||||
| 1297 | - | |||||||||||||||||||
| 1298 | \internal | - | ||||||||||||||||||
| 1299 | */ | - | ||||||||||||||||||
| 1300 | - | |||||||||||||||||||
| 1301 | /*! \fn const Key &QMap::iterator::key() const | - | ||||||||||||||||||
| 1302 | - | |||||||||||||||||||
| 1303 | Returns the current item's key as a const reference. | - | ||||||||||||||||||
| 1304 | - | |||||||||||||||||||
| 1305 | There is no direct way of changing an item's key through an | - | ||||||||||||||||||
| 1306 | iterator, although it can be done by calling QMap::erase() | - | ||||||||||||||||||
| 1307 | followed by QMap::insert() or QMap::insertMulti(). | - | ||||||||||||||||||
| 1308 | - | |||||||||||||||||||
| 1309 | \sa value() | - | ||||||||||||||||||
| 1310 | */ | - | ||||||||||||||||||
| 1311 | - | |||||||||||||||||||
| 1312 | /*! \fn T &QMap::iterator::value() const | - | ||||||||||||||||||
| 1313 | - | |||||||||||||||||||
| 1314 | Returns a modifiable reference to the current item's value. | - | ||||||||||||||||||
| 1315 | - | |||||||||||||||||||
| 1316 | You can change the value of an item by using value() on | - | ||||||||||||||||||
| 1317 | the left side of an assignment, for example: | - | ||||||||||||||||||
| 1318 | - | |||||||||||||||||||
| 1319 | \snippet code/src_corelib_tools_qmap.cpp 23 | - | ||||||||||||||||||
| 1320 | - | |||||||||||||||||||
| 1321 | \sa key(), operator*() | - | ||||||||||||||||||
| 1322 | */ | - | ||||||||||||||||||
| 1323 | - | |||||||||||||||||||
| 1324 | /*! \fn T &QMap::iterator::operator*() const | - | ||||||||||||||||||
| 1325 | - | |||||||||||||||||||
| 1326 | Returns a modifiable reference to the current item's value. | - | ||||||||||||||||||
| 1327 | - | |||||||||||||||||||
| 1328 | Same as value(). | - | ||||||||||||||||||
| 1329 | - | |||||||||||||||||||
| 1330 | \sa key() | - | ||||||||||||||||||
| 1331 | */ | - | ||||||||||||||||||
| 1332 | - | |||||||||||||||||||
| 1333 | /*! \fn T *QMap::iterator::operator->() const | - | ||||||||||||||||||
| 1334 | - | |||||||||||||||||||
| 1335 | Returns a pointer to the current item's value. | - | ||||||||||||||||||
| 1336 | - | |||||||||||||||||||
| 1337 | \sa value() | - | ||||||||||||||||||
| 1338 | */ | - | ||||||||||||||||||
| 1339 | - | |||||||||||||||||||
| 1340 | /*! | - | ||||||||||||||||||
| 1341 | \fn bool QMap::iterator::operator==(const iterator &other) const | - | ||||||||||||||||||
| 1342 | \fn bool QMap::iterator::operator==(const const_iterator &other) const | - | ||||||||||||||||||
| 1343 | - | |||||||||||||||||||
| 1344 | Returns \c true if \a other points to the same item as this | - | ||||||||||||||||||
| 1345 | iterator; otherwise returns \c false. | - | ||||||||||||||||||
| 1346 | - | |||||||||||||||||||
| 1347 | \sa operator!=() | - | ||||||||||||||||||
| 1348 | */ | - | ||||||||||||||||||
| 1349 | - | |||||||||||||||||||
| 1350 | /*! | - | ||||||||||||||||||
| 1351 | \fn bool QMap::iterator::operator!=(const iterator &other) const | - | ||||||||||||||||||
| 1352 | \fn bool QMap::iterator::operator!=(const const_iterator &other) const | - | ||||||||||||||||||
| 1353 | - | |||||||||||||||||||
| 1354 | Returns \c true if \a other points to a different item than this | - | ||||||||||||||||||
| 1355 | iterator; otherwise returns \c false. | - | ||||||||||||||||||
| 1356 | - | |||||||||||||||||||
| 1357 | \sa operator==() | - | ||||||||||||||||||
| 1358 | */ | - | ||||||||||||||||||
| 1359 | - | |||||||||||||||||||
| 1360 | /*! \fn QMap::iterator QMap::iterator::operator++() | - | ||||||||||||||||||
| 1361 | - | |||||||||||||||||||
| 1362 | The prefix ++ operator (\c{++i}) advances the iterator to the | - | ||||||||||||||||||
| 1363 | next item in the map and returns an iterator to the new current | - | ||||||||||||||||||
| 1364 | item. | - | ||||||||||||||||||
| 1365 | - | |||||||||||||||||||
| 1366 | Calling this function on QMap::end() leads to undefined results. | - | ||||||||||||||||||
| 1367 | - | |||||||||||||||||||
| 1368 | \sa operator--() | - | ||||||||||||||||||
| 1369 | */ | - | ||||||||||||||||||
| 1370 | - | |||||||||||||||||||
| 1371 | /*! \fn QMap::iterator QMap::iterator::operator++(int) | - | ||||||||||||||||||
| 1372 | - | |||||||||||||||||||
| 1373 | \overload | - | ||||||||||||||||||
| 1374 | - | |||||||||||||||||||
| 1375 | The postfix ++ operator (\c{i++}) advances the iterator to the | - | ||||||||||||||||||
| 1376 | next item in the map and returns an iterator to the previously | - | ||||||||||||||||||
| 1377 | current item. | - | ||||||||||||||||||
| 1378 | */ | - | ||||||||||||||||||
| 1379 | - | |||||||||||||||||||
| 1380 | /*! \fn QMap::iterator QMap::iterator::operator--() | - | ||||||||||||||||||
| 1381 | - | |||||||||||||||||||
| 1382 | The prefix -- operator (\c{--i}) makes the preceding item | - | ||||||||||||||||||
| 1383 | current and returns an iterator pointing to the new current item. | - | ||||||||||||||||||
| 1384 | - | |||||||||||||||||||
| 1385 | Calling this function on QMap::begin() leads to undefined | - | ||||||||||||||||||
| 1386 | results. | - | ||||||||||||||||||
| 1387 | - | |||||||||||||||||||
| 1388 | \sa operator++() | - | ||||||||||||||||||
| 1389 | */ | - | ||||||||||||||||||
| 1390 | - | |||||||||||||||||||
| 1391 | /*! \fn QMap::iterator QMap::iterator::operator--(int) | - | ||||||||||||||||||
| 1392 | - | |||||||||||||||||||
| 1393 | \overload | - | ||||||||||||||||||
| 1394 | - | |||||||||||||||||||
| 1395 | The postfix -- operator (\c{i--}) makes the preceding item | - | ||||||||||||||||||
| 1396 | current and returns an iterator pointing to the previously | - | ||||||||||||||||||
| 1397 | current item. | - | ||||||||||||||||||
| 1398 | */ | - | ||||||||||||||||||
| 1399 | - | |||||||||||||||||||
| 1400 | /*! \fn QMap::iterator QMap::iterator::operator+(int j) const | - | ||||||||||||||||||
| 1401 | - | |||||||||||||||||||
| 1402 | Returns an iterator to the item at \a j positions forward from | - | ||||||||||||||||||
| 1403 | this iterator. (If \a j is negative, the iterator goes backward.) | - | ||||||||||||||||||
| 1404 | - | |||||||||||||||||||
| 1405 | This operation can be slow for large \a j values. | - | ||||||||||||||||||
| 1406 | - | |||||||||||||||||||
| 1407 | \sa operator-() | - | ||||||||||||||||||
| 1408 | - | |||||||||||||||||||
| 1409 | */ | - | ||||||||||||||||||
| 1410 | - | |||||||||||||||||||
| 1411 | /*! \fn QMap::iterator QMap::iterator::operator-(int j) const | - | ||||||||||||||||||
| 1412 | - | |||||||||||||||||||
| 1413 | Returns an iterator to the item at \a j positions backward from | - | ||||||||||||||||||
| 1414 | this iterator. (If \a j is negative, the iterator goes forward.) | - | ||||||||||||||||||
| 1415 | - | |||||||||||||||||||
| 1416 | This operation can be slow for large \a j values. | - | ||||||||||||||||||
| 1417 | - | |||||||||||||||||||
| 1418 | \sa operator+() | - | ||||||||||||||||||
| 1419 | */ | - | ||||||||||||||||||
| 1420 | - | |||||||||||||||||||
| 1421 | /*! \fn QMap::iterator &QMap::iterator::operator+=(int j) | - | ||||||||||||||||||
| 1422 | - | |||||||||||||||||||
| 1423 | Advances the iterator by \a j items. (If \a j is negative, the | - | ||||||||||||||||||
| 1424 | iterator goes backward.) | - | ||||||||||||||||||
| 1425 | - | |||||||||||||||||||
| 1426 | \sa operator-=(), operator+() | - | ||||||||||||||||||
| 1427 | */ | - | ||||||||||||||||||
| 1428 | - | |||||||||||||||||||
| 1429 | /*! \fn QMap::iterator &QMap::iterator::operator-=(int j) | - | ||||||||||||||||||
| 1430 | - | |||||||||||||||||||
| 1431 | Makes the iterator go back by \a j items. (If \a j is negative, | - | ||||||||||||||||||
| 1432 | the iterator goes forward.) | - | ||||||||||||||||||
| 1433 | - | |||||||||||||||||||
| 1434 | \sa operator+=(), operator-() | - | ||||||||||||||||||
| 1435 | */ | - | ||||||||||||||||||
| 1436 | - | |||||||||||||||||||
| 1437 | /*! \class QMap::const_iterator | - | ||||||||||||||||||
| 1438 | \inmodule QtCore | - | ||||||||||||||||||
| 1439 | \brief The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap. | - | ||||||||||||||||||
| 1440 | - | |||||||||||||||||||
| 1441 | QMap features both \l{STL-style iterators} and \l{Java-style | - | ||||||||||||||||||
| 1442 | iterators}. The STL-style iterators are more low-level and more | - | ||||||||||||||||||
| 1443 | cumbersome to use; on the other hand, they are slightly faster | - | ||||||||||||||||||
| 1444 | and, for developers who already know STL, have the advantage of | - | ||||||||||||||||||
| 1445 | familiarity. | - | ||||||||||||||||||
| 1446 | - | |||||||||||||||||||
| 1447 | QMap\<Key, T\>::const_iterator allows you to iterate over a QMap | - | ||||||||||||||||||
| 1448 | (or a QMultiMap). If you want to modify the QMap as you iterate | - | ||||||||||||||||||
| 1449 | over it, you must use QMap::iterator instead. It is generally | - | ||||||||||||||||||
| 1450 | good practice to use QMap::const_iterator on a non-const QMap as | - | ||||||||||||||||||
| 1451 | well, unless you need to change the QMap through the iterator. | - | ||||||||||||||||||
| 1452 | Const iterators are slightly faster, and can improve code | - | ||||||||||||||||||
| 1453 | readability. | - | ||||||||||||||||||
| 1454 | - | |||||||||||||||||||
| 1455 | The default QMap::const_iterator constructor creates an | - | ||||||||||||||||||
| 1456 | uninitialized iterator. You must initialize it using a QMap | - | ||||||||||||||||||
| 1457 | function like QMap::constBegin(), QMap::constEnd(), or | - | ||||||||||||||||||
| 1458 | QMap::find() before you can start iterating. Here's a typical | - | ||||||||||||||||||
| 1459 | loop that prints all the (key, value) pairs stored in a map: | - | ||||||||||||||||||
| 1460 | - | |||||||||||||||||||
| 1461 | \snippet code/src_corelib_tools_qmap.cpp 24 | - | ||||||||||||||||||
| 1462 | - | |||||||||||||||||||
| 1463 | Unlike QHash, which stores its items in an arbitrary order, QMap | - | ||||||||||||||||||
| 1464 | stores its items ordered by key. Items that share the same key | - | ||||||||||||||||||
| 1465 | (because they were inserted using QMap::insertMulti()) will | - | ||||||||||||||||||
| 1466 | appear consecutively, from the most recently to the least | - | ||||||||||||||||||
| 1467 | recently inserted value. | - | ||||||||||||||||||
| 1468 | - | |||||||||||||||||||
| 1469 | Multiple iterators can be used on the same map. If you add items | - | ||||||||||||||||||
| 1470 | to the map, existing iterators will remain valid. If you remove | - | ||||||||||||||||||
| 1471 | items from the map, iterators that point to the removed items | - | ||||||||||||||||||
| 1472 | will become dangling iterators. | - | ||||||||||||||||||
| 1473 | - | |||||||||||||||||||
| 1474 | \warning Iterators on implicitly shared containers do not work | - | ||||||||||||||||||
| 1475 | exactly like STL-iterators. You should avoid copying a container | - | ||||||||||||||||||
| 1476 | while iterators are active on that container. For more information, | - | ||||||||||||||||||
| 1477 | read \l{Implicit sharing iterator problem}. | - | ||||||||||||||||||
| 1478 | - | |||||||||||||||||||
| 1479 | \sa QMap::iterator, QMap::key_iterator, QMapIterator | - | ||||||||||||||||||
| 1480 | */ | - | ||||||||||||||||||
| 1481 | - | |||||||||||||||||||
| 1482 | /*! \typedef QMap::const_iterator::difference_type | - | ||||||||||||||||||
| 1483 | - | |||||||||||||||||||
| 1484 | \internal | - | ||||||||||||||||||
| 1485 | */ | - | ||||||||||||||||||
| 1486 | - | |||||||||||||||||||
| 1487 | /*! \typedef QMap::const_iterator::iterator_category | - | ||||||||||||||||||
| 1488 | - | |||||||||||||||||||
| 1489 | A synonym for \e {std::bidirectional_iterator_tag} indicating | - | ||||||||||||||||||
| 1490 | this iterator is a bidirectional iterator. | - | ||||||||||||||||||
| 1491 | */ | - | ||||||||||||||||||
| 1492 | - | |||||||||||||||||||
| 1493 | /*! \typedef QMap::const_iterator::pointer | - | ||||||||||||||||||
| 1494 | - | |||||||||||||||||||
| 1495 | \internal | - | ||||||||||||||||||
| 1496 | */ | - | ||||||||||||||||||
| 1497 | - | |||||||||||||||||||
| 1498 | /*! \typedef QMap::const_iterator::reference | - | ||||||||||||||||||
| 1499 | - | |||||||||||||||||||
| 1500 | \internal | - | ||||||||||||||||||
| 1501 | */ | - | ||||||||||||||||||
| 1502 | - | |||||||||||||||||||
| 1503 | /*! \typedef QMap::const_iterator::value_type | - | ||||||||||||||||||
| 1504 | - | |||||||||||||||||||
| 1505 | \internal | - | ||||||||||||||||||
| 1506 | */ | - | ||||||||||||||||||
| 1507 | - | |||||||||||||||||||
| 1508 | /*! \fn QMap::const_iterator::const_iterator() | - | ||||||||||||||||||
| 1509 | - | |||||||||||||||||||
| 1510 | Constructs an uninitialized iterator. | - | ||||||||||||||||||
| 1511 | - | |||||||||||||||||||
| 1512 | Functions like key(), value(), and operator++() must not be | - | ||||||||||||||||||
| 1513 | called on an uninitialized iterator. Use operator=() to assign a | - | ||||||||||||||||||
| 1514 | value to it before using it. | - | ||||||||||||||||||
| 1515 | - | |||||||||||||||||||
| 1516 | \sa QMap::constBegin(), QMap::constEnd() | - | ||||||||||||||||||
| 1517 | */ | - | ||||||||||||||||||
| 1518 | - | |||||||||||||||||||
| 1519 | /*! \fn QMap::const_iterator::const_iterator(const Node *) | - | ||||||||||||||||||
| 1520 | - | |||||||||||||||||||
| 1521 | \internal | - | ||||||||||||||||||
| 1522 | */ | - | ||||||||||||||||||
| 1523 | - | |||||||||||||||||||
| 1524 | /*! \fn QMap::const_iterator::const_iterator(const iterator &other) | - | ||||||||||||||||||
| 1525 | - | |||||||||||||||||||
| 1526 | Constructs a copy of \a other. | - | ||||||||||||||||||
| 1527 | */ | - | ||||||||||||||||||
| 1528 | - | |||||||||||||||||||
| 1529 | /*! \fn const Key &QMap::const_iterator::key() const | - | ||||||||||||||||||
| 1530 | - | |||||||||||||||||||
| 1531 | Returns the current item's key. | - | ||||||||||||||||||
| 1532 | - | |||||||||||||||||||
| 1533 | \sa value() | - | ||||||||||||||||||
| 1534 | */ | - | ||||||||||||||||||
| 1535 | - | |||||||||||||||||||
| 1536 | /*! \fn const T &QMap::const_iterator::value() const | - | ||||||||||||||||||
| 1537 | - | |||||||||||||||||||
| 1538 | Returns the current item's value. | - | ||||||||||||||||||
| 1539 | - | |||||||||||||||||||
| 1540 | \sa key(), operator*() | - | ||||||||||||||||||
| 1541 | */ | - | ||||||||||||||||||
| 1542 | - | |||||||||||||||||||
| 1543 | /*! \fn const T &QMap::const_iterator::operator*() const | - | ||||||||||||||||||
| 1544 | - | |||||||||||||||||||
| 1545 | Returns the current item's value. | - | ||||||||||||||||||
| 1546 | - | |||||||||||||||||||
| 1547 | Same as value(). | - | ||||||||||||||||||
| 1548 | - | |||||||||||||||||||
| 1549 | \sa key() | - | ||||||||||||||||||
| 1550 | */ | - | ||||||||||||||||||
| 1551 | - | |||||||||||||||||||
| 1552 | /*! \fn const T *QMap::const_iterator::operator->() const | - | ||||||||||||||||||
| 1553 | - | |||||||||||||||||||
| 1554 | Returns a pointer to the current item's value. | - | ||||||||||||||||||
| 1555 | - | |||||||||||||||||||
| 1556 | \sa value() | - | ||||||||||||||||||
| 1557 | */ | - | ||||||||||||||||||
| 1558 | - | |||||||||||||||||||
| 1559 | /*! \fn bool QMap::const_iterator::operator==(const const_iterator &other) const | - | ||||||||||||||||||
| 1560 | - | |||||||||||||||||||
| 1561 | Returns \c true if \a other points to the same item as this | - | ||||||||||||||||||
| 1562 | iterator; otherwise returns \c false. | - | ||||||||||||||||||
| 1563 | - | |||||||||||||||||||
| 1564 | \sa operator!=() | - | ||||||||||||||||||
| 1565 | */ | - | ||||||||||||||||||
| 1566 | - | |||||||||||||||||||
| 1567 | /*! \fn bool QMap::const_iterator::operator!=(const const_iterator &other) const | - | ||||||||||||||||||
| 1568 | - | |||||||||||||||||||
| 1569 | Returns \c true if \a other points to a different item than this | - | ||||||||||||||||||
| 1570 | iterator; otherwise returns \c false. | - | ||||||||||||||||||
| 1571 | - | |||||||||||||||||||
| 1572 | \sa operator==() | - | ||||||||||||||||||
| 1573 | */ | - | ||||||||||||||||||
| 1574 | - | |||||||||||||||||||
| 1575 | /*! \fn QMap::const_iterator QMap::const_iterator::operator++() | - | ||||||||||||||||||
| 1576 | - | |||||||||||||||||||
| 1577 | The prefix ++ operator (\c{++i}) advances the iterator to the | - | ||||||||||||||||||
| 1578 | next item in the map and returns an iterator to the new current | - | ||||||||||||||||||
| 1579 | item. | - | ||||||||||||||||||
| 1580 | - | |||||||||||||||||||
| 1581 | Calling this function on QMap::end() leads to undefined results. | - | ||||||||||||||||||
| 1582 | - | |||||||||||||||||||
| 1583 | \sa operator--() | - | ||||||||||||||||||
| 1584 | */ | - | ||||||||||||||||||
| 1585 | - | |||||||||||||||||||
| 1586 | /*! \fn QMap::const_iterator QMap::const_iterator::operator++(int) | - | ||||||||||||||||||
| 1587 | - | |||||||||||||||||||
| 1588 | \overload | - | ||||||||||||||||||
| 1589 | - | |||||||||||||||||||
| 1590 | The postfix ++ operator (\c{i++}) advances the iterator to the | - | ||||||||||||||||||
| 1591 | next item in the map and returns an iterator to the previously | - | ||||||||||||||||||
| 1592 | current item. | - | ||||||||||||||||||
| 1593 | */ | - | ||||||||||||||||||
| 1594 | - | |||||||||||||||||||
| 1595 | /*! \fn QMap::const_iterator &QMap::const_iterator::operator--() | - | ||||||||||||||||||
| 1596 | - | |||||||||||||||||||
| 1597 | The prefix -- operator (\c{--i}) makes the preceding item | - | ||||||||||||||||||
| 1598 | current and returns an iterator pointing to the new current item. | - | ||||||||||||||||||
| 1599 | - | |||||||||||||||||||
| 1600 | Calling this function on QMap::begin() leads to undefined | - | ||||||||||||||||||
| 1601 | results. | - | ||||||||||||||||||
| 1602 | - | |||||||||||||||||||
| 1603 | \sa operator++() | - | ||||||||||||||||||
| 1604 | */ | - | ||||||||||||||||||
| 1605 | - | |||||||||||||||||||
| 1606 | /*! \fn QMap::const_iterator QMap::const_iterator::operator--(int) | - | ||||||||||||||||||
| 1607 | - | |||||||||||||||||||
| 1608 | \overload | - | ||||||||||||||||||
| 1609 | - | |||||||||||||||||||
| 1610 | The postfix -- operator (\c{i--}) makes the preceding item | - | ||||||||||||||||||
| 1611 | current and returns an iterator pointing to the previously | - | ||||||||||||||||||
| 1612 | current item. | - | ||||||||||||||||||
| 1613 | */ | - | ||||||||||||||||||
| 1614 | - | |||||||||||||||||||
| 1615 | /*! \fn QMap::const_iterator QMap::const_iterator::operator+(int j) const | - | ||||||||||||||||||
| 1616 | - | |||||||||||||||||||
| 1617 | Returns an iterator to the item at \a j positions forward from | - | ||||||||||||||||||
| 1618 | this iterator. (If \a j is negative, the iterator goes backward.) | - | ||||||||||||||||||
| 1619 | - | |||||||||||||||||||
| 1620 | This operation can be slow for large \a j values. | - | ||||||||||||||||||
| 1621 | - | |||||||||||||||||||
| 1622 | \sa operator-() | - | ||||||||||||||||||
| 1623 | */ | - | ||||||||||||||||||
| 1624 | - | |||||||||||||||||||
| 1625 | /*! \fn QMap::const_iterator QMap::const_iterator::operator-(int j) const | - | ||||||||||||||||||
| 1626 | - | |||||||||||||||||||
| 1627 | Returns an iterator to the item at \a j positions backward from | - | ||||||||||||||||||
| 1628 | this iterator. (If \a j is negative, the iterator goes forward.) | - | ||||||||||||||||||
| 1629 | - | |||||||||||||||||||
| 1630 | This operation can be slow for large \a j values. | - | ||||||||||||||||||
| 1631 | - | |||||||||||||||||||
| 1632 | \sa operator+() | - | ||||||||||||||||||
| 1633 | */ | - | ||||||||||||||||||
| 1634 | - | |||||||||||||||||||
| 1635 | /*! \fn QMap::const_iterator &QMap::const_iterator::operator+=(int j) | - | ||||||||||||||||||
| 1636 | - | |||||||||||||||||||
| 1637 | Advances the iterator by \a j items. (If \a j is negative, the | - | ||||||||||||||||||
| 1638 | iterator goes backward.) | - | ||||||||||||||||||
| 1639 | - | |||||||||||||||||||
| 1640 | This operation can be slow for large \a j values. | - | ||||||||||||||||||
| 1641 | - | |||||||||||||||||||
| 1642 | \sa operator-=(), operator+() | - | ||||||||||||||||||
| 1643 | */ | - | ||||||||||||||||||
| 1644 | - | |||||||||||||||||||
| 1645 | /*! \fn QMap::const_iterator &QMap::const_iterator::operator-=(int j) | - | ||||||||||||||||||
| 1646 | - | |||||||||||||||||||
| 1647 | Makes the iterator go back by \a j items. (If \a j is negative, | - | ||||||||||||||||||
| 1648 | the iterator goes forward.) | - | ||||||||||||||||||
| 1649 | - | |||||||||||||||||||
| 1650 | This operation can be slow for large \a j values. | - | ||||||||||||||||||
| 1651 | - | |||||||||||||||||||
| 1652 | \sa operator+=(), operator-() | - | ||||||||||||||||||
| 1653 | */ | - | ||||||||||||||||||
| 1654 | - | |||||||||||||||||||
| 1655 | /*! \class QMap::key_iterator | - | ||||||||||||||||||
| 1656 | \inmodule QtCore | - | ||||||||||||||||||
| 1657 | \since 5.6 | - | ||||||||||||||||||
| 1658 | \brief The QMap::key_iterator class provides an STL-style const iterator for QMap and QMultiMap keys. | - | ||||||||||||||||||
| 1659 | - | |||||||||||||||||||
| 1660 | QMap::key_iterator is essentially the same as QMap::const_iterator | - | ||||||||||||||||||
| 1661 | with the difference that operator*() and operator->() return a key | - | ||||||||||||||||||
| 1662 | instead of a value. | - | ||||||||||||||||||
| 1663 | - | |||||||||||||||||||
| 1664 | For most uses QMap::iterator and QMap::const_iterator should be used, | - | ||||||||||||||||||
| 1665 | you can easily access the key by calling QMap::iterator::key(): | - | ||||||||||||||||||
| 1666 | - | |||||||||||||||||||
| 1667 | \snippet code/src_corelib_tools_qmap.cpp keyiterator1 | - | ||||||||||||||||||
| 1668 | - | |||||||||||||||||||
| 1669 | However, to have interoperability between QMap's keys and STL-style | - | ||||||||||||||||||
| 1670 | algorithms we need an iterator that dereferences to a key instead | - | ||||||||||||||||||
| 1671 | of a value. With QMap::key_iterator we can apply an algorithm to a | - | ||||||||||||||||||
| 1672 | range of keys without having to call QMap::keys(), which is inefficient | - | ||||||||||||||||||
| 1673 | as it costs one QMap iteration and memory allocation to create a temporary | - | ||||||||||||||||||
| 1674 | QList. | - | ||||||||||||||||||
| 1675 | - | |||||||||||||||||||
| 1676 | \snippet code/src_corelib_tools_qmap.cpp keyiterator2 | - | ||||||||||||||||||
| 1677 | - | |||||||||||||||||||
| 1678 | QMap::key_iterator is const, it's not possible to modify the key. | - | ||||||||||||||||||
| 1679 | - | |||||||||||||||||||
| 1680 | The default QMap::key_iterator constructor creates an uninitialized | - | ||||||||||||||||||
| 1681 | iterator. You must initialize it using a QMap function like | - | ||||||||||||||||||
| 1682 | QMap::keyBegin() or QMap::keyEnd(). | - | ||||||||||||||||||
| 1683 | - | |||||||||||||||||||
| 1684 | \warning Iterators on implicitly shared containers do not work | - | ||||||||||||||||||
| 1685 | exactly like STL-iterators. You should avoid copying a container | - | ||||||||||||||||||
| 1686 | while iterators are active on that container. For more information, | - | ||||||||||||||||||
| 1687 | read \l{Implicit sharing iterator problem}. | - | ||||||||||||||||||
| 1688 | - | |||||||||||||||||||
| 1689 | \sa QMap::const_iterator, QMap::iterator | - | ||||||||||||||||||
| 1690 | */ | - | ||||||||||||||||||
| 1691 | - | |||||||||||||||||||
| 1692 | /*! \typedef QMap::key_iterator::difference_type | - | ||||||||||||||||||
| 1693 | \internal | - | ||||||||||||||||||
| 1694 | */ | - | ||||||||||||||||||
| 1695 | - | |||||||||||||||||||
| 1696 | /*! \typedef QMap::key_iterator::iterator_category | - | ||||||||||||||||||
| 1697 | \internal | - | ||||||||||||||||||
| 1698 | */ | - | ||||||||||||||||||
| 1699 | - | |||||||||||||||||||
| 1700 | /*! \typedef QMap::key_iterator::pointer | - | ||||||||||||||||||
| 1701 | \internal | - | ||||||||||||||||||
| 1702 | */ | - | ||||||||||||||||||
| 1703 | - | |||||||||||||||||||
| 1704 | /*! \typedef QMap::key_iterator::reference | - | ||||||||||||||||||
| 1705 | \internal | - | ||||||||||||||||||
| 1706 | */ | - | ||||||||||||||||||
| 1707 | - | |||||||||||||||||||
| 1708 | /*! \typedef QMap::key_iterator::value_type | - | ||||||||||||||||||
| 1709 | \internal | - | ||||||||||||||||||
| 1710 | */ | - | ||||||||||||||||||
| 1711 | - | |||||||||||||||||||
| 1712 | /*! \fn const T &QMap::key_iterator::operator*() const | - | ||||||||||||||||||
| 1713 | - | |||||||||||||||||||
| 1714 | Returns the current item's key. | - | ||||||||||||||||||
| 1715 | */ | - | ||||||||||||||||||
| 1716 | - | |||||||||||||||||||
| 1717 | /*! \fn const T *QMap::key_iterator::operator->() const | - | ||||||||||||||||||
| 1718 | - | |||||||||||||||||||
| 1719 | Returns a pointer to the current item's key. | - | ||||||||||||||||||
| 1720 | */ | - | ||||||||||||||||||
| 1721 | - | |||||||||||||||||||
| 1722 | /*! \fn bool QMap::key_iterator::operator==(key_iterator other) const | - | ||||||||||||||||||
| 1723 | - | |||||||||||||||||||
| 1724 | Returns \c true if \a other points to the same item as this | - | ||||||||||||||||||
| 1725 | iterator; otherwise returns \c false. | - | ||||||||||||||||||
| 1726 | - | |||||||||||||||||||
| 1727 | \sa operator!=() | - | ||||||||||||||||||
| 1728 | */ | - | ||||||||||||||||||
| 1729 | - | |||||||||||||||||||
| 1730 | /*! \fn bool QMap::key_iterator::operator!=(key_iterator other) const | - | ||||||||||||||||||
| 1731 | - | |||||||||||||||||||
| 1732 | Returns \c true if \a other points to a different item than this | - | ||||||||||||||||||
| 1733 | iterator; otherwise returns \c false. | - | ||||||||||||||||||
| 1734 | - | |||||||||||||||||||
| 1735 | \sa operator==() | - | ||||||||||||||||||
| 1736 | */ | - | ||||||||||||||||||
| 1737 | - | |||||||||||||||||||
| 1738 | /*! | - | ||||||||||||||||||
| 1739 | \fn QMap::key_iterator &QMap::key_iterator::operator++() | - | ||||||||||||||||||
| 1740 | - | |||||||||||||||||||
| 1741 | The prefix ++ operator (\c{++i}) advances the iterator to the | - | ||||||||||||||||||
| 1742 | next item in the hash and returns an iterator to the new current | - | ||||||||||||||||||
| 1743 | item. | - | ||||||||||||||||||
| 1744 | - | |||||||||||||||||||
| 1745 | Calling this function on QMap::keyEnd() leads to undefined results. | - | ||||||||||||||||||
| 1746 | - | |||||||||||||||||||
| 1747 | \sa operator--() | - | ||||||||||||||||||
| 1748 | */ | - | ||||||||||||||||||
| 1749 | - | |||||||||||||||||||
| 1750 | /*! \fn QMap::key_iterator QMap::key_iterator::operator++(int) | - | ||||||||||||||||||
| 1751 | - | |||||||||||||||||||
| 1752 | \overload | - | ||||||||||||||||||
| 1753 | - | |||||||||||||||||||
| 1754 | The postfix ++ operator (\c{i++}) advances the iterator to the | - | ||||||||||||||||||
| 1755 | next item in the hash and returns an iterator to the previous | - | ||||||||||||||||||
| 1756 | item. | - | ||||||||||||||||||
| 1757 | */ | - | ||||||||||||||||||
| 1758 | - | |||||||||||||||||||
| 1759 | /*! \fn QMap::key_iterator &QMap::key_iterator::operator--() | - | ||||||||||||||||||
| 1760 | - | |||||||||||||||||||
| 1761 | The prefix -- operator (\c{--i}) makes the preceding item | - | ||||||||||||||||||
| 1762 | current and returns an iterator pointing to the new current item. | - | ||||||||||||||||||
| 1763 | - | |||||||||||||||||||
| 1764 | Calling this function on QMap::keyBegin() leads to undefined | - | ||||||||||||||||||
| 1765 | results. | - | ||||||||||||||||||
| 1766 | - | |||||||||||||||||||
| 1767 | \sa operator++() | - | ||||||||||||||||||
| 1768 | */ | - | ||||||||||||||||||
| 1769 | - | |||||||||||||||||||
| 1770 | /*! \fn QMap::key_iterator QMap::key_iterator::operator--(int) | - | ||||||||||||||||||
| 1771 | - | |||||||||||||||||||
| 1772 | \overload | - | ||||||||||||||||||
| 1773 | - | |||||||||||||||||||
| 1774 | The postfix -- operator (\c{i--}) makes the preceding item | - | ||||||||||||||||||
| 1775 | current and returns an iterator pointing to the previous | - | ||||||||||||||||||
| 1776 | item. | - | ||||||||||||||||||
| 1777 | */ | - | ||||||||||||||||||
| 1778 | - | |||||||||||||||||||
| 1779 | /*! \fn const_iterator QMap::key_iterator::base() const | - | ||||||||||||||||||
| 1780 | Returns the underlying const_iterator this key_iterator is based on. | - | ||||||||||||||||||
| 1781 | */ | - | ||||||||||||||||||
| 1782 | - | |||||||||||||||||||
| 1783 | /*! \fn QDataStream &operator<<(QDataStream &out, const QMap<Key, T> &map) | - | ||||||||||||||||||
| 1784 | \relates QMap | - | ||||||||||||||||||
| 1785 | - | |||||||||||||||||||
| 1786 | Writes the map \a map to stream \a out. | - | ||||||||||||||||||
| 1787 | - | |||||||||||||||||||
| 1788 | This function requires the key and value types to implement \c | - | ||||||||||||||||||
| 1789 | operator<<(). | - | ||||||||||||||||||
| 1790 | - | |||||||||||||||||||
| 1791 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - | ||||||||||||||||||
| 1792 | */ | - | ||||||||||||||||||
| 1793 | - | |||||||||||||||||||
| 1794 | /*! \fn QDataStream &operator>>(QDataStream &in, QMap<Key, T> &map) | - | ||||||||||||||||||
| 1795 | \relates QMap | - | ||||||||||||||||||
| 1796 | - | |||||||||||||||||||
| 1797 | Reads a map from stream \a in into \a map. | - | ||||||||||||||||||
| 1798 | - | |||||||||||||||||||
| 1799 | This function requires the key and value types to implement \c | - | ||||||||||||||||||
| 1800 | operator>>(). | - | ||||||||||||||||||
| 1801 | - | |||||||||||||||||||
| 1802 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - | ||||||||||||||||||
| 1803 | */ | - | ||||||||||||||||||
| 1804 | - | |||||||||||||||||||
| 1805 | /*! \class QMultiMap | - | ||||||||||||||||||
| 1806 | \inmodule QtCore | - | ||||||||||||||||||
| 1807 | \brief The QMultiMap class is a convenience QMap subclass that provides multi-valued maps. | - | ||||||||||||||||||
| 1808 | - | |||||||||||||||||||
| 1809 | \ingroup tools | - | ||||||||||||||||||
| 1810 | \ingroup shared | - | ||||||||||||||||||
| 1811 | - | |||||||||||||||||||
| 1812 | \reentrant | - | ||||||||||||||||||
| 1813 | - | |||||||||||||||||||
| 1814 | QMultiMap\<Key, T\> is one of Qt's generic \l{container classes}. | - | ||||||||||||||||||
| 1815 | It inherits QMap and extends it with a few convenience functions | - | ||||||||||||||||||
| 1816 | that make it more suitable than QMap for storing multi-valued | - | ||||||||||||||||||
| 1817 | maps. A multi-valued map is a map that allows multiple values | - | ||||||||||||||||||
| 1818 | with the same key; QMap normally doesn't allow that, unless you | - | ||||||||||||||||||
| 1819 | call QMap::insertMulti(). | - | ||||||||||||||||||
| 1820 | - | |||||||||||||||||||
| 1821 | Because QMultiMap inherits QMap, all of QMap's functionality also | - | ||||||||||||||||||
| 1822 | applies to QMultiMap. For example, you can use isEmpty() to test | - | ||||||||||||||||||
| 1823 | whether the map is empty, and you can traverse a QMultiMap using | - | ||||||||||||||||||
| 1824 | QMap's iterator classes (for example, QMapIterator). But in | - | ||||||||||||||||||
| 1825 | addition, it provides an insert() function that corresponds to | - | ||||||||||||||||||
| 1826 | QMap::insertMulti(), and a replace() function that corresponds to | - | ||||||||||||||||||
| 1827 | QMap::insert(). It also provides convenient operator+() and | - | ||||||||||||||||||
| 1828 | operator+=(). | - | ||||||||||||||||||
| 1829 | - | |||||||||||||||||||
| 1830 | Example: | - | ||||||||||||||||||
| 1831 | \snippet code/src_corelib_tools_qmap.cpp 25 | - | ||||||||||||||||||
| 1832 | - | |||||||||||||||||||
| 1833 | Unlike QMap, QMultiMap provides no operator[]. Use value() or | - | ||||||||||||||||||
| 1834 | replace() if you want to access the most recently inserted item | - | ||||||||||||||||||
| 1835 | with a certain key. | - | ||||||||||||||||||
| 1836 | - | |||||||||||||||||||
| 1837 | If you want to retrieve all the values for a single key, you can | - | ||||||||||||||||||
| 1838 | use values(const Key &key), which returns a QList<T>: | - | ||||||||||||||||||
| 1839 | - | |||||||||||||||||||
| 1840 | \snippet code/src_corelib_tools_qmap.cpp 26 | - | ||||||||||||||||||
| 1841 | - | |||||||||||||||||||
| 1842 | The items that share the same key are available from most | - | ||||||||||||||||||
| 1843 | recently to least recently inserted. | - | ||||||||||||||||||
| 1844 | - | |||||||||||||||||||
| 1845 | If you prefer the STL-style iterators, you can call find() to get | - | ||||||||||||||||||
| 1846 | the iterator for the first item with a key and iterate from | - | ||||||||||||||||||
| 1847 | there: | - | ||||||||||||||||||
| 1848 | - | |||||||||||||||||||
| 1849 | \snippet code/src_corelib_tools_qmap.cpp 27 | - | ||||||||||||||||||
| 1850 | - | |||||||||||||||||||
| 1851 | QMultiMap's key and value data types must be \l{assignable data | - | ||||||||||||||||||
| 1852 | types}. This covers most data types you are likely to encounter, | - | ||||||||||||||||||
| 1853 | but the compiler won't let you, for example, store a QWidget as a | - | ||||||||||||||||||
| 1854 | value; instead, store a QWidget *. In addition, QMultiMap's key type | - | ||||||||||||||||||
| 1855 | must provide operator<(). See the QMap documentation for details. | - | ||||||||||||||||||
| 1856 | - | |||||||||||||||||||
| 1857 | \sa QMap, QMapIterator, QMutableMapIterator, QMultiHash | - | ||||||||||||||||||
| 1858 | */ | - | ||||||||||||||||||
| 1859 | - | |||||||||||||||||||
| 1860 | /*! \fn QMultiMap::QMultiMap() | - | ||||||||||||||||||
| 1861 | - | |||||||||||||||||||
| 1862 | Constructs an empty map. | - | ||||||||||||||||||
| 1863 | */ | - | ||||||||||||||||||
| 1864 | - | |||||||||||||||||||
| 1865 | /*! \fn QMultiMap::QMultiMap(std::initializer_list<std::pair<Key,T> > list) | - | ||||||||||||||||||
| 1866 | \since 5.1 | - | ||||||||||||||||||
| 1867 | - | |||||||||||||||||||
| 1868 | Constructs a multi map with a copy of each of the elements in the | - | ||||||||||||||||||
| 1869 | initializer list \a list. | - | ||||||||||||||||||
| 1870 | - | |||||||||||||||||||
| 1871 | This function is only available if the program is being | - | ||||||||||||||||||
| 1872 | compiled in C++11 mode. | - | ||||||||||||||||||
| 1873 | */ | - | ||||||||||||||||||
| 1874 | - | |||||||||||||||||||
| 1875 | /*! \fn QMultiMap::QMultiMap(const QMap<Key, T> &other) | - | ||||||||||||||||||
| 1876 | - | |||||||||||||||||||
| 1877 | Constructs a copy of \a other (which can be a QMap or a | - | ||||||||||||||||||
| 1878 | QMultiMap). | - | ||||||||||||||||||
| 1879 | - | |||||||||||||||||||
| 1880 | \sa operator=() | - | ||||||||||||||||||
| 1881 | */ | - | ||||||||||||||||||
| 1882 | - | |||||||||||||||||||
| 1883 | /*! \fn QMultiMap::iterator QMultiMap::replace(const Key &key, const T &value) | - | ||||||||||||||||||
| 1884 | - | |||||||||||||||||||
| 1885 | Inserts a new item with the key \a key and a value of \a value. | - | ||||||||||||||||||
| 1886 | - | |||||||||||||||||||
| 1887 | If there is already an item with the key \a key, that item's value | - | ||||||||||||||||||
| 1888 | is replaced with \a value. | - | ||||||||||||||||||
| 1889 | - | |||||||||||||||||||
| 1890 | If there are multiple items with the key \a key, the most | - | ||||||||||||||||||
| 1891 | recently inserted item's value is replaced with \a value. | - | ||||||||||||||||||
| 1892 | - | |||||||||||||||||||
| 1893 | \sa insert() | - | ||||||||||||||||||
| 1894 | */ | - | ||||||||||||||||||
| 1895 | - | |||||||||||||||||||
| 1896 | /*! \fn QMultiMap::iterator QMultiMap::insert(const Key &key, const T &value) | - | ||||||||||||||||||
| 1897 | - | |||||||||||||||||||
| 1898 | Inserts a new item with the key \a key and a value of \a value. | - | ||||||||||||||||||
| 1899 | - | |||||||||||||||||||
| 1900 | If there is already an item with the same key in the map, this | - | ||||||||||||||||||
| 1901 | function will simply create a new one. (This behavior is | - | ||||||||||||||||||
| 1902 | different from replace(), which overwrites the value of an | - | ||||||||||||||||||
| 1903 | existing item.) | - | ||||||||||||||||||
| 1904 | - | |||||||||||||||||||
| 1905 | \sa replace() | - | ||||||||||||||||||
| 1906 | */ | - | ||||||||||||||||||
| 1907 | - | |||||||||||||||||||
| 1908 | /*! \fn QMultiMap::iterator QMultiMap::insert(QMap<Key, T>::const_iterator pos, const Key &key, const T &value) | - | ||||||||||||||||||
| 1909 | - | |||||||||||||||||||
| 1910 | \since 5.1 | - | ||||||||||||||||||
| 1911 | Inserts a new item with the key \a key and value \a value and with hint \a pos | - | ||||||||||||||||||
| 1912 | suggesting where to do the insert. | - | ||||||||||||||||||
| 1913 | - | |||||||||||||||||||
| 1914 | If constBegin() is used as hint it indicates that the \a key is less than any key in the map | - | ||||||||||||||||||
| 1915 | while constEnd() suggests that the \a key is larger than any key in the map. | - | ||||||||||||||||||
| 1916 | Otherwise the hint should meet the condition (\a pos - 1).key() < \a key <= pos.key(). | - | ||||||||||||||||||
| 1917 | If the hint \a pos is wrong it is ignored and a regular insert is done. | - | ||||||||||||||||||
| 1918 | - | |||||||||||||||||||
| 1919 | If there is already an item with the same key in the map, this function will simply create a new one. | - | ||||||||||||||||||
| 1920 | - | |||||||||||||||||||
| 1921 | \b {Note:} Be careful with the hint. Providing an iterator from an older shared instance might | - | ||||||||||||||||||
| 1922 | crash but there is also a risk that it will silently corrupt both the map and the \a pos map. | - | ||||||||||||||||||
| 1923 | */ | - | ||||||||||||||||||
| 1924 | - | |||||||||||||||||||
| 1925 | /*! \fn QMultiMap &QMultiMap::operator+=(const QMultiMap &other) | - | ||||||||||||||||||
| 1926 | - | |||||||||||||||||||
| 1927 | Inserts all the items in the \a other map into this map and | - | ||||||||||||||||||
| 1928 | returns a reference to this map. | - | ||||||||||||||||||
| 1929 | - | |||||||||||||||||||
| 1930 | \sa insert(), operator+() | - | ||||||||||||||||||
| 1931 | */ | - | ||||||||||||||||||
| 1932 | - | |||||||||||||||||||
| 1933 | /*! \fn QMultiMap QMultiMap::operator+(const QMultiMap &other) const | - | ||||||||||||||||||
| 1934 | - | |||||||||||||||||||
| 1935 | Returns a map that contains all the items in this map in | - | ||||||||||||||||||
| 1936 | addition to all the items in \a other. If a key is common to both | - | ||||||||||||||||||
| 1937 | maps, the resulting map will contain the key multiple times. | - | ||||||||||||||||||
| 1938 | - | |||||||||||||||||||
| 1939 | \sa operator+=() | - | ||||||||||||||||||
| 1940 | */ | - | ||||||||||||||||||
| 1941 | - | |||||||||||||||||||
| 1942 | /*! | - | ||||||||||||||||||
| 1943 | \fn bool QMultiMap::contains(const Key &key, const T &value) const | - | ||||||||||||||||||
| 1944 | \since 4.3 | - | ||||||||||||||||||
| 1945 | - | |||||||||||||||||||
| 1946 | Returns \c true if the map contains an item with key \a key and | - | ||||||||||||||||||
| 1947 | value \a value; otherwise returns \c false. | - | ||||||||||||||||||
| 1948 | - | |||||||||||||||||||
| 1949 | \sa QMap::contains() | - | ||||||||||||||||||
| 1950 | */ | - | ||||||||||||||||||
| 1951 | - | |||||||||||||||||||
| 1952 | /*! | - | ||||||||||||||||||
| 1953 | \fn int QMultiMap::remove(const Key &key, const T &value) | - | ||||||||||||||||||
| 1954 | \since 4.3 | - | ||||||||||||||||||
| 1955 | - | |||||||||||||||||||
| 1956 | Removes all the items that have the key \a key and the value \a | - | ||||||||||||||||||
| 1957 | value from the map. Returns the number of items removed. | - | ||||||||||||||||||
| 1958 | - | |||||||||||||||||||
| 1959 | \sa QMap::remove() | - | ||||||||||||||||||
| 1960 | */ | - | ||||||||||||||||||
| 1961 | - | |||||||||||||||||||
| 1962 | /*! | - | ||||||||||||||||||
| 1963 | \fn int QMultiMap::count(const Key &key, const T &value) const | - | ||||||||||||||||||
| 1964 | \since 4.3 | - | ||||||||||||||||||
| 1965 | - | |||||||||||||||||||
| 1966 | Returns the number of items with key \a key and value \a value. | - | ||||||||||||||||||
| 1967 | - | |||||||||||||||||||
| 1968 | \sa QMap::count() | - | ||||||||||||||||||
| 1969 | */ | - | ||||||||||||||||||
| 1970 | - | |||||||||||||||||||
| 1971 | /*! | - | ||||||||||||||||||
| 1972 | \fn typename QMap<Key, T>::iterator QMultiMap::find(const Key &key, const T &value) | - | ||||||||||||||||||
| 1973 | \since 4.3 | - | ||||||||||||||||||
| 1974 | - | |||||||||||||||||||
| 1975 | Returns an iterator pointing to the item with key \a key and | - | ||||||||||||||||||
| 1976 | value \a value in the map. | - | ||||||||||||||||||
| 1977 | - | |||||||||||||||||||
| 1978 | If the map contains no such item, the function returns end(). | - | ||||||||||||||||||
| 1979 | - | |||||||||||||||||||
| 1980 | If the map contains multiple items with key \a key, this | - | ||||||||||||||||||
| 1981 | function returns an iterator that points to the most recently | - | ||||||||||||||||||
| 1982 | inserted value. | - | ||||||||||||||||||
| 1983 | - | |||||||||||||||||||
| 1984 | \sa QMap::find() | - | ||||||||||||||||||
| 1985 | */ | - | ||||||||||||||||||
| 1986 | - | |||||||||||||||||||
| 1987 | /*! | - | ||||||||||||||||||
| 1988 | \fn typename QMap<Key, T>::const_iterator QMultiMap::find(const Key &key, const T &value) const | - | ||||||||||||||||||
| 1989 | \since 4.3 | - | ||||||||||||||||||
| 1990 | \overload | - | ||||||||||||||||||
| 1991 | - | |||||||||||||||||||
| 1992 | Returns a const iterator pointing to the item with the given \a key and | - | ||||||||||||||||||
| 1993 | \a value in the map. | - | ||||||||||||||||||
| 1994 | - | |||||||||||||||||||
| 1995 | If the map contains no such item, the function returns end(). | - | ||||||||||||||||||
| 1996 | - | |||||||||||||||||||
| 1997 | If the map contains multiple items with the specified \a key, this | - | ||||||||||||||||||
| 1998 | function returns a const iterator that points to the most recently | - | ||||||||||||||||||
| 1999 | inserted value. | - | ||||||||||||||||||
| 2000 | - | |||||||||||||||||||
| 2001 | \sa QMap::find() | - | ||||||||||||||||||
| 2002 | */ | - | ||||||||||||||||||
| 2003 | - | |||||||||||||||||||
| 2004 | /*! | - | ||||||||||||||||||
| 2005 | \fn typename QMap<Key, T>::const_iterator QMultiMap::constFind(const Key &key, const T &value) const | - | ||||||||||||||||||
| 2006 | \since 4.3 | - | ||||||||||||||||||
| 2007 | - | |||||||||||||||||||
| 2008 | Returns an iterator pointing to the item with key \a key and the | - | ||||||||||||||||||
| 2009 | value \a value in the map. | - | ||||||||||||||||||
| 2010 | - | |||||||||||||||||||
| 2011 | If the map contains no such item, the function returns | - | ||||||||||||||||||
| 2012 | constEnd(). | - | ||||||||||||||||||
| 2013 | - | |||||||||||||||||||
| 2014 | \sa QMap::constFind() | - | ||||||||||||||||||
| 2015 | */ | - | ||||||||||||||||||
| 2016 | - | |||||||||||||||||||
| 2017 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |