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