1<!-- 2Copyright Daniel James 2006-2009 3Distributed under the Boost Software License, Version 1.0. (See accompanying 4file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5--><library-reference> 6 <header name="boost/unordered_set.hpp"> 7 <namespace name="boost"> 8 <class name="unordered_set"> 9 <template> 10 <template-type-parameter name="Value"> 11 </template-type-parameter> 12 <template-type-parameter name="Hash"> 13 <default><type>boost::hash<Value></type></default> 14 </template-type-parameter> 15 <template-type-parameter name="Pred"> 16 <default><type>std::equal_to<Value></type></default> 17 </template-type-parameter> 18 <template-type-parameter name="Alloc"> 19 <default><type>std::allocator<Value></type></default> 20 </template-type-parameter> 21 </template> 22 <purpose><simpara> 23 An unordered associative container that stores unique values. 24 </simpara></purpose> 25 <description> 26 <para>Based on chapter 23 of 27 <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2960.pdf">the working draft of the C++ standard [n2960]</ulink>. 28 But without the updated rules for allocators. 29 </para> 30 <para><emphasis role="bold">Template Parameters</emphasis> 31 <informaltable> 32 <tgroup cols="2"> 33 <tbody> 34 <row> 35 <entry><emphasis>Value</emphasis></entry> 36 <entry>Value must be Assignable and CopyConstructible</entry></row> 37 <row> 38 <entry><emphasis>Hash</emphasis></entry> 39 <entry>A unary function object type that acts a hash function for a <code>Value</code>. It takes a single argument of type <code>Value</code> and returns a value of type std::size_t.</entry></row> 40 <row> 41 <entry><emphasis>Pred</emphasis></entry> 42 <entry>A binary function object that implements an equivalence relation on values of type <code>Value</code>. 43 A binary function object that induces an equivalence relation on values of type Key. 44 It takes two arguments of type Key and returns a value of type bool.</entry></row> 45 <row> 46 <entry><emphasis>Alloc</emphasis></entry> 47 <entry>An allocator whose value type is the same as the container's value type.</entry></row></tbody></tgroup></informaltable></para> 48 <para>The elements are organized into buckets. Keys with the same hash code are stored in the same bucket.</para> 49 <para>The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash.</para> 50 </description> 51 <typedef name="key_type"> 52 <type>Value</type> 53 </typedef> 54 <typedef name="value_type"> 55 <type>Value</type> 56 </typedef> 57 <typedef name="hasher"> 58 <type>Hash</type> 59 </typedef> 60 <typedef name="key_equal"> 61 <type>Pred</type> 62 </typedef> 63 <typedef name="allocator_type"> 64 <type>Alloc</type> 65 </typedef> 66 <typedef name="pointer"> 67 <type>typename allocator_type::pointer</type> 68 </typedef> 69 <typedef name="const_pointer"> 70 <type>typename allocator_type::const_pointer</type> 71 </typedef> 72 <typedef name="reference"> 73 <type>typename allocator_type::reference</type> 74 <purpose><simpara>lvalue of <type>value_type</type>.</simpara></purpose> 75 </typedef> 76 <typedef name="const_reference"> 77 <type>typename allocator_type::const_reference</type> 78 <purpose><simpara>const lvalue of <type>value_type</type>.</simpara></purpose> 79 </typedef> 80 <typedef name="size_type"> 81 <type><emphasis>implementation-defined</emphasis></type> 82 <description> 83 <para>An unsigned integral type.</para> 84 <para><type>size_type</type> can represent any non-negative value of <type>difference_type</type>.</para> 85 </description> 86 </typedef> 87 <typedef name="difference_type"> 88 <type><emphasis>implementation-defined</emphasis></type> 89 <description> 90 <para>A signed integral type.</para> 91 <para>Is identical to the difference type of <type>iterator</type> and <type>const_iterator</type>.</para> 92 </description> 93 </typedef> 94 <typedef name="iterator"> 95 <type><emphasis>implementation-defined</emphasis></type> 96 <description> 97 <para>A constant iterator whose value type is <type>value_type</type>. </para> 98 <para>The iterator category is at least a forward iterator.</para> 99 <para>Convertible to <type>const_iterator</type>.</para> 100 </description> 101 </typedef> 102 <typedef name="const_iterator"> 103 <type><emphasis>implementation-defined</emphasis></type> 104 <description> 105 <para>A constant iterator whose value type is <type>value_type</type>. </para> 106 <para>The iterator category is at least a forward iterator.</para> 107 </description> 108 </typedef> 109 <typedef name="local_iterator"> 110 <type><emphasis>implementation-defined</emphasis></type> 111 <description> 112 <para>An iterator with the same value type, difference type and pointer and reference type as <type>iterator</type>.</para> 113 <para>A local_iterator object can be used to iterate through a single bucket.</para> 114 </description> 115 </typedef> 116 <typedef name="const_local_iterator"> 117 <type><emphasis>implementation-defined</emphasis></type> 118 <description> 119 <para>A constant iterator with the same value type, difference type and pointer and reference type as <type>const_iterator</type>.</para> 120 <para>A const_local_iterator object can be used to iterate through a single bucket.</para> 121 </description> 122 </typedef> 123 <constructor specifiers="explicit"> 124 <parameter name="n"> 125 <paramtype>size_type</paramtype> 126 <default><emphasis>implementation-defined</emphasis></default> 127 </parameter> 128 <parameter name="hf"> 129 <paramtype>hasher const&</paramtype> 130 <default>hasher()</default> 131 </parameter> 132 <parameter name="eq"> 133 <paramtype>key_equal const&</paramtype> 134 <default>key_equal()</default> 135 </parameter> 136 <parameter name="a"> 137 <paramtype>allocator_type const&</paramtype> 138 <default>allocator_type()</default> 139 </parameter> 140 <postconditions> 141 <code><methodname>size</methodname>() == 0</code> 142 </postconditions> 143 <description> 144 <para>Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0.</para> 145 </description> 146 </constructor> 147 <constructor> 148 <template> 149 <template-type-parameter name="InputIterator"> 150 </template-type-parameter> 151 </template> 152 <parameter name="f"> 153 <paramtype>InputIterator</paramtype> 154 </parameter> 155 <parameter name="l"> 156 <paramtype>InputIterator</paramtype> 157 </parameter> 158 <parameter name="n"> 159 <paramtype>size_type</paramtype> 160 <default><emphasis>implementation-defined</emphasis></default> 161 </parameter> 162 <parameter name="hf"> 163 <paramtype>hasher const&</paramtype> 164 <default>hasher()</default> 165 </parameter> 166 <parameter name="eq"> 167 <paramtype>key_equal const&</paramtype> 168 <default>key_equal()</default> 169 </parameter> 170 <parameter name="a"> 171 <paramtype>allocator_type const&</paramtype> 172 <default>allocator_type()</default> 173 </parameter> 174 <description> 175 <para>Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0 and inserts the elements from [f, l) into it.</para> 176 </description> 177 </constructor> 178 <constructor> 179 <parameter> 180 <paramtype>unordered_set const&</paramtype> 181 </parameter> 182 <description> 183 <para>The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.</para> 184 </description> 185 <requires> 186 <para><code>value_type</code> is copy constructible</para> 187 </requires> 188 </constructor> 189 <constructor> 190 <parameter> 191 <paramtype>unordered_set &&</paramtype> 192 </parameter> 193 <description> 194 <para>The move constructor.</para> 195 </description> 196 <notes> 197 <para>This is emulated on compilers without rvalue references.</para> 198 </notes> 199 <requires> 200 <para> 201 <code>value_type</code> is move constructible. 202 (TODO: This is not actually required in this implementation). 203 </para> 204 </requires> 205 </constructor> 206 <constructor specifiers="explicit"> 207 <parameter name="a"> 208 <paramtype>Allocator const&</paramtype> 209 </parameter> 210 <description> 211 <para>Constructs an empty container, using allocator <code>a</code>.</para> 212 </description> 213 </constructor> 214 <constructor> 215 <parameter name="x"> 216 <paramtype>unordered_set const&</paramtype> 217 </parameter> 218 <parameter name="a"> 219 <paramtype>Allocator const&</paramtype> 220 </parameter> 221 <description> 222 <para>Constructs an container, copying <code>x</code>'s contained elements, hash function, predicate, maximum load factor, but using allocator <code>a</code>.</para> 223 </description> 224 </constructor> 225 <destructor> 226 <notes> 227 <para>The destructor is applied to every element, and all memory is deallocated</para> 228 </notes> 229 </destructor> 230 <method name="operator="> 231 <parameter> 232 <paramtype>unordered_set const&</paramtype> 233 </parameter> 234 <type>unordered_set&</type> 235 <description> 236 <para>The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.</para> 237 </description> 238 <notes> 239 <para> 240 On compilers without rvalue references, there is a single assignment 241 operator with the signature <code>operator=(unordered_set)</code> 242 in order to emulate move semantics. 243 </para> 244 </notes> 245 <requires> 246 <para><code>value_type</code> is copy constructible</para> 247 </requires> 248 </method> 249 <method name="operator="> 250 <parameter> 251 <paramtype>unordered_set &&</paramtype> 252 </parameter> 253 <type>unordered_set&</type> 254 <description> 255 <para>The move assignment operator.</para> 256 </description> 257 <notes> 258 <para> 259 On compilers without rvalue references, there is a single assignment 260 operator with the signature <code>operator=(unordered_set)</code> 261 in order to emulate move semantics. 262 </para> 263 </notes> 264 <requires> 265 <para> 266 <code>value_type</code> is move constructible. 267 (TODO: This is not actually required in this implementation). 268 </para> 269 </requires> 270 </method> 271 <method name="get_allocator" cv="const"> 272 <type>allocator_type</type> 273 </method> 274 <method-group name="size and capacity"> 275 <method name="empty" cv="const"> 276 <type>bool</type> 277 <returns> 278 <code><methodname>size</methodname>() == 0</code> 279 </returns> 280 </method> 281 <method name="size" cv="const"> 282 <type>size_type</type> 283 <returns> 284 <code>std::distance(<methodname>begin</methodname>(), <methodname>end</methodname>())</code> 285 </returns> 286 </method> 287 <method name="max_size" cv="const"> 288 <type>size_type</type> 289 <returns><code><methodname>size</methodname>()</code> of the largest possible container. 290 </returns> 291 </method> 292 </method-group> 293 <method-group name="iterators"> 294 <overloaded-method name="begin"> 295 <signature><type>iterator</type></signature> 296 <signature cv="const"><type>const_iterator</type></signature> 297 <returns>An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. 298 </returns> 299 </overloaded-method> 300 <overloaded-method name="end"> 301 <signature> 302 <type>iterator</type> 303 </signature> 304 <signature cv="const"> 305 <type>const_iterator</type> 306 </signature> 307 <returns>An iterator which refers to the past-the-end value for the container. 308 </returns> 309 </overloaded-method> 310 <method name="cbegin" cv="const"> 311 <type>const_iterator</type> 312 <returns>A constant iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. 313 </returns> 314 </method> 315 <method name="cend" cv="const"> 316 <type>const_iterator</type> 317 <returns>A constant iterator which refers to the past-the-end value for the container. 318 </returns> 319 </method> 320 </method-group> 321 <method-group name="modifiers"> 322 <method name="emplace"> 323 <template> 324 <template-type-parameter name="Args" pack="1"> 325 </template-type-parameter> 326 </template> 327 <parameter name="args" pack="1"> 328 <paramtype>Args&&</paramtype> 329 </parameter> 330 <type>std::pair<iterator, bool></type> 331 <description> 332 <para>Inserts an object, constructed with the arguments <code>args</code>, in the container if and only if there is no element in the container with an equivalent value.</para> 333 </description> 334 <returns> 335 <para>The bool component of the return type is true if an insert took place.</para> 336 <para>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.</para> 337 </returns> 338 <throws> 339 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 340 </throws> 341 <notes> 342 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 343 <para>Pointers and references to elements are never invalidated.</para> 344 <para>If the compiler doesn't support variadic template arguments or rvalue 345 references, this is emulated for up to 10 arguments, with no support 346 for rvalue references or move semantics.</para> 347 </notes> 348 </method> 349 <method name="emplace_hint"> 350 <template> 351 <template-type-parameter name="Args" pack="1"> 352 </template-type-parameter> 353 </template> 354 <parameter name="hint"> 355 <paramtype>const_iterator</paramtype> 356 </parameter> 357 <parameter name="args" pack="1"> 358 <paramtype>Args&&</paramtype> 359 </parameter> 360 <type>iterator</type> 361 <description> 362 <para>Inserts an object, constructed with the arguments <code>args</code>, in the container if and only if there is no element in the container with an equivalent value.</para> 363 <para>hint is a suggestion to where the element should be inserted.</para> 364 </description> 365 <returns> 366 <para>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.</para> 367 </returns> 368 <throws> 369 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 370 </throws> 371 <notes> 372 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same value. </para> 373 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 374 <para>Pointers and references to elements are never invalidated.</para> 375 <para>If the compiler doesn't support variadic template arguments or rvalue 376 references, this is emulated for up to 10 arguments, with no support 377 for rvalue references or move semantics.</para> 378 </notes> 379 </method> 380 <method name="insert"> 381 <parameter name="obj"> 382 <paramtype>value_type const&</paramtype> 383 </parameter> 384 <type>std::pair<iterator, bool></type> 385 <description> 386 <para>Inserts obj in the container if and only if there is no element in the container with an equivalent value.</para> 387 </description> 388 <returns> 389 <para>The bool component of the return type is true if an insert took place.</para> 390 <para>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.</para> 391 </returns> 392 <throws> 393 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 394 </throws> 395 <notes> 396 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 397 <para>Pointers and references to elements are never invalidated.</para> 398 </notes> 399 </method> 400 <method name="insert"> 401 <parameter name="hint"> 402 <paramtype>const_iterator</paramtype> 403 </parameter> 404 <parameter name="obj"> 405 <paramtype>value_type const&</paramtype> 406 </parameter> 407 <type>iterator</type> 408 <description> 409 <para>Inserts obj in the container if and only if there is no element in the container with an equivalent value.</para> 410 <para>hint is a suggestion to where the element should be inserted.</para> 411 </description> 412 <returns> 413 <para>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.</para> 414 </returns> 415 <throws> 416 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 417 </throws> 418 <notes> 419 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same value. </para> 420 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 421 <para>Pointers and references to elements are never invalidated.</para> 422 </notes> 423 </method> 424 <method name="insert"> 425 <template> 426 <template-type-parameter name="InputIterator"> 427 </template-type-parameter> 428 </template> 429 <parameter name="first"> 430 <paramtype>InputIterator</paramtype> 431 </parameter> 432 <parameter name="last"> 433 <paramtype>InputIterator</paramtype> 434 </parameter> 435 <type>void</type> 436 <description> 437 <para>Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent value.</para> 438 </description> 439 <throws> 440 <para>When inserting a single element, if an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 441 </throws> 442 <notes> 443 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 444 <para>Pointers and references to elements are never invalidated.</para> 445 </notes> 446 </method> 447 <method name="erase"> 448 <parameter name="position"> 449 <paramtype>const_iterator</paramtype> 450 </parameter> 451 <type>iterator</type> 452 <description> 453 <para>Erase the element pointed to by <code>position</code>.</para> 454 </description> 455 <returns> 456 <para>The iterator following <code>position</code> before the erasure.</para> 457 </returns> 458 <throws> 459 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 460 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 461 </throws> 462 <notes> 463 <para> 464 When the number of elements is a lot smaller than the number of buckets 465 this function can be very inefficient as it has to search through empty 466 buckets for the next element, in order to return the iterator. 467 The method <methodname>quick_erase</methodname> is faster, but has yet 468 to be standardized. 469 </para> 470 </notes> 471 </method> 472 <method name="erase"> 473 <parameter name="k"> 474 <paramtype>key_type const&</paramtype> 475 </parameter> 476 <type>size_type</type> 477 <description> 478 <para>Erase all elements with key equivalent to <code>k</code>.</para> 479 </description> 480 <returns> 481 <para>The number of elements erased.</para> 482 </returns> 483 <throws> 484 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 485 </throws> 486 </method> 487 <method name="erase"> 488 <parameter name="first"> 489 <paramtype>const_iterator</paramtype> 490 </parameter> 491 <parameter name="last"> 492 <paramtype>const_iterator</paramtype> 493 </parameter> 494 <type>iterator</type> 495 <description> 496 <para>Erases the elements in the range from <code>first</code> to <code>last</code>.</para> 497 </description> 498 <returns> 499 <para>The iterator following the erased elements - i.e. <code>last</code>.</para> 500 </returns> 501 <throws> 502 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 503 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 504 </throws> 505 </method> 506 <method name="quick_erase"> 507 <parameter name="position"> 508 <paramtype>const_iterator</paramtype> 509 </parameter> 510 <type>void</type> 511 <description> 512 <para>Erase the element pointed to by <code>position</code>.</para> 513 </description> 514 <throws> 515 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 516 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 517 </throws> 518 <notes> 519 <para> 520 This method is faster than <methodname>erase</methodname> as 521 it doesn't have to find the next element in the container - 522 a potentially costly operation. 523 </para> 524 <para> 525 As it hasn't been standardized, it's likely that this may 526 change in the future. 527 </para> 528 </notes> 529 </method> 530 <method name="erase_return_void"> 531 <parameter name="position"> 532 <paramtype>const_iterator</paramtype> 533 </parameter> 534 <type>void</type> 535 <description> 536 <para>Erase the element pointed to by <code>position</code>.</para> 537 </description> 538 <throws> 539 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 540 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 541 </throws> 542 <notes> 543 <para> 544 This method is now deprecated, use 545 <methodname>quick_return</methodname> instead. Although be 546 warned that as that isn't standardized yet, it could also 547 change. 548 </para> 549 </notes> 550 </method> 551 <method name="clear"> 552 <type>void</type> 553 <description> 554 <para>Erases all elements in the container.</para> 555 </description> 556 <postconditions> 557 <para><code><methodname>size</methodname>() == 0</code></para> 558 </postconditions> 559 <throws> 560 <para>Never throws an exception.</para> 561 </throws> 562 </method> 563 <method name="swap"> 564 <parameter> 565 <paramtype>unordered_set&</paramtype> 566 </parameter> 567 <type>void</type> 568 <throws> 569 <para>If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of <code>key_equal</code> or <code>hasher</code>.</para> 570 </throws> 571 <notes> 572 <para>For a discussion of the behavior when allocators aren't equal see 573 <link linkend="unordered.rationale.swapping_containers_with_unequal_allocators">the implementation details</link>.</para> 574 </notes> 575 </method> 576 </method-group> 577 <method-group name="observers"> 578 <method name="hash_function" cv="const"> 579 <type>hasher</type> 580 <returns>The container's hash function. 581 </returns> 582 </method> 583 <method name="key_eq" cv="const"> 584 <type>key_equal</type> 585 <returns>The container's key equality predicate. 586 </returns> 587 </method> 588 </method-group> 589 <method-group name="lookup"> 590 <overloaded-method name="find"> 591 <signature> 592 <parameter name="k"> 593 <paramtype>key_type const&</paramtype> 594 </parameter> 595 <type>iterator</type> 596 </signature> 597 <signature cv="const"> 598 <parameter name="k"> 599 <paramtype>key_type const&</paramtype> 600 </parameter> 601 <type>const_iterator</type> 602 </signature> 603 <signature> 604 <template> 605 <template-type-parameter name="CompatibleKey"/> 606 <template-type-parameter name="CompatibleHash"/> 607 <template-type-parameter name="CompatiblePredicate"/> 608 </template> 609 <parameter name="k"> 610 <paramtype>CompatibleKey const&</paramtype> 611 </parameter> 612 <parameter name="hash"> 613 <paramtype>CompatibleHash const&</paramtype> 614 </parameter> 615 <parameter name="eq"> 616 <paramtype>CompatiblePredicate const&</paramtype> 617 </parameter> 618 <type>iterator</type> 619 </signature> 620 <signature cv="const"> 621 <template> 622 <template-type-parameter name="CompatibleKey"/> 623 <template-type-parameter name="CompatibleHash"/> 624 <template-type-parameter name="CompatiblePredicate"/> 625 </template> 626 <parameter name="k"> 627 <paramtype>CompatibleKey const&</paramtype> 628 </parameter> 629 <parameter name="hash"> 630 <paramtype>CompatibleHash const&</paramtype> 631 </parameter> 632 <parameter name="eq"> 633 <paramtype>CompatiblePredicate const&</paramtype> 634 </parameter> 635 <type>const_iterator</type> 636 </signature> 637 <returns> 638 <para>An iterator pointing to an element with key equivalent to <code>k</code>, or <code>b.end()</code> if no such element exists.</para> 639 </returns> 640 <notes><para> 641 The templated overloads are a non-standard extensions which 642 allows you to use a compatible hash function and equality 643 predicate for a key of a different type in order to avoid 644 an expensive type cast. In general, its use is not encouraged. 645 </para></notes> 646 </overloaded-method> 647 <method name="count" cv="const"> 648 <parameter name="k"> 649 <paramtype>key_type const&</paramtype> 650 </parameter> 651 <type>size_type</type> 652 <returns> 653 <para>The number of elements with key equivalent to <code>k</code>.</para> 654 </returns> 655 </method> 656 <overloaded-method name="equal_range"> 657 <signature> 658 <parameter name="k"> 659 <paramtype>key_type const&</paramtype> 660 </parameter> 661 <type>std::pair<iterator, iterator></type> 662 </signature> 663 <signature cv="const"> 664 <parameter name="k"> 665 <paramtype>key_type const&</paramtype> 666 </parameter> 667 <type>std::pair<const_iterator, const_iterator></type> 668 </signature> 669 <returns> 670 <para>A range containing all elements with key equivalent to <code>k</code>. 671 If the container doesn't container any such elements, returns 672 <code><functionname>std::make_pair</functionname>(<methodname>b.end</methodname>(),<methodname>b.end</methodname>())</code>. 673 </para> 674 </returns> 675 </overloaded-method> 676 </method-group> 677 <method-group name="bucket interface"> 678 <method name="bucket_count" cv="const"> 679 <type>size_type</type> 680 <returns> 681 <para>The number of buckets.</para> 682 </returns> 683 </method> 684 <method name="max_bucket_count" cv="const"> 685 <type>size_type</type> 686 <returns> 687 <para>An upper bound on the number of buckets.</para> 688 </returns> 689 </method> 690 <method name="bucket_size" cv="const"> 691 <parameter name="n"> 692 <paramtype>size_type</paramtype> 693 </parameter> 694 <type>size_type</type> 695 <requires> 696 <para><code>n < <methodname>bucket_count</methodname>()</code></para> 697 </requires> 698 <returns> 699 <para>The number of elements in bucket <code>n</code>.</para> 700 </returns> 701 </method> 702 <method name="bucket" cv="const"> 703 <parameter name="k"> 704 <paramtype>key_type const&</paramtype> 705 </parameter> 706 <type>size_type</type> 707 <returns> 708 <para>The index of the bucket which would contain an element with key <code>k</code>.</para> 709 </returns> 710 <postconditions> 711 <para>The return value is less than <code>bucket_count()</code></para> 712 </postconditions> 713 </method> 714 <overloaded-method name="begin"> 715 <signature> 716 <parameter name="n"> 717 <paramtype>size_type</paramtype> 718 </parameter> 719 <type>local_iterator</type> 720 </signature> 721 <signature cv="const"> 722 <parameter name="n"> 723 <paramtype>size_type</paramtype> 724 </parameter> 725 <type>const_local_iterator</type> 726 </signature> 727 <requires> 728 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 729 </requires> 730 <returns> 731 <para>A local iterator pointing the first element in the bucket with index <code>n</code>.</para> 732 </returns> 733 </overloaded-method> 734 <overloaded-method name="end"> 735 <signature> 736 <parameter name="n"> 737 <paramtype>size_type</paramtype> 738 </parameter> 739 <type>local_iterator</type> 740 </signature> 741 <signature cv="const"> 742 <parameter name="n"> 743 <paramtype>size_type</paramtype> 744 </parameter> 745 <type>const_local_iterator</type> 746 </signature> 747 <requires> 748 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 749 </requires> 750 <returns> 751 <para>A local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para> 752 </returns> 753 </overloaded-method> 754 <method name="cbegin" cv="const"> 755 <parameter name="n"> 756 <paramtype>size_type</paramtype> 757 </parameter> 758 <type>const_local_iterator</type> 759 <requires> 760 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 761 </requires> 762 <returns> 763 <para>A constant local iterator pointing the first element in the bucket with index <code>n</code>.</para> 764 </returns> 765 </method> 766 <method name="cend"> 767 <parameter name="n"> 768 <paramtype>size_type</paramtype> 769 </parameter> 770 <type>const_local_iterator</type> 771 <requires> 772 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 773 </requires> 774 <returns> 775 <para>A constant local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para> 776 </returns> 777 </method> 778 </method-group> 779 <method-group name="hash policy"> 780 <method name="load_factor" cv="const"> 781 <type>float</type> 782 <returns> 783 <para>The average number of elements per bucket.</para> 784 </returns> 785 </method> 786 <method name="max_load_factor" cv="const"> 787 <type>float</type> 788 <returns> 789 <para>Returns the current maximum load factor.</para> 790 </returns> 791 </method> 792 <method name="max_load_factor"> 793 <parameter name="z"> 794 <paramtype>float</paramtype> 795 </parameter> 796 <type>void</type> 797 <effects> 798 <para>Changes the container's maximum load factor, using <code>z</code> as a hint.</para> 799 </effects> 800 </method> 801 <method name="rehash"> 802 <parameter name="n"> 803 <paramtype>size_type</paramtype> 804 </parameter> 805 <type>void</type> 806 <description> 807 <para>Changes the number of buckets so that there at least <code>n</code> buckets, and so that the load factor is less than the maximum load factor.</para> 808 <para>Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.</para> 809 </description> 810 <throws> 811 <para>The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.</para> 812 </throws> 813 </method> 814 </method-group> 815 <free-function-group name="Equality Comparisons"> 816 <function name="operator=="> 817 <template> 818 <template-type-parameter name="Value"> 819 </template-type-parameter> 820 <template-type-parameter name="Hash"> 821 </template-type-parameter> 822 <template-type-parameter name="Pred"> 823 </template-type-parameter> 824 <template-type-parameter name="Alloc"> 825 </template-type-parameter> 826 </template> 827 <parameter name="x"> 828 <paramtype>unordered_set<Value, Hash, Pred, Alloc> const&</paramtype> 829 </parameter> 830 <parameter name="y"> 831 <paramtype>unordered_set<Value, Hash, Pred, Alloc> const&</paramtype> 832 </parameter> 833 <type>bool</type> 834 <notes> 835 <para>This is a boost extension.</para> 836 <para>Behavior is undefined if the two containers don't have 837 equivalent equality predicates.</para> 838 </notes> 839 </function> 840 <function name="operator!="> 841 <template> 842 <template-type-parameter name="Value"> 843 </template-type-parameter> 844 <template-type-parameter name="Hash"> 845 </template-type-parameter> 846 <template-type-parameter name="Pred"> 847 </template-type-parameter> 848 <template-type-parameter name="Alloc"> 849 </template-type-parameter> 850 </template> 851 <parameter name="x"> 852 <paramtype>unordered_set<Value, Hash, Pred, Alloc> const&</paramtype> 853 </parameter> 854 <parameter name="y"> 855 <paramtype>unordered_set<Value, Hash, Pred, Alloc> const&</paramtype> 856 </parameter> 857 <type>bool</type> 858 <notes> 859 <para>This is a boost extension.</para> 860 <para>Behavior is undefined if the two containers don't have 861 equivalent equality predicates.</para> 862 </notes> 863 </function> 864 </free-function-group> 865 <free-function-group name="swap"> 866 <function name="swap"> 867 <template> 868 <template-type-parameter name="Value"> 869 </template-type-parameter> 870 <template-type-parameter name="Hash"> 871 </template-type-parameter> 872 <template-type-parameter name="Pred"> 873 </template-type-parameter> 874 <template-type-parameter name="Alloc"> 875 </template-type-parameter> 876 </template> 877 <parameter name="x"> 878 <paramtype>unordered_set<Value, Hash, Pred, Alloc>&</paramtype> 879 </parameter> 880 <parameter name="y"> 881 <paramtype>unordered_set<Value, Hash, Pred, Alloc>&</paramtype> 882 </parameter> 883 <type>void</type> 884 <effects> 885 <para><code>x.swap(y)</code></para> 886 </effects> 887 <throws> 888 <para>If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of <code>Hash</code> or <code>Pred</code>.</para> 889 </throws> 890 <notes> 891 <para>For a discussion of the behavior when allocators aren't equal see 892 <link linkend="unordered.rationale.swapping_containers_with_unequal_allocators">the implementation details</link>.</para> 893 </notes> 894 </function> 895 </free-function-group> 896 </class> 897 <class name="unordered_multiset"> 898 <template> 899 <template-type-parameter name="Value"> 900 </template-type-parameter> 901 <template-type-parameter name="Hash"> 902 <default><type>boost::hash<Value></type></default> 903 </template-type-parameter> 904 <template-type-parameter name="Pred"> 905 <default><type>std::equal_to<Value></type></default> 906 </template-type-parameter> 907 <template-type-parameter name="Alloc"> 908 <default><type>std::allocator<Value></type></default> 909 </template-type-parameter> 910 </template> 911 <purpose><simpara> 912 An unordered associative container that stores values. The same key can be stored multiple times. 913 </simpara></purpose> 914 <description> 915 <para>Based on chapter 23 of 916 <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2960.pdf">the working draft of the C++ standard [n2960]</ulink>. 917 But without the updated rules for allocators. 918 </para> 919 <para><emphasis role="bold">Template Parameters</emphasis> 920 <informaltable> 921 <tgroup cols="2"> 922 <tbody> 923 <row> 924 <entry><emphasis>Value</emphasis></entry> 925 <entry>Value must be Assignable and CopyConstructible</entry></row> 926 <row> 927 <entry><emphasis>Hash</emphasis></entry> 928 <entry>A unary function object type that acts a hash function for a <code>Value</code>. It takes a single argument of type <code>Value</code> and returns a value of type std::size_t.</entry></row> 929 <row> 930 <entry><emphasis>Pred</emphasis></entry> 931 <entry>A binary function object that implements an equivalence relation on values of type <code>Value</code>. 932 A binary function object that induces an equivalence relation on values of type Key. 933 It takes two arguments of type Key and returns a value of type bool.</entry></row> 934 <row> 935 <entry><emphasis>Alloc</emphasis></entry> 936 <entry>An allocator whose value type is the same as the container's value type.</entry></row></tbody></tgroup></informaltable></para> 937 <para>The elements are organized into buckets. Keys with the same hash code are stored in the same bucket and elements with equivalent keys are stored next to each other.</para> 938 <para>The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash.</para> 939 </description> 940 <typedef name="key_type"> 941 <type>Value</type> 942 </typedef> 943 <typedef name="value_type"> 944 <type>Value</type> 945 </typedef> 946 <typedef name="hasher"> 947 <type>Hash</type> 948 </typedef> 949 <typedef name="key_equal"> 950 <type>Pred</type> 951 </typedef> 952 <typedef name="allocator_type"> 953 <type>Alloc</type> 954 </typedef> 955 <typedef name="pointer"> 956 <type>typename allocator_type::pointer</type> 957 </typedef> 958 <typedef name="const_pointer"> 959 <type>typename allocator_type::const_pointer</type> 960 </typedef> 961 <typedef name="reference"> 962 <type>typename allocator_type::reference</type> 963 <purpose><simpara>lvalue of <type>value_type</type>.</simpara></purpose> 964 </typedef> 965 <typedef name="const_reference"> 966 <type>typename allocator_type::const_reference</type> 967 <purpose><simpara>const lvalue of <type>value_type</type>.</simpara></purpose> 968 </typedef> 969 <typedef name="size_type"> 970 <type><emphasis>implementation-defined</emphasis></type> 971 <description> 972 <para>An unsigned integral type.</para> 973 <para><type>size_type</type> can represent any non-negative value of <type>difference_type</type>.</para> 974 </description> 975 </typedef> 976 <typedef name="difference_type"> 977 <type><emphasis>implementation-defined</emphasis></type> 978 <description> 979 <para>A signed integral type.</para> 980 <para>Is identical to the difference type of <type>iterator</type> and <type>const_iterator</type>.</para> 981 </description> 982 </typedef> 983 <typedef name="iterator"> 984 <type><emphasis>implementation-defined</emphasis></type> 985 <description> 986 <para>A constant iterator whose value type is <type>value_type</type>. </para> 987 <para>The iterator category is at least a forward iterator.</para> 988 <para>Convertible to <type>const_iterator</type>.</para> 989 </description> 990 </typedef> 991 <typedef name="const_iterator"> 992 <type><emphasis>implementation-defined</emphasis></type> 993 <description> 994 <para>A constant iterator whose value type is <type>value_type</type>. </para> 995 <para>The iterator category is at least a forward iterator.</para> 996 </description> 997 </typedef> 998 <typedef name="local_iterator"> 999 <type><emphasis>implementation-defined</emphasis></type> 1000 <description> 1001 <para>An iterator with the same value type, difference type and pointer and reference type as <type>iterator</type>.</para> 1002 <para>A local_iterator object can be used to iterate through a single bucket.</para> 1003 </description> 1004 </typedef> 1005 <typedef name="const_local_iterator"> 1006 <type><emphasis>implementation-defined</emphasis></type> 1007 <description> 1008 <para>A constant iterator with the same value type, difference type and pointer and reference type as <type>const_iterator</type>.</para> 1009 <para>A const_local_iterator object can be used to iterate through a single bucket.</para> 1010 </description> 1011 </typedef> 1012 <constructor specifiers="explicit"> 1013 <parameter name="n"> 1014 <paramtype>size_type</paramtype> 1015 <default><emphasis>implementation-defined</emphasis></default> 1016 </parameter> 1017 <parameter name="hf"> 1018 <paramtype>hasher const&</paramtype> 1019 <default>hasher()</default> 1020 </parameter> 1021 <parameter name="eq"> 1022 <paramtype>key_equal const&</paramtype> 1023 <default>key_equal()</default> 1024 </parameter> 1025 <parameter name="a"> 1026 <paramtype>allocator_type const&</paramtype> 1027 <default>allocator_type()</default> 1028 </parameter> 1029 <postconditions> 1030 <code><methodname>size</methodname>() == 0</code> 1031 </postconditions> 1032 <description> 1033 <para>Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0.</para> 1034 </description> 1035 </constructor> 1036 <constructor> 1037 <template> 1038 <template-type-parameter name="InputIterator"> 1039 </template-type-parameter> 1040 </template> 1041 <parameter name="f"> 1042 <paramtype>InputIterator</paramtype> 1043 </parameter> 1044 <parameter name="l"> 1045 <paramtype>InputIterator</paramtype> 1046 </parameter> 1047 <parameter name="n"> 1048 <paramtype>size_type</paramtype> 1049 <default><emphasis>implementation-defined</emphasis></default> 1050 </parameter> 1051 <parameter name="hf"> 1052 <paramtype>hasher const&</paramtype> 1053 <default>hasher()</default> 1054 </parameter> 1055 <parameter name="eq"> 1056 <paramtype>key_equal const&</paramtype> 1057 <default>key_equal()</default> 1058 </parameter> 1059 <parameter name="a"> 1060 <paramtype>allocator_type const&</paramtype> 1061 <default>allocator_type()</default> 1062 </parameter> 1063 <description> 1064 <para>Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0 and inserts the elements from [f, l) into it.</para> 1065 </description> 1066 </constructor> 1067 <constructor> 1068 <parameter> 1069 <paramtype>unordered_multiset const&</paramtype> 1070 </parameter> 1071 <description> 1072 <para>The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.</para> 1073 </description> 1074 <requires> 1075 <para><code>value_type</code> is copy constructible</para> 1076 </requires> 1077 </constructor> 1078 <constructor> 1079 <parameter> 1080 <paramtype>unordered_multiset &&</paramtype> 1081 </parameter> 1082 <description> 1083 <para>The move constructor.</para> 1084 </description> 1085 <notes> 1086 <para>This is emulated on compilers without rvalue references.</para> 1087 </notes> 1088 <requires> 1089 <para> 1090 <code>value_type</code> is move constructible. 1091 (TODO: This is not actually required in this implementation). 1092 </para> 1093 </requires> 1094 </constructor> 1095 <constructor specifiers="explicit"> 1096 <parameter name="a"> 1097 <paramtype>Allocator const&</paramtype> 1098 </parameter> 1099 <description> 1100 <para>Constructs an empty container, using allocator <code>a</code>.</para> 1101 </description> 1102 </constructor> 1103 <constructor> 1104 <parameter name="x"> 1105 <paramtype>unordered_multiset const&</paramtype> 1106 </parameter> 1107 <parameter name="a"> 1108 <paramtype>Allocator const&</paramtype> 1109 </parameter> 1110 <description> 1111 <para>Constructs an container, copying <code>x</code>'s contained elements, hash function, predicate, maximum load factor, but using allocator <code>a</code>.</para> 1112 </description> 1113 </constructor> 1114 <destructor> 1115 <notes> 1116 <para>The destructor is applied to every element, and all memory is deallocated</para> 1117 </notes> 1118 </destructor> 1119 <method name="operator="> 1120 <parameter> 1121 <paramtype>unordered_multiset const&</paramtype> 1122 </parameter> 1123 <type>unordered_multiset&</type> 1124 <description> 1125 <para>The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.</para> 1126 </description> 1127 <notes> 1128 <para> 1129 On compilers without rvalue references, there is a single assignment 1130 operator with the signature <code>operator=(unordered_multiset)</code> 1131 in order to emulate move semantics. 1132 </para> 1133 </notes> 1134 <requires> 1135 <para><code>value_type</code> is copy constructible</para> 1136 </requires> 1137 </method> 1138 <method name="operator="> 1139 <parameter> 1140 <paramtype>unordered_multiset &&</paramtype> 1141 </parameter> 1142 <type>unordered_multiset&</type> 1143 <description> 1144 <para>The move assignment operator.</para> 1145 </description> 1146 <notes> 1147 <para> 1148 On compilers without rvalue references, there is a single assignment 1149 operator with the signature <code>operator=(unordered_multiset)</code> 1150 in order to emulate move semantics. 1151 </para> 1152 </notes> 1153 <requires> 1154 <para> 1155 <code>value_type</code> is move constructible. 1156 (TODO: This is not actually required in this implementation). 1157 </para> 1158 </requires> 1159 </method> 1160 <method name="get_allocator" cv="const"> 1161 <type>allocator_type</type> 1162 </method> 1163 <method-group name="size and capacity"> 1164 <method name="empty" cv="const"> 1165 <type>bool</type> 1166 <returns> 1167 <code><methodname>size</methodname>() == 0</code> 1168 </returns> 1169 </method> 1170 <method name="size" cv="const"> 1171 <type>size_type</type> 1172 <returns> 1173 <code>std::distance(<methodname>begin</methodname>(), <methodname>end</methodname>())</code> 1174 </returns> 1175 </method> 1176 <method name="max_size" cv="const"> 1177 <type>size_type</type> 1178 <returns><code><methodname>size</methodname>()</code> of the largest possible container. 1179 </returns> 1180 </method> 1181 </method-group> 1182 <method-group name="iterators"> 1183 <overloaded-method name="begin"> 1184 <signature><type>iterator</type></signature> 1185 <signature cv="const"><type>const_iterator</type></signature> 1186 <returns>An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. 1187 </returns> 1188 </overloaded-method> 1189 <overloaded-method name="end"> 1190 <signature> 1191 <type>iterator</type> 1192 </signature> 1193 <signature cv="const"> 1194 <type>const_iterator</type> 1195 </signature> 1196 <returns>An iterator which refers to the past-the-end value for the container. 1197 </returns> 1198 </overloaded-method> 1199 <method name="cbegin" cv="const"> 1200 <type>const_iterator</type> 1201 <returns>A constant iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. 1202 </returns> 1203 </method> 1204 <method name="cend" cv="const"> 1205 <type>const_iterator</type> 1206 <returns>A constant iterator which refers to the past-the-end value for the container. 1207 </returns> 1208 </method> 1209 </method-group> 1210 <method-group name="modifiers"> 1211 <method name="emplace"> 1212 <template> 1213 <template-type-parameter name="Args" pack="1"> 1214 </template-type-parameter> 1215 </template> 1216 <parameter name="args" pack="1"> 1217 <paramtype>Args&&</paramtype> 1218 </parameter> 1219 <type>iterator</type> 1220 <description> 1221 <para>Inserts an object, constructed with the arguments <code>args</code>, in the container.</para> 1222 </description> 1223 <returns> 1224 <para>An iterator pointing to the inserted element.</para> 1225 </returns> 1226 <throws> 1227 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 1228 </throws> 1229 <notes> 1230 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 1231 <para>Pointers and references to elements are never invalidated.</para> 1232 <para>If the compiler doesn't support variadic template arguments or rvalue 1233 references, this is emulated for up to 10 arguments, with no support 1234 for rvalue references or move semantics.</para> 1235 </notes> 1236 </method> 1237 <method name="emplace_hint"> 1238 <template> 1239 <template-type-parameter name="Args" pack="1"> 1240 </template-type-parameter> 1241 </template> 1242 <parameter name="hint"> 1243 <paramtype>const_iterator</paramtype> 1244 </parameter> 1245 <parameter name="args" pack="1"> 1246 <paramtype>Args&&</paramtype> 1247 </parameter> 1248 <type>iterator</type> 1249 <description> 1250 <para>Inserts an object, constructed with the arguments <code>args</code>, in the container.</para> 1251 <para>hint is a suggestion to where the element should be inserted.</para> 1252 </description> 1253 <returns> 1254 <para>An iterator pointing to the inserted element.</para> 1255 </returns> 1256 <throws> 1257 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 1258 </throws> 1259 <notes> 1260 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same value. </para> 1261 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 1262 <para>Pointers and references to elements are never invalidated.</para> 1263 <para>If the compiler doesn't support variadic template arguments or rvalue 1264 references, this is emulated for up to 10 arguments, with no support 1265 for rvalue references or move semantics.</para> 1266 </notes> 1267 </method> 1268 <method name="insert"> 1269 <parameter name="obj"> 1270 <paramtype>value_type const&</paramtype> 1271 </parameter> 1272 <type>iterator</type> 1273 <description> 1274 <para>Inserts obj in the container.</para> 1275 </description> 1276 <returns> 1277 <para>An iterator pointing to the inserted element.</para> 1278 </returns> 1279 <throws> 1280 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 1281 </throws> 1282 <notes> 1283 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 1284 <para>Pointers and references to elements are never invalidated.</para> 1285 </notes> 1286 </method> 1287 <method name="insert"> 1288 <parameter name="hint"> 1289 <paramtype>const_iterator</paramtype> 1290 </parameter> 1291 <parameter name="obj"> 1292 <paramtype>value_type const&</paramtype> 1293 </parameter> 1294 <type>iterator</type> 1295 <description> 1296 <para>Inserts obj in the container.</para> 1297 <para>hint is a suggestion to where the element should be inserted.</para> 1298 </description> 1299 <returns> 1300 <para>An iterator pointing to the inserted element.</para> 1301 </returns> 1302 <throws> 1303 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 1304 </throws> 1305 <notes> 1306 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same value. </para> 1307 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 1308 <para>Pointers and references to elements are never invalidated.</para> 1309 </notes> 1310 </method> 1311 <method name="insert"> 1312 <template> 1313 <template-type-parameter name="InputIterator"> 1314 </template-type-parameter> 1315 </template> 1316 <parameter name="first"> 1317 <paramtype>InputIterator</paramtype> 1318 </parameter> 1319 <parameter name="last"> 1320 <paramtype>InputIterator</paramtype> 1321 </parameter> 1322 <type>void</type> 1323 <description> 1324 <para>Inserts a range of elements into the container.</para> 1325 </description> 1326 <throws> 1327 <para>When inserting a single element, if an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 1328 </throws> 1329 <notes> 1330 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 1331 <para>Pointers and references to elements are never invalidated.</para> 1332 </notes> 1333 </method> 1334 <method name="erase"> 1335 <parameter name="position"> 1336 <paramtype>const_iterator</paramtype> 1337 </parameter> 1338 <type>iterator</type> 1339 <description> 1340 <para>Erase the element pointed to by <code>position</code>.</para> 1341 </description> 1342 <returns> 1343 <para>The iterator following <code>position</code> before the erasure.</para> 1344 </returns> 1345 <throws> 1346 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 1347 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 1348 </throws> 1349 <notes> 1350 <para> 1351 When the number of elements is a lot smaller than the number of buckets 1352 this function can be very inefficient as it has to search through empty 1353 buckets for the next element, in order to return the iterator. 1354 The method <methodname>quick_erase</methodname> is faster, but has yet 1355 to be standardized. 1356 </para> 1357 </notes> 1358 </method> 1359 <method name="erase"> 1360 <parameter name="k"> 1361 <paramtype>key_type const&</paramtype> 1362 </parameter> 1363 <type>size_type</type> 1364 <description> 1365 <para>Erase all elements with key equivalent to <code>k</code>.</para> 1366 </description> 1367 <returns> 1368 <para>The number of elements erased.</para> 1369 </returns> 1370 <throws> 1371 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 1372 </throws> 1373 </method> 1374 <method name="erase"> 1375 <parameter name="first"> 1376 <paramtype>const_iterator</paramtype> 1377 </parameter> 1378 <parameter name="last"> 1379 <paramtype>const_iterator</paramtype> 1380 </parameter> 1381 <type>iterator</type> 1382 <description> 1383 <para>Erases the elements in the range from <code>first</code> to <code>last</code>.</para> 1384 </description> 1385 <returns> 1386 <para>The iterator following the erased elements - i.e. <code>last</code>.</para> 1387 </returns> 1388 <throws> 1389 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 1390 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 1391 </throws> 1392 </method> 1393 <method name="quick_erase"> 1394 <parameter name="position"> 1395 <paramtype>const_iterator</paramtype> 1396 </parameter> 1397 <type>void</type> 1398 <description> 1399 <para>Erase the element pointed to by <code>position</code>.</para> 1400 </description> 1401 <throws> 1402 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 1403 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 1404 </throws> 1405 <notes> 1406 <para> 1407 This method is faster than <methodname>erase</methodname> as 1408 it doesn't have to find the next element in the container - 1409 a potentially costly operation. 1410 </para> 1411 <para> 1412 As it hasn't been standardized, it's likely that this may 1413 change in the future. 1414 </para> 1415 </notes> 1416 </method> 1417 <method name="erase_return_void"> 1418 <parameter name="position"> 1419 <paramtype>const_iterator</paramtype> 1420 </parameter> 1421 <type>void</type> 1422 <description> 1423 <para>Erase the element pointed to by <code>position</code>.</para> 1424 </description> 1425 <throws> 1426 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 1427 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 1428 </throws> 1429 <notes> 1430 <para> 1431 This method is now deprecated, use 1432 <methodname>quick_return</methodname> instead. Although be 1433 warned that as that isn't standardized yet, it could also 1434 change. 1435 </para> 1436 </notes> 1437 </method> 1438 <method name="clear"> 1439 <type>void</type> 1440 <description> 1441 <para>Erases all elements in the container.</para> 1442 </description> 1443 <postconditions> 1444 <para><code><methodname>size</methodname>() == 0</code></para> 1445 </postconditions> 1446 <throws> 1447 <para>Never throws an exception.</para> 1448 </throws> 1449 </method> 1450 <method name="swap"> 1451 <parameter> 1452 <paramtype>unordered_multiset&</paramtype> 1453 </parameter> 1454 <type>void</type> 1455 <throws> 1456 <para>If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of <code>key_equal</code> or <code>hasher</code>.</para> 1457 </throws> 1458 <notes> 1459 <para>For a discussion of the behavior when allocators aren't equal see 1460 <link linkend="unordered.rationale.swapping_containers_with_unequal_allocators">the implementation details</link>.</para> 1461 </notes> 1462 </method> 1463 </method-group> 1464 <method-group name="observers"> 1465 <method name="hash_function" cv="const"> 1466 <type>hasher</type> 1467 <returns>The container's hash function. 1468 </returns> 1469 </method> 1470 <method name="key_eq" cv="const"> 1471 <type>key_equal</type> 1472 <returns>The container's key equality predicate. 1473 </returns> 1474 </method> 1475 </method-group> 1476 <method-group name="lookup"> 1477 <overloaded-method name="find"> 1478 <signature> 1479 <parameter name="k"> 1480 <paramtype>key_type const&</paramtype> 1481 </parameter> 1482 <type>iterator</type> 1483 </signature> 1484 <signature cv="const"> 1485 <parameter name="k"> 1486 <paramtype>key_type const&</paramtype> 1487 </parameter> 1488 <type>const_iterator</type> 1489 </signature> 1490 <signature> 1491 <template> 1492 <template-type-parameter name="CompatibleKey"/> 1493 <template-type-parameter name="CompatibleHash"/> 1494 <template-type-parameter name="CompatiblePredicate"/> 1495 </template> 1496 <parameter name="k"> 1497 <paramtype>CompatibleKey const&</paramtype> 1498 </parameter> 1499 <parameter name="hash"> 1500 <paramtype>CompatibleHash const&</paramtype> 1501 </parameter> 1502 <parameter name="eq"> 1503 <paramtype>CompatiblePredicate const&</paramtype> 1504 </parameter> 1505 <type>iterator</type> 1506 </signature> 1507 <signature cv="const"> 1508 <template> 1509 <template-type-parameter name="CompatibleKey"/> 1510 <template-type-parameter name="CompatibleHash"/> 1511 <template-type-parameter name="CompatiblePredicate"/> 1512 </template> 1513 <parameter name="k"> 1514 <paramtype>CompatibleKey const&</paramtype> 1515 </parameter> 1516 <parameter name="hash"> 1517 <paramtype>CompatibleHash const&</paramtype> 1518 </parameter> 1519 <parameter name="eq"> 1520 <paramtype>CompatiblePredicate const&</paramtype> 1521 </parameter> 1522 <type>const_iterator</type> 1523 </signature> 1524 <returns> 1525 <para>An iterator pointing to an element with key equivalent to <code>k</code>, or <code>b.end()</code> if no such element exists.</para> 1526 </returns> 1527 <notes><para> 1528 The templated overloads are a non-standard extensions which 1529 allows you to use a compatible hash function and equality 1530 predicate for a key of a different type in order to avoid 1531 an expensive type cast. In general, its use is not encouraged. 1532 </para></notes> 1533 </overloaded-method> 1534 <method name="count" cv="const"> 1535 <parameter name="k"> 1536 <paramtype>key_type const&</paramtype> 1537 </parameter> 1538 <type>size_type</type> 1539 <returns> 1540 <para>The number of elements with key equivalent to <code>k</code>.</para> 1541 </returns> 1542 </method> 1543 <overloaded-method name="equal_range"> 1544 <signature> 1545 <parameter name="k"> 1546 <paramtype>key_type const&</paramtype> 1547 </parameter> 1548 <type>std::pair<iterator, iterator></type> 1549 </signature> 1550 <signature cv="const"> 1551 <parameter name="k"> 1552 <paramtype>key_type const&</paramtype> 1553 </parameter> 1554 <type>std::pair<const_iterator, const_iterator></type> 1555 </signature> 1556 <returns> 1557 <para>A range containing all elements with key equivalent to <code>k</code>. 1558 If the container doesn't container any such elements, returns 1559 <code><functionname>std::make_pair</functionname>(<methodname>b.end</methodname>(),<methodname>b.end</methodname>())</code>. 1560 </para> 1561 </returns> 1562 </overloaded-method> 1563 </method-group> 1564 <method-group name="bucket interface"> 1565 <method name="bucket_count" cv="const"> 1566 <type>size_type</type> 1567 <returns> 1568 <para>The number of buckets.</para> 1569 </returns> 1570 </method> 1571 <method name="max_bucket_count" cv="const"> 1572 <type>size_type</type> 1573 <returns> 1574 <para>An upper bound on the number of buckets.</para> 1575 </returns> 1576 </method> 1577 <method name="bucket_size" cv="const"> 1578 <parameter name="n"> 1579 <paramtype>size_type</paramtype> 1580 </parameter> 1581 <type>size_type</type> 1582 <requires> 1583 <para><code>n < <methodname>bucket_count</methodname>()</code></para> 1584 </requires> 1585 <returns> 1586 <para>The number of elements in bucket <code>n</code>.</para> 1587 </returns> 1588 </method> 1589 <method name="bucket" cv="const"> 1590 <parameter name="k"> 1591 <paramtype>key_type const&</paramtype> 1592 </parameter> 1593 <type>size_type</type> 1594 <returns> 1595 <para>The index of the bucket which would contain an element with key <code>k</code>.</para> 1596 </returns> 1597 <postconditions> 1598 <para>The return value is less than <code>bucket_count()</code></para> 1599 </postconditions> 1600 </method> 1601 <overloaded-method name="begin"> 1602 <signature> 1603 <parameter name="n"> 1604 <paramtype>size_type</paramtype> 1605 </parameter> 1606 <type>local_iterator</type> 1607 </signature> 1608 <signature cv="const"> 1609 <parameter name="n"> 1610 <paramtype>size_type</paramtype> 1611 </parameter> 1612 <type>const_local_iterator</type> 1613 </signature> 1614 <requires> 1615 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 1616 </requires> 1617 <returns> 1618 <para>A local iterator pointing the first element in the bucket with index <code>n</code>.</para> 1619 </returns> 1620 </overloaded-method> 1621 <overloaded-method name="end"> 1622 <signature> 1623 <parameter name="n"> 1624 <paramtype>size_type</paramtype> 1625 </parameter> 1626 <type>local_iterator</type> 1627 </signature> 1628 <signature cv="const"> 1629 <parameter name="n"> 1630 <paramtype>size_type</paramtype> 1631 </parameter> 1632 <type>const_local_iterator</type> 1633 </signature> 1634 <requires> 1635 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 1636 </requires> 1637 <returns> 1638 <para>A local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para> 1639 </returns> 1640 </overloaded-method> 1641 <method name="cbegin" cv="const"> 1642 <parameter name="n"> 1643 <paramtype>size_type</paramtype> 1644 </parameter> 1645 <type>const_local_iterator</type> 1646 <requires> 1647 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 1648 </requires> 1649 <returns> 1650 <para>A constant local iterator pointing the first element in the bucket with index <code>n</code>.</para> 1651 </returns> 1652 </method> 1653 <method name="cend"> 1654 <parameter name="n"> 1655 <paramtype>size_type</paramtype> 1656 </parameter> 1657 <type>const_local_iterator</type> 1658 <requires> 1659 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 1660 </requires> 1661 <returns> 1662 <para>A constant local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para> 1663 </returns> 1664 </method> 1665 </method-group> 1666 <method-group name="hash policy"> 1667 <method name="load_factor" cv="const"> 1668 <type>float</type> 1669 <returns> 1670 <para>The average number of elements per bucket.</para> 1671 </returns> 1672 </method> 1673 <method name="max_load_factor" cv="const"> 1674 <type>float</type> 1675 <returns> 1676 <para>Returns the current maximum load factor.</para> 1677 </returns> 1678 </method> 1679 <method name="max_load_factor"> 1680 <parameter name="z"> 1681 <paramtype>float</paramtype> 1682 </parameter> 1683 <type>void</type> 1684 <effects> 1685 <para>Changes the container's maximum load factor, using <code>z</code> as a hint.</para> 1686 </effects> 1687 </method> 1688 <method name="rehash"> 1689 <parameter name="n"> 1690 <paramtype>size_type</paramtype> 1691 </parameter> 1692 <type>void</type> 1693 <description> 1694 <para>Changes the number of buckets so that there at least <code>n</code> buckets, and so that the load factor is less than the maximum load factor.</para> 1695 <para>Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.</para> 1696 </description> 1697 <throws> 1698 <para>The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.</para> 1699 </throws> 1700 </method> 1701 </method-group> 1702 <free-function-group name="Equality Comparisons"> 1703 <function name="operator=="> 1704 <template> 1705 <template-type-parameter name="Value"> 1706 </template-type-parameter> 1707 <template-type-parameter name="Hash"> 1708 </template-type-parameter> 1709 <template-type-parameter name="Pred"> 1710 </template-type-parameter> 1711 <template-type-parameter name="Alloc"> 1712 </template-type-parameter> 1713 </template> 1714 <parameter name="x"> 1715 <paramtype>unordered_multiset<Value, Hash, Pred, Alloc> const&</paramtype> 1716 </parameter> 1717 <parameter name="y"> 1718 <paramtype>unordered_multiset<Value, Hash, Pred, Alloc> const&</paramtype> 1719 </parameter> 1720 <type>bool</type> 1721 <notes> 1722 <para>This is a boost extension.</para> 1723 <para>Behavior is undefined if the two containers don't have 1724 equivalent equality predicates.</para> 1725 </notes> 1726 </function> 1727 <function name="operator!="> 1728 <template> 1729 <template-type-parameter name="Value"> 1730 </template-type-parameter> 1731 <template-type-parameter name="Hash"> 1732 </template-type-parameter> 1733 <template-type-parameter name="Pred"> 1734 </template-type-parameter> 1735 <template-type-parameter name="Alloc"> 1736 </template-type-parameter> 1737 </template> 1738 <parameter name="x"> 1739 <paramtype>unordered_multiset<Value, Hash, Pred, Alloc> const&</paramtype> 1740 </parameter> 1741 <parameter name="y"> 1742 <paramtype>unordered_multiset<Value, Hash, Pred, Alloc> const&</paramtype> 1743 </parameter> 1744 <type>bool</type> 1745 <notes> 1746 <para>This is a boost extension.</para> 1747 <para>Behavior is undefined if the two containers don't have 1748 equivalent equality predicates.</para> 1749 </notes> 1750 </function> 1751 </free-function-group> 1752 <free-function-group name="swap"> 1753 <function name="swap"> 1754 <template> 1755 <template-type-parameter name="Value"> 1756 </template-type-parameter> 1757 <template-type-parameter name="Hash"> 1758 </template-type-parameter> 1759 <template-type-parameter name="Pred"> 1760 </template-type-parameter> 1761 <template-type-parameter name="Alloc"> 1762 </template-type-parameter> 1763 </template> 1764 <parameter name="x"> 1765 <paramtype>unordered_multiset<Value, Hash, Pred, Alloc>&</paramtype> 1766 </parameter> 1767 <parameter name="y"> 1768 <paramtype>unordered_multiset<Value, Hash, Pred, Alloc>&</paramtype> 1769 </parameter> 1770 <type>void</type> 1771 <effects> 1772 <para><code>x.swap(y)</code></para> 1773 </effects> 1774 <throws> 1775 <para>If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of <code>Hash</code> or <code>Pred</code>.</para> 1776 </throws> 1777 <notes> 1778 <para>For a discussion of the behavior when allocators aren't equal see 1779 <link linkend="unordered.rationale.swapping_containers_with_unequal_allocators">the implementation details</link>.</para> 1780 </notes> 1781 </function> 1782 </free-function-group> 1783 </class> 1784 </namespace> 1785 </header> 1786 <header name="boost/unordered_map.hpp"> 1787 <namespace name="boost"> 1788 <class name="unordered_map"> 1789 <template> 1790 <template-type-parameter name="Key"> 1791 </template-type-parameter> 1792 <template-type-parameter name="Mapped"> 1793 </template-type-parameter> 1794 <template-type-parameter name="Hash"> 1795 <default><type>boost::hash<Key></type></default> 1796 </template-type-parameter> 1797 <template-type-parameter name="Pred"> 1798 <default><type>std::equal_to<Key></type></default> 1799 </template-type-parameter> 1800 <template-type-parameter name="Alloc"> 1801 <default><type>std::allocator<std::pair<Key const, Mapped> ></type></default> 1802 </template-type-parameter> 1803 </template> 1804 <purpose><simpara> 1805 An unordered associative container that associates unique keys with another value. 1806 </simpara></purpose> 1807 <description> 1808 <para>Based on chapter 23 of 1809 <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2960.pdf">the working draft of the C++ standard [n2960]</ulink>. 1810 But without the updated rules for allocators. 1811 </para> 1812 <para><emphasis role="bold">Template Parameters</emphasis> 1813 <informaltable> 1814 <tgroup cols="2"> 1815 <tbody> 1816 <row> 1817 <entry><emphasis>Key</emphasis></entry> 1818 <entry>Key must be Assignable and CopyConstructible.</entry></row> 1819 <row> 1820 <entry><emphasis>Mapped</emphasis></entry> 1821 <entry>Mapped must be CopyConstructible</entry></row> 1822 <row> 1823 <entry><emphasis>Hash</emphasis></entry> 1824 <entry>A unary function object type that acts a hash function for a <code>Key</code>. It takes a single argument of type <code>Key</code> and returns a value of type std::size_t.</entry></row> 1825 <row> 1826 <entry><emphasis>Pred</emphasis></entry> 1827 <entry>A binary function object that implements an equivalence relation on values of type <code>Key</code>. 1828 A binary function object that induces an equivalence relation on values of type Key. 1829 It takes two arguments of type Key and returns a value of type bool.</entry></row> 1830 <row> 1831 <entry><emphasis>Alloc</emphasis></entry> 1832 <entry>An allocator whose value type is the same as the container's value type.</entry></row></tbody></tgroup></informaltable></para> 1833 <para>The elements are organized into buckets. Keys with the same hash code are stored in the same bucket.</para> 1834 <para>The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash.</para> 1835 </description> 1836 <typedef name="key_type"> 1837 <type>Key</type> 1838 </typedef> 1839 <typedef name="value_type"> 1840 <type>std::pair<Key const, Mapped></type> 1841 </typedef> 1842 <typedef name="mapped_type"> 1843 <type>Mapped</type> 1844 </typedef> 1845 <typedef name="hasher"> 1846 <type>Hash</type> 1847 </typedef> 1848 <typedef name="key_equal"> 1849 <type>Pred</type> 1850 </typedef> 1851 <typedef name="allocator_type"> 1852 <type>Alloc</type> 1853 </typedef> 1854 <typedef name="pointer"> 1855 <type>typename allocator_type::pointer</type> 1856 </typedef> 1857 <typedef name="const_pointer"> 1858 <type>typename allocator_type::const_pointer</type> 1859 </typedef> 1860 <typedef name="reference"> 1861 <type>typename allocator_type::reference</type> 1862 <purpose><simpara>lvalue of <type>value_type</type>.</simpara></purpose> 1863 </typedef> 1864 <typedef name="const_reference"> 1865 <type>typename allocator_type::const_reference</type> 1866 <purpose><simpara>const lvalue of <type>value_type</type>.</simpara></purpose> 1867 </typedef> 1868 <typedef name="size_type"> 1869 <type><emphasis>implementation-defined</emphasis></type> 1870 <description> 1871 <para>An unsigned integral type.</para> 1872 <para><type>size_type</type> can represent any non-negative value of <type>difference_type</type>.</para> 1873 </description> 1874 </typedef> 1875 <typedef name="difference_type"> 1876 <type><emphasis>implementation-defined</emphasis></type> 1877 <description> 1878 <para>A signed integral type.</para> 1879 <para>Is identical to the difference type of <type>iterator</type> and <type>const_iterator</type>.</para> 1880 </description> 1881 </typedef> 1882 <typedef name="iterator"> 1883 <type><emphasis>implementation-defined</emphasis></type> 1884 <description> 1885 <para>A iterator whose value type is <type>value_type</type>. </para> 1886 <para>The iterator category is at least a forward iterator.</para> 1887 <para>Convertible to <type>const_iterator</type>.</para> 1888 </description> 1889 </typedef> 1890 <typedef name="const_iterator"> 1891 <type><emphasis>implementation-defined</emphasis></type> 1892 <description> 1893 <para>A constant iterator whose value type is <type>value_type</type>. </para> 1894 <para>The iterator category is at least a forward iterator.</para> 1895 </description> 1896 </typedef> 1897 <typedef name="local_iterator"> 1898 <type><emphasis>implementation-defined</emphasis></type> 1899 <description> 1900 <para>An iterator with the same value type, difference type and pointer and reference type as <type>iterator</type>.</para> 1901 <para>A local_iterator object can be used to iterate through a single bucket.</para> 1902 </description> 1903 </typedef> 1904 <typedef name="const_local_iterator"> 1905 <type><emphasis>implementation-defined</emphasis></type> 1906 <description> 1907 <para>A constant iterator with the same value type, difference type and pointer and reference type as <type>const_iterator</type>.</para> 1908 <para>A const_local_iterator object can be used to iterate through a single bucket.</para> 1909 </description> 1910 </typedef> 1911 <constructor specifiers="explicit"> 1912 <parameter name="n"> 1913 <paramtype>size_type</paramtype> 1914 <default><emphasis>implementation-defined</emphasis></default> 1915 </parameter> 1916 <parameter name="hf"> 1917 <paramtype>hasher const&</paramtype> 1918 <default>hasher()</default> 1919 </parameter> 1920 <parameter name="eq"> 1921 <paramtype>key_equal const&</paramtype> 1922 <default>key_equal()</default> 1923 </parameter> 1924 <parameter name="a"> 1925 <paramtype>allocator_type const&</paramtype> 1926 <default>allocator_type()</default> 1927 </parameter> 1928 <postconditions> 1929 <code><methodname>size</methodname>() == 0</code> 1930 </postconditions> 1931 <description> 1932 <para>Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0.</para> 1933 </description> 1934 </constructor> 1935 <constructor> 1936 <template> 1937 <template-type-parameter name="InputIterator"> 1938 </template-type-parameter> 1939 </template> 1940 <parameter name="f"> 1941 <paramtype>InputIterator</paramtype> 1942 </parameter> 1943 <parameter name="l"> 1944 <paramtype>InputIterator</paramtype> 1945 </parameter> 1946 <parameter name="n"> 1947 <paramtype>size_type</paramtype> 1948 <default><emphasis>implementation-defined</emphasis></default> 1949 </parameter> 1950 <parameter name="hf"> 1951 <paramtype>hasher const&</paramtype> 1952 <default>hasher()</default> 1953 </parameter> 1954 <parameter name="eq"> 1955 <paramtype>key_equal const&</paramtype> 1956 <default>key_equal()</default> 1957 </parameter> 1958 <parameter name="a"> 1959 <paramtype>allocator_type const&</paramtype> 1960 <default>allocator_type()</default> 1961 </parameter> 1962 <description> 1963 <para>Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0 and inserts the elements from [f, l) into it.</para> 1964 </description> 1965 </constructor> 1966 <constructor> 1967 <parameter> 1968 <paramtype>unordered_map const&</paramtype> 1969 </parameter> 1970 <description> 1971 <para>The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.</para> 1972 </description> 1973 <requires> 1974 <para><code>value_type</code> is copy constructible</para> 1975 </requires> 1976 </constructor> 1977 <constructor> 1978 <parameter> 1979 <paramtype>unordered_map &&</paramtype> 1980 </parameter> 1981 <description> 1982 <para>The move constructor.</para> 1983 </description> 1984 <notes> 1985 <para>This is emulated on compilers without rvalue references.</para> 1986 </notes> 1987 <requires> 1988 <para> 1989 <code>value_type</code> is move constructible. 1990 (TODO: This is not actually required in this implementation). 1991 </para> 1992 </requires> 1993 </constructor> 1994 <constructor specifiers="explicit"> 1995 <parameter name="a"> 1996 <paramtype>Allocator const&</paramtype> 1997 </parameter> 1998 <description> 1999 <para>Constructs an empty container, using allocator <code>a</code>.</para> 2000 </description> 2001 </constructor> 2002 <constructor> 2003 <parameter name="x"> 2004 <paramtype>unordered_map const&</paramtype> 2005 </parameter> 2006 <parameter name="a"> 2007 <paramtype>Allocator const&</paramtype> 2008 </parameter> 2009 <description> 2010 <para>Constructs an container, copying <code>x</code>'s contained elements, hash function, predicate, maximum load factor, but using allocator <code>a</code>.</para> 2011 </description> 2012 </constructor> 2013 <destructor> 2014 <notes> 2015 <para>The destructor is applied to every element, and all memory is deallocated</para> 2016 </notes> 2017 </destructor> 2018 <method name="operator="> 2019 <parameter> 2020 <paramtype>unordered_map const&</paramtype> 2021 </parameter> 2022 <type>unordered_map&</type> 2023 <description> 2024 <para>The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.</para> 2025 </description> 2026 <notes> 2027 <para> 2028 On compilers without rvalue references, there is a single assignment 2029 operator with the signature <code>operator=(unordered_map)</code> 2030 in order to emulate move semantics. 2031 </para> 2032 </notes> 2033 <requires> 2034 <para><code>value_type</code> is copy constructible</para> 2035 </requires> 2036 </method> 2037 <method name="operator="> 2038 <parameter> 2039 <paramtype>unordered_map &&</paramtype> 2040 </parameter> 2041 <type>unordered_map&</type> 2042 <description> 2043 <para>The move assignment operator.</para> 2044 </description> 2045 <notes> 2046 <para> 2047 On compilers without rvalue references, there is a single assignment 2048 operator with the signature <code>operator=(unordered_map)</code> 2049 in order to emulate move semantics. 2050 </para> 2051 </notes> 2052 <requires> 2053 <para> 2054 <code>value_type</code> is move constructible. 2055 (TODO: This is not actually required in this implementation). 2056 </para> 2057 </requires> 2058 </method> 2059 <method name="get_allocator" cv="const"> 2060 <type>allocator_type</type> 2061 </method> 2062 <method-group name="size and capacity"> 2063 <method name="empty" cv="const"> 2064 <type>bool</type> 2065 <returns> 2066 <code><methodname>size</methodname>() == 0</code> 2067 </returns> 2068 </method> 2069 <method name="size" cv="const"> 2070 <type>size_type</type> 2071 <returns> 2072 <code>std::distance(<methodname>begin</methodname>(), <methodname>end</methodname>())</code> 2073 </returns> 2074 </method> 2075 <method name="max_size" cv="const"> 2076 <type>size_type</type> 2077 <returns><code><methodname>size</methodname>()</code> of the largest possible container. 2078 </returns> 2079 </method> 2080 </method-group> 2081 <method-group name="iterators"> 2082 <overloaded-method name="begin"> 2083 <signature><type>iterator</type></signature> 2084 <signature cv="const"><type>const_iterator</type></signature> 2085 <returns>An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. 2086 </returns> 2087 </overloaded-method> 2088 <overloaded-method name="end"> 2089 <signature> 2090 <type>iterator</type> 2091 </signature> 2092 <signature cv="const"> 2093 <type>const_iterator</type> 2094 </signature> 2095 <returns>An iterator which refers to the past-the-end value for the container. 2096 </returns> 2097 </overloaded-method> 2098 <method name="cbegin" cv="const"> 2099 <type>const_iterator</type> 2100 <returns>A constant iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. 2101 </returns> 2102 </method> 2103 <method name="cend" cv="const"> 2104 <type>const_iterator</type> 2105 <returns>A constant iterator which refers to the past-the-end value for the container. 2106 </returns> 2107 </method> 2108 </method-group> 2109 <method-group name="modifiers"> 2110 <method name="emplace"> 2111 <template> 2112 <template-type-parameter name="Args" pack="1"> 2113 </template-type-parameter> 2114 </template> 2115 <parameter name="args" pack="1"> 2116 <paramtype>Args&&</paramtype> 2117 </parameter> 2118 <type>std::pair<iterator, bool></type> 2119 <description> 2120 <para>Inserts an object, constructed with the arguments <code>args</code>, in the container if and only if there is no element in the container with an equivalent key.</para> 2121 </description> 2122 <returns> 2123 <para>The bool component of the return type is true if an insert took place.</para> 2124 <para>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key.</para> 2125 </returns> 2126 <throws> 2127 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 2128 </throws> 2129 <notes> 2130 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 2131 <para>Pointers and references to elements are never invalidated.</para> 2132 <para>If the compiler doesn't support variadic template arguments or rvalue 2133 references, this is emulated for up to 10 arguments, with no support 2134 for rvalue references or move semantics.</para> 2135 </notes> 2136 </method> 2137 <method name="emplace_hint"> 2138 <template> 2139 <template-type-parameter name="Args" pack="1"> 2140 </template-type-parameter> 2141 </template> 2142 <parameter name="hint"> 2143 <paramtype>const_iterator</paramtype> 2144 </parameter> 2145 <parameter name="args" pack="1"> 2146 <paramtype>Args&&</paramtype> 2147 </parameter> 2148 <type>iterator</type> 2149 <description> 2150 <para>Inserts an object, constructed with the arguments <code>args</code>, in the container if and only if there is no element in the container with an equivalent key.</para> 2151 <para>hint is a suggestion to where the element should be inserted.</para> 2152 </description> 2153 <returns> 2154 <para>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key.</para> 2155 </returns> 2156 <throws> 2157 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 2158 </throws> 2159 <notes> 2160 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. </para> 2161 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 2162 <para>Pointers and references to elements are never invalidated.</para> 2163 <para>If the compiler doesn't support variadic template arguments or rvalue 2164 references, this is emulated for up to 10 arguments, with no support 2165 for rvalue references or move semantics.</para> 2166 </notes> 2167 </method> 2168 <method name="insert"> 2169 <parameter name="obj"> 2170 <paramtype>value_type const&</paramtype> 2171 </parameter> 2172 <type>std::pair<iterator, bool></type> 2173 <description> 2174 <para>Inserts obj in the container if and only if there is no element in the container with an equivalent key.</para> 2175 </description> 2176 <returns> 2177 <para>The bool component of the return type is true if an insert took place.</para> 2178 <para>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key.</para> 2179 </returns> 2180 <throws> 2181 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 2182 </throws> 2183 <notes> 2184 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 2185 <para>Pointers and references to elements are never invalidated.</para> 2186 </notes> 2187 </method> 2188 <method name="insert"> 2189 <parameter name="hint"> 2190 <paramtype>const_iterator</paramtype> 2191 </parameter> 2192 <parameter name="obj"> 2193 <paramtype>value_type const&</paramtype> 2194 </parameter> 2195 <type>iterator</type> 2196 <description> 2197 <para>Inserts obj in the container if and only if there is no element in the container with an equivalent key.</para> 2198 <para>hint is a suggestion to where the element should be inserted.</para> 2199 </description> 2200 <returns> 2201 <para>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key.</para> 2202 </returns> 2203 <throws> 2204 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 2205 </throws> 2206 <notes> 2207 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. </para> 2208 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 2209 <para>Pointers and references to elements are never invalidated.</para> 2210 </notes> 2211 </method> 2212 <method name="insert"> 2213 <template> 2214 <template-type-parameter name="InputIterator"> 2215 </template-type-parameter> 2216 </template> 2217 <parameter name="first"> 2218 <paramtype>InputIterator</paramtype> 2219 </parameter> 2220 <parameter name="last"> 2221 <paramtype>InputIterator</paramtype> 2222 </parameter> 2223 <type>void</type> 2224 <description> 2225 <para>Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key.</para> 2226 </description> 2227 <throws> 2228 <para>When inserting a single element, if an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 2229 </throws> 2230 <notes> 2231 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 2232 <para>Pointers and references to elements are never invalidated.</para> 2233 </notes> 2234 </method> 2235 <method name="erase"> 2236 <parameter name="position"> 2237 <paramtype>const_iterator</paramtype> 2238 </parameter> 2239 <type>iterator</type> 2240 <description> 2241 <para>Erase the element pointed to by <code>position</code>.</para> 2242 </description> 2243 <returns> 2244 <para>The iterator following <code>position</code> before the erasure.</para> 2245 </returns> 2246 <throws> 2247 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 2248 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 2249 </throws> 2250 <notes> 2251 <para> 2252 When the number of elements is a lot smaller than the number of buckets 2253 this function can be very inefficient as it has to search through empty 2254 buckets for the next element, in order to return the iterator. 2255 The method <methodname>quick_erase</methodname> is faster, but has yet 2256 to be standardized. 2257 </para> 2258 </notes> 2259 </method> 2260 <method name="erase"> 2261 <parameter name="k"> 2262 <paramtype>key_type const&</paramtype> 2263 </parameter> 2264 <type>size_type</type> 2265 <description> 2266 <para>Erase all elements with key equivalent to <code>k</code>.</para> 2267 </description> 2268 <returns> 2269 <para>The number of elements erased.</para> 2270 </returns> 2271 <throws> 2272 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 2273 </throws> 2274 </method> 2275 <method name="erase"> 2276 <parameter name="first"> 2277 <paramtype>const_iterator</paramtype> 2278 </parameter> 2279 <parameter name="last"> 2280 <paramtype>const_iterator</paramtype> 2281 </parameter> 2282 <type>iterator</type> 2283 <description> 2284 <para>Erases the elements in the range from <code>first</code> to <code>last</code>.</para> 2285 </description> 2286 <returns> 2287 <para>The iterator following the erased elements - i.e. <code>last</code>.</para> 2288 </returns> 2289 <throws> 2290 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 2291 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 2292 </throws> 2293 </method> 2294 <method name="quick_erase"> 2295 <parameter name="position"> 2296 <paramtype>const_iterator</paramtype> 2297 </parameter> 2298 <type>void</type> 2299 <description> 2300 <para>Erase the element pointed to by <code>position</code>.</para> 2301 </description> 2302 <throws> 2303 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 2304 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 2305 </throws> 2306 <notes> 2307 <para> 2308 This method is faster than <methodname>erase</methodname> as 2309 it doesn't have to find the next element in the container - 2310 a potentially costly operation. 2311 </para> 2312 <para> 2313 As it hasn't been standardized, it's likely that this may 2314 change in the future. 2315 </para> 2316 </notes> 2317 </method> 2318 <method name="erase_return_void"> 2319 <parameter name="position"> 2320 <paramtype>const_iterator</paramtype> 2321 </parameter> 2322 <type>void</type> 2323 <description> 2324 <para>Erase the element pointed to by <code>position</code>.</para> 2325 </description> 2326 <throws> 2327 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 2328 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 2329 </throws> 2330 <notes> 2331 <para> 2332 This method is now deprecated, use 2333 <methodname>quick_return</methodname> instead. Although be 2334 warned that as that isn't standardized yet, it could also 2335 change. 2336 </para> 2337 </notes> 2338 </method> 2339 <method name="clear"> 2340 <type>void</type> 2341 <description> 2342 <para>Erases all elements in the container.</para> 2343 </description> 2344 <postconditions> 2345 <para><code><methodname>size</methodname>() == 0</code></para> 2346 </postconditions> 2347 <throws> 2348 <para>Never throws an exception.</para> 2349 </throws> 2350 </method> 2351 <method name="swap"> 2352 <parameter> 2353 <paramtype>unordered_map&</paramtype> 2354 </parameter> 2355 <type>void</type> 2356 <throws> 2357 <para>If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of <code>key_equal</code> or <code>hasher</code>.</para> 2358 </throws> 2359 <notes> 2360 <para>For a discussion of the behavior when allocators aren't equal see 2361 <link linkend="unordered.rationale.swapping_containers_with_unequal_allocators">the implementation details</link>.</para> 2362 </notes> 2363 </method> 2364 </method-group> 2365 <method-group name="observers"> 2366 <method name="hash_function" cv="const"> 2367 <type>hasher</type> 2368 <returns>The container's hash function. 2369 </returns> 2370 </method> 2371 <method name="key_eq" cv="const"> 2372 <type>key_equal</type> 2373 <returns>The container's key equality predicate. 2374 </returns> 2375 </method> 2376 </method-group> 2377 <method-group name="lookup"> 2378 <overloaded-method name="find"> 2379 <signature> 2380 <parameter name="k"> 2381 <paramtype>key_type const&</paramtype> 2382 </parameter> 2383 <type>iterator</type> 2384 </signature> 2385 <signature cv="const"> 2386 <parameter name="k"> 2387 <paramtype>key_type const&</paramtype> 2388 </parameter> 2389 <type>const_iterator</type> 2390 </signature> 2391 <signature> 2392 <template> 2393 <template-type-parameter name="CompatibleKey"/> 2394 <template-type-parameter name="CompatibleHash"/> 2395 <template-type-parameter name="CompatiblePredicate"/> 2396 </template> 2397 <parameter name="k"> 2398 <paramtype>CompatibleKey const&</paramtype> 2399 </parameter> 2400 <parameter name="hash"> 2401 <paramtype>CompatibleHash const&</paramtype> 2402 </parameter> 2403 <parameter name="eq"> 2404 <paramtype>CompatiblePredicate const&</paramtype> 2405 </parameter> 2406 <type>iterator</type> 2407 </signature> 2408 <signature cv="const"> 2409 <template> 2410 <template-type-parameter name="CompatibleKey"/> 2411 <template-type-parameter name="CompatibleHash"/> 2412 <template-type-parameter name="CompatiblePredicate"/> 2413 </template> 2414 <parameter name="k"> 2415 <paramtype>CompatibleKey const&</paramtype> 2416 </parameter> 2417 <parameter name="hash"> 2418 <paramtype>CompatibleHash const&</paramtype> 2419 </parameter> 2420 <parameter name="eq"> 2421 <paramtype>CompatiblePredicate const&</paramtype> 2422 </parameter> 2423 <type>const_iterator</type> 2424 </signature> 2425 <returns> 2426 <para>An iterator pointing to an element with key equivalent to <code>k</code>, or <code>b.end()</code> if no such element exists.</para> 2427 </returns> 2428 <notes><para> 2429 The templated overloads are a non-standard extensions which 2430 allows you to use a compatible hash function and equality 2431 predicate for a key of a different type in order to avoid 2432 an expensive type cast. In general, its use is not encouraged. 2433 </para></notes> 2434 </overloaded-method> 2435 <method name="count" cv="const"> 2436 <parameter name="k"> 2437 <paramtype>key_type const&</paramtype> 2438 </parameter> 2439 <type>size_type</type> 2440 <returns> 2441 <para>The number of elements with key equivalent to <code>k</code>.</para> 2442 </returns> 2443 </method> 2444 <overloaded-method name="equal_range"> 2445 <signature> 2446 <parameter name="k"> 2447 <paramtype>key_type const&</paramtype> 2448 </parameter> 2449 <type>std::pair<iterator, iterator></type> 2450 </signature> 2451 <signature cv="const"> 2452 <parameter name="k"> 2453 <paramtype>key_type const&</paramtype> 2454 </parameter> 2455 <type>std::pair<const_iterator, const_iterator></type> 2456 </signature> 2457 <returns> 2458 <para>A range containing all elements with key equivalent to <code>k</code>. 2459 If the container doesn't container any such elements, returns 2460 <code><functionname>std::make_pair</functionname>(<methodname>b.end</methodname>(),<methodname>b.end</methodname>())</code>. 2461 </para> 2462 </returns> 2463 </overloaded-method> 2464 <method name="operator[]"> 2465 <parameter name="k"> 2466 <paramtype>key_type const&</paramtype> 2467 </parameter> 2468 <type>mapped_type&</type> 2469 <effects> 2470 <para>If the container does not already contain an elements with a key equivalent to <code>k</code>, inserts the value <code>std::pair<key_type const, mapped_type>(k, mapped_type())</code></para> 2471 </effects> 2472 <returns> 2473 <para>A reference to <code>x.second</code> where x is the element already in the container, or the newly inserted element with a key equivalent to <code>k</code></para> 2474 </returns> 2475 <throws> 2476 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 2477 </throws> 2478 <notes> 2479 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 2480 <para>Pointers and references to elements are never invalidated.</para> 2481 </notes> 2482 </method> 2483 <overloaded-method name="at"> 2484 <signature><type>Mapped&</type> 2485 <parameter name="k"><paramtype>key_type const&</paramtype></parameter></signature> 2486 <signature cv="const"><type>Mapped const&</type> 2487 <parameter name="k"><paramtype>key_type const&</paramtype></parameter></signature> 2488 <returns> 2489 <para>A reference to <code>x.second</code> where <code>x</code> is the (unique) element whose key is equivalent to <code>k</code>.</para> 2490 </returns> 2491 <throws> 2492 <para>An exception object of type <code>std::out_of_range</code> if no such element is present.</para> 2493 </throws> 2494 <notes> 2495 <para>This is not specified in the draft standard, but that is probably an oversight. The issue has been raised in 2496 <ulink url="http://groups.google.com/group/comp.std.c++/browse_thread/thread/ab7c22a868fd370b">comp.std.c++</ulink>.</para> 2497 </notes> 2498 </overloaded-method> 2499 </method-group> 2500 <method-group name="bucket interface"> 2501 <method name="bucket_count" cv="const"> 2502 <type>size_type</type> 2503 <returns> 2504 <para>The number of buckets.</para> 2505 </returns> 2506 </method> 2507 <method name="max_bucket_count" cv="const"> 2508 <type>size_type</type> 2509 <returns> 2510 <para>An upper bound on the number of buckets.</para> 2511 </returns> 2512 </method> 2513 <method name="bucket_size" cv="const"> 2514 <parameter name="n"> 2515 <paramtype>size_type</paramtype> 2516 </parameter> 2517 <type>size_type</type> 2518 <requires> 2519 <para><code>n < <methodname>bucket_count</methodname>()</code></para> 2520 </requires> 2521 <returns> 2522 <para>The number of elements in bucket <code>n</code>.</para> 2523 </returns> 2524 </method> 2525 <method name="bucket" cv="const"> 2526 <parameter name="k"> 2527 <paramtype>key_type const&</paramtype> 2528 </parameter> 2529 <type>size_type</type> 2530 <returns> 2531 <para>The index of the bucket which would contain an element with key <code>k</code>.</para> 2532 </returns> 2533 <postconditions> 2534 <para>The return value is less than <code>bucket_count()</code></para> 2535 </postconditions> 2536 </method> 2537 <overloaded-method name="begin"> 2538 <signature> 2539 <parameter name="n"> 2540 <paramtype>size_type</paramtype> 2541 </parameter> 2542 <type>local_iterator</type> 2543 </signature> 2544 <signature cv="const"> 2545 <parameter name="n"> 2546 <paramtype>size_type</paramtype> 2547 </parameter> 2548 <type>const_local_iterator</type> 2549 </signature> 2550 <requires> 2551 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 2552 </requires> 2553 <returns> 2554 <para>A local iterator pointing the first element in the bucket with index <code>n</code>.</para> 2555 </returns> 2556 </overloaded-method> 2557 <overloaded-method name="end"> 2558 <signature> 2559 <parameter name="n"> 2560 <paramtype>size_type</paramtype> 2561 </parameter> 2562 <type>local_iterator</type> 2563 </signature> 2564 <signature cv="const"> 2565 <parameter name="n"> 2566 <paramtype>size_type</paramtype> 2567 </parameter> 2568 <type>const_local_iterator</type> 2569 </signature> 2570 <requires> 2571 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 2572 </requires> 2573 <returns> 2574 <para>A local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para> 2575 </returns> 2576 </overloaded-method> 2577 <method name="cbegin" cv="const"> 2578 <parameter name="n"> 2579 <paramtype>size_type</paramtype> 2580 </parameter> 2581 <type>const_local_iterator</type> 2582 <requires> 2583 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 2584 </requires> 2585 <returns> 2586 <para>A constant local iterator pointing the first element in the bucket with index <code>n</code>.</para> 2587 </returns> 2588 </method> 2589 <method name="cend"> 2590 <parameter name="n"> 2591 <paramtype>size_type</paramtype> 2592 </parameter> 2593 <type>const_local_iterator</type> 2594 <requires> 2595 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 2596 </requires> 2597 <returns> 2598 <para>A constant local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para> 2599 </returns> 2600 </method> 2601 </method-group> 2602 <method-group name="hash policy"> 2603 <method name="load_factor" cv="const"> 2604 <type>float</type> 2605 <returns> 2606 <para>The average number of elements per bucket.</para> 2607 </returns> 2608 </method> 2609 <method name="max_load_factor" cv="const"> 2610 <type>float</type> 2611 <returns> 2612 <para>Returns the current maximum load factor.</para> 2613 </returns> 2614 </method> 2615 <method name="max_load_factor"> 2616 <parameter name="z"> 2617 <paramtype>float</paramtype> 2618 </parameter> 2619 <type>void</type> 2620 <effects> 2621 <para>Changes the container's maximum load factor, using <code>z</code> as a hint.</para> 2622 </effects> 2623 </method> 2624 <method name="rehash"> 2625 <parameter name="n"> 2626 <paramtype>size_type</paramtype> 2627 </parameter> 2628 <type>void</type> 2629 <description> 2630 <para>Changes the number of buckets so that there at least <code>n</code> buckets, and so that the load factor is less than the maximum load factor.</para> 2631 <para>Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.</para> 2632 </description> 2633 <throws> 2634 <para>The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.</para> 2635 </throws> 2636 </method> 2637 </method-group> 2638 <free-function-group name="Equality Comparisons"> 2639 <function name="operator=="> 2640 <template> 2641 <template-type-parameter name="Key"> 2642 </template-type-parameter> 2643 <template-type-parameter name="Mapped"> 2644 </template-type-parameter> 2645 <template-type-parameter name="Hash"> 2646 </template-type-parameter> 2647 <template-type-parameter name="Pred"> 2648 </template-type-parameter> 2649 <template-type-parameter name="Alloc"> 2650 </template-type-parameter> 2651 </template> 2652 <parameter name="x"> 2653 <paramtype>unordered_map<Key, Mapped, Hash, Pred, Alloc> const&</paramtype> 2654 </parameter> 2655 <parameter name="y"> 2656 <paramtype>unordered_map<Key, Mapped, Hash, Pred, Alloc> const&</paramtype> 2657 </parameter> 2658 <type>bool</type> 2659 <notes> 2660 <para>This is a boost extension.</para> 2661 <para>Behavior is undefined if the two containers don't have 2662 equivalent equality predicates.</para> 2663 </notes> 2664 </function> 2665 <function name="operator!="> 2666 <template> 2667 <template-type-parameter name="Key"> 2668 </template-type-parameter> 2669 <template-type-parameter name="Mapped"> 2670 </template-type-parameter> 2671 <template-type-parameter name="Hash"> 2672 </template-type-parameter> 2673 <template-type-parameter name="Pred"> 2674 </template-type-parameter> 2675 <template-type-parameter name="Alloc"> 2676 </template-type-parameter> 2677 </template> 2678 <parameter name="x"> 2679 <paramtype>unordered_map<Key, Mapped, Hash, Pred, Alloc> const&</paramtype> 2680 </parameter> 2681 <parameter name="y"> 2682 <paramtype>unordered_map<Key, Mapped, Hash, Pred, Alloc> const&</paramtype> 2683 </parameter> 2684 <type>bool</type> 2685 <notes> 2686 <para>This is a boost extension.</para> 2687 <para>Behavior is undefined if the two containers don't have 2688 equivalent equality predicates.</para> 2689 </notes> 2690 </function> 2691 </free-function-group> 2692 <free-function-group name="swap"> 2693 <function name="swap"> 2694 <template> 2695 <template-type-parameter name="Key"> 2696 </template-type-parameter> 2697 <template-type-parameter name="Mapped"> 2698 </template-type-parameter> 2699 <template-type-parameter name="Hash"> 2700 </template-type-parameter> 2701 <template-type-parameter name="Pred"> 2702 </template-type-parameter> 2703 <template-type-parameter name="Alloc"> 2704 </template-type-parameter> 2705 </template> 2706 <parameter name="x"> 2707 <paramtype>unordered_map<Key, Mapped, Hash, Pred, Alloc>&</paramtype> 2708 </parameter> 2709 <parameter name="y"> 2710 <paramtype>unordered_map<Key, Mapped, Hash, Pred, Alloc>&</paramtype> 2711 </parameter> 2712 <type>void</type> 2713 <effects> 2714 <para><code>x.swap(y)</code></para> 2715 </effects> 2716 <throws> 2717 <para>If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of <code>Hash</code> or <code>Pred</code>.</para> 2718 </throws> 2719 <notes> 2720 <para>For a discussion of the behavior when allocators aren't equal see 2721 <link linkend="unordered.rationale.swapping_containers_with_unequal_allocators">the implementation details</link>.</para> 2722 </notes> 2723 </function> 2724 </free-function-group> 2725 </class> 2726 <class name="unordered_multimap"> 2727 <template> 2728 <template-type-parameter name="Key"> 2729 </template-type-parameter> 2730 <template-type-parameter name="Mapped"> 2731 </template-type-parameter> 2732 <template-type-parameter name="Hash"> 2733 <default><type>boost::hash<Key></type></default> 2734 </template-type-parameter> 2735 <template-type-parameter name="Pred"> 2736 <default><type>std::equal_to<Key></type></default> 2737 </template-type-parameter> 2738 <template-type-parameter name="Alloc"> 2739 <default><type>std::allocator<std::pair<Key const, Mapped> ></type></default> 2740 </template-type-parameter> 2741 </template> 2742 <purpose><simpara> 2743 An unordered associative container that associates keys with another value. The same key can be stored multiple times. 2744 </simpara></purpose> 2745 <description> 2746 <para>Based on chapter 23 of 2747 <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2960.pdf">the working draft of the C++ standard [n2960]</ulink>. 2748 But without the updated rules for allocators. 2749 </para> 2750 <para><emphasis role="bold">Template Parameters</emphasis> 2751 <informaltable> 2752 <tgroup cols="2"> 2753 <tbody> 2754 <row> 2755 <entry><emphasis>Key</emphasis></entry> 2756 <entry>Key must be Assignable and CopyConstructible.</entry></row> 2757 <row> 2758 <entry><emphasis>Mapped</emphasis></entry> 2759 <entry>Mapped must be CopyConstructible</entry></row> 2760 <row> 2761 <entry><emphasis>Hash</emphasis></entry> 2762 <entry>A unary function object type that acts a hash function for a <code>Key</code>. It takes a single argument of type <code>Key</code> and returns a value of type std::size_t.</entry></row> 2763 <row> 2764 <entry><emphasis>Pred</emphasis></entry> 2765 <entry>A binary function object that implements an equivalence relation on values of type <code>Key</code>. 2766 A binary function object that induces an equivalence relation on values of type Key. 2767 It takes two arguments of type Key and returns a value of type bool.</entry></row> 2768 <row> 2769 <entry><emphasis>Alloc</emphasis></entry> 2770 <entry>An allocator whose value type is the same as the container's value type.</entry></row></tbody></tgroup></informaltable></para> 2771 <para>The elements are organized into buckets. Keys with the same hash code are stored in the same bucket and elements with equivalent keys are stored next to each other.</para> 2772 <para>The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash.</para> 2773 </description> 2774 <typedef name="key_type"> 2775 <type>Key</type> 2776 </typedef> 2777 <typedef name="value_type"> 2778 <type>std::pair<Key const, Mapped></type> 2779 </typedef> 2780 <typedef name="mapped_type"> 2781 <type>Mapped</type> 2782 </typedef> 2783 <typedef name="hasher"> 2784 <type>Hash</type> 2785 </typedef> 2786 <typedef name="key_equal"> 2787 <type>Pred</type> 2788 </typedef> 2789 <typedef name="allocator_type"> 2790 <type>Alloc</type> 2791 </typedef> 2792 <typedef name="pointer"> 2793 <type>typename allocator_type::pointer</type> 2794 </typedef> 2795 <typedef name="const_pointer"> 2796 <type>typename allocator_type::const_pointer</type> 2797 </typedef> 2798 <typedef name="reference"> 2799 <type>typename allocator_type::reference</type> 2800 <purpose><simpara>lvalue of <type>value_type</type>.</simpara></purpose> 2801 </typedef> 2802 <typedef name="const_reference"> 2803 <type>typename allocator_type::const_reference</type> 2804 <purpose><simpara>const lvalue of <type>value_type</type>.</simpara></purpose> 2805 </typedef> 2806 <typedef name="size_type"> 2807 <type><emphasis>implementation-defined</emphasis></type> 2808 <description> 2809 <para>An unsigned integral type.</para> 2810 <para><type>size_type</type> can represent any non-negative value of <type>difference_type</type>.</para> 2811 </description> 2812 </typedef> 2813 <typedef name="difference_type"> 2814 <type><emphasis>implementation-defined</emphasis></type> 2815 <description> 2816 <para>A signed integral type.</para> 2817 <para>Is identical to the difference type of <type>iterator</type> and <type>const_iterator</type>.</para> 2818 </description> 2819 </typedef> 2820 <typedef name="iterator"> 2821 <type><emphasis>implementation-defined</emphasis></type> 2822 <description> 2823 <para>A iterator whose value type is <type>value_type</type>. </para> 2824 <para>The iterator category is at least a forward iterator.</para> 2825 <para>Convertible to <type>const_iterator</type>.</para> 2826 </description> 2827 </typedef> 2828 <typedef name="const_iterator"> 2829 <type><emphasis>implementation-defined</emphasis></type> 2830 <description> 2831 <para>A constant iterator whose value type is <type>value_type</type>. </para> 2832 <para>The iterator category is at least a forward iterator.</para> 2833 </description> 2834 </typedef> 2835 <typedef name="local_iterator"> 2836 <type><emphasis>implementation-defined</emphasis></type> 2837 <description> 2838 <para>An iterator with the same value type, difference type and pointer and reference type as <type>iterator</type>.</para> 2839 <para>A local_iterator object can be used to iterate through a single bucket.</para> 2840 </description> 2841 </typedef> 2842 <typedef name="const_local_iterator"> 2843 <type><emphasis>implementation-defined</emphasis></type> 2844 <description> 2845 <para>A constant iterator with the same value type, difference type and pointer and reference type as <type>const_iterator</type>.</para> 2846 <para>A const_local_iterator object can be used to iterate through a single bucket.</para> 2847 </description> 2848 </typedef> 2849 <constructor specifiers="explicit"> 2850 <parameter name="n"> 2851 <paramtype>size_type</paramtype> 2852 <default><emphasis>implementation-defined</emphasis></default> 2853 </parameter> 2854 <parameter name="hf"> 2855 <paramtype>hasher const&</paramtype> 2856 <default>hasher()</default> 2857 </parameter> 2858 <parameter name="eq"> 2859 <paramtype>key_equal const&</paramtype> 2860 <default>key_equal()</default> 2861 </parameter> 2862 <parameter name="a"> 2863 <paramtype>allocator_type const&</paramtype> 2864 <default>allocator_type()</default> 2865 </parameter> 2866 <postconditions> 2867 <code><methodname>size</methodname>() == 0</code> 2868 </postconditions> 2869 <description> 2870 <para>Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0.</para> 2871 </description> 2872 </constructor> 2873 <constructor> 2874 <template> 2875 <template-type-parameter name="InputIterator"> 2876 </template-type-parameter> 2877 </template> 2878 <parameter name="f"> 2879 <paramtype>InputIterator</paramtype> 2880 </parameter> 2881 <parameter name="l"> 2882 <paramtype>InputIterator</paramtype> 2883 </parameter> 2884 <parameter name="n"> 2885 <paramtype>size_type</paramtype> 2886 <default><emphasis>implementation-defined</emphasis></default> 2887 </parameter> 2888 <parameter name="hf"> 2889 <paramtype>hasher const&</paramtype> 2890 <default>hasher()</default> 2891 </parameter> 2892 <parameter name="eq"> 2893 <paramtype>key_equal const&</paramtype> 2894 <default>key_equal()</default> 2895 </parameter> 2896 <parameter name="a"> 2897 <paramtype>allocator_type const&</paramtype> 2898 <default>allocator_type()</default> 2899 </parameter> 2900 <description> 2901 <para>Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0 and inserts the elements from [f, l) into it.</para> 2902 </description> 2903 </constructor> 2904 <constructor> 2905 <parameter> 2906 <paramtype>unordered_multimap const&</paramtype> 2907 </parameter> 2908 <description> 2909 <para>The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.</para> 2910 </description> 2911 <requires> 2912 <para><code>value_type</code> is copy constructible</para> 2913 </requires> 2914 </constructor> 2915 <constructor> 2916 <parameter> 2917 <paramtype>unordered_multimap &&</paramtype> 2918 </parameter> 2919 <description> 2920 <para>The move constructor.</para> 2921 </description> 2922 <notes> 2923 <para>This is emulated on compilers without rvalue references.</para> 2924 </notes> 2925 <requires> 2926 <para> 2927 <code>value_type</code> is move constructible. 2928 (TODO: This is not actually required in this implementation). 2929 </para> 2930 </requires> 2931 </constructor> 2932 <constructor specifiers="explicit"> 2933 <parameter name="a"> 2934 <paramtype>Allocator const&</paramtype> 2935 </parameter> 2936 <description> 2937 <para>Constructs an empty container, using allocator <code>a</code>.</para> 2938 </description> 2939 </constructor> 2940 <constructor> 2941 <parameter name="x"> 2942 <paramtype>unordered_multimap const&</paramtype> 2943 </parameter> 2944 <parameter name="a"> 2945 <paramtype>Allocator const&</paramtype> 2946 </parameter> 2947 <description> 2948 <para>Constructs an container, copying <code>x</code>'s contained elements, hash function, predicate, maximum load factor, but using allocator <code>a</code>.</para> 2949 </description> 2950 </constructor> 2951 <destructor> 2952 <notes> 2953 <para>The destructor is applied to every element, and all memory is deallocated</para> 2954 </notes> 2955 </destructor> 2956 <method name="operator="> 2957 <parameter> 2958 <paramtype>unordered_multimap const&</paramtype> 2959 </parameter> 2960 <type>unordered_multimap&</type> 2961 <description> 2962 <para>The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.</para> 2963 </description> 2964 <notes> 2965 <para> 2966 On compilers without rvalue references, there is a single assignment 2967 operator with the signature <code>operator=(unordered_multimap)</code> 2968 in order to emulate move semantics. 2969 </para> 2970 </notes> 2971 <requires> 2972 <para><code>value_type</code> is copy constructible</para> 2973 </requires> 2974 </method> 2975 <method name="operator="> 2976 <parameter> 2977 <paramtype>unordered_multimap &&</paramtype> 2978 </parameter> 2979 <type>unordered_multimap&</type> 2980 <description> 2981 <para>The move assignment operator.</para> 2982 </description> 2983 <notes> 2984 <para> 2985 On compilers without rvalue references, there is a single assignment 2986 operator with the signature <code>operator=(unordered_multimap)</code> 2987 in order to emulate move semantics. 2988 </para> 2989 </notes> 2990 <requires> 2991 <para> 2992 <code>value_type</code> is move constructible. 2993 (TODO: This is not actually required in this implementation). 2994 </para> 2995 </requires> 2996 </method> 2997 <method name="get_allocator" cv="const"> 2998 <type>allocator_type</type> 2999 </method> 3000 <method-group name="size and capacity"> 3001 <method name="empty" cv="const"> 3002 <type>bool</type> 3003 <returns> 3004 <code><methodname>size</methodname>() == 0</code> 3005 </returns> 3006 </method> 3007 <method name="size" cv="const"> 3008 <type>size_type</type> 3009 <returns> 3010 <code>std::distance(<methodname>begin</methodname>(), <methodname>end</methodname>())</code> 3011 </returns> 3012 </method> 3013 <method name="max_size" cv="const"> 3014 <type>size_type</type> 3015 <returns><code><methodname>size</methodname>()</code> of the largest possible container. 3016 </returns> 3017 </method> 3018 </method-group> 3019 <method-group name="iterators"> 3020 <overloaded-method name="begin"> 3021 <signature><type>iterator</type></signature> 3022 <signature cv="const"><type>const_iterator</type></signature> 3023 <returns>An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. 3024 </returns> 3025 </overloaded-method> 3026 <overloaded-method name="end"> 3027 <signature> 3028 <type>iterator</type> 3029 </signature> 3030 <signature cv="const"> 3031 <type>const_iterator</type> 3032 </signature> 3033 <returns>An iterator which refers to the past-the-end value for the container. 3034 </returns> 3035 </overloaded-method> 3036 <method name="cbegin" cv="const"> 3037 <type>const_iterator</type> 3038 <returns>A constant iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. 3039 </returns> 3040 </method> 3041 <method name="cend" cv="const"> 3042 <type>const_iterator</type> 3043 <returns>A constant iterator which refers to the past-the-end value for the container. 3044 </returns> 3045 </method> 3046 </method-group> 3047 <method-group name="modifiers"> 3048 <method name="emplace"> 3049 <template> 3050 <template-type-parameter name="Args" pack="1"> 3051 </template-type-parameter> 3052 </template> 3053 <parameter name="args" pack="1"> 3054 <paramtype>Args&&</paramtype> 3055 </parameter> 3056 <type>iterator</type> 3057 <description> 3058 <para>Inserts an object, constructed with the arguments <code>args</code>, in the container.</para> 3059 </description> 3060 <returns> 3061 <para>An iterator pointing to the inserted element.</para> 3062 </returns> 3063 <throws> 3064 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 3065 </throws> 3066 <notes> 3067 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 3068 <para>Pointers and references to elements are never invalidated.</para> 3069 <para>If the compiler doesn't support variadic template arguments or rvalue 3070 references, this is emulated for up to 10 arguments, with no support 3071 for rvalue references or move semantics.</para> 3072 </notes> 3073 </method> 3074 <method name="emplace_hint"> 3075 <template> 3076 <template-type-parameter name="Args" pack="1"> 3077 </template-type-parameter> 3078 </template> 3079 <parameter name="hint"> 3080 <paramtype>const_iterator</paramtype> 3081 </parameter> 3082 <parameter name="args" pack="1"> 3083 <paramtype>Args&&</paramtype> 3084 </parameter> 3085 <type>iterator</type> 3086 <description> 3087 <para>Inserts an object, constructed with the arguments <code>args</code>, in the container.</para> 3088 <para>hint is a suggestion to where the element should be inserted.</para> 3089 </description> 3090 <returns> 3091 <para>An iterator pointing to the inserted element.</para> 3092 </returns> 3093 <throws> 3094 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 3095 </throws> 3096 <notes> 3097 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. </para> 3098 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 3099 <para>Pointers and references to elements are never invalidated.</para> 3100 <para>If the compiler doesn't support variadic template arguments or rvalue 3101 references, this is emulated for up to 10 arguments, with no support 3102 for rvalue references or move semantics.</para> 3103 </notes> 3104 </method> 3105 <method name="insert"> 3106 <parameter name="obj"> 3107 <paramtype>value_type const&</paramtype> 3108 </parameter> 3109 <type>iterator</type> 3110 <description> 3111 <para>Inserts obj in the container.</para> 3112 </description> 3113 <returns> 3114 <para>An iterator pointing to the inserted element.</para> 3115 </returns> 3116 <throws> 3117 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 3118 </throws> 3119 <notes> 3120 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 3121 <para>Pointers and references to elements are never invalidated.</para> 3122 </notes> 3123 </method> 3124 <method name="insert"> 3125 <parameter name="hint"> 3126 <paramtype>const_iterator</paramtype> 3127 </parameter> 3128 <parameter name="obj"> 3129 <paramtype>value_type const&</paramtype> 3130 </parameter> 3131 <type>iterator</type> 3132 <description> 3133 <para>Inserts obj in the container.</para> 3134 <para>hint is a suggestion to where the element should be inserted.</para> 3135 </description> 3136 <returns> 3137 <para>An iterator pointing to the inserted element.</para> 3138 </returns> 3139 <throws> 3140 <para>If an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 3141 </throws> 3142 <notes> 3143 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. </para> 3144 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 3145 <para>Pointers and references to elements are never invalidated.</para> 3146 </notes> 3147 </method> 3148 <method name="insert"> 3149 <template> 3150 <template-type-parameter name="InputIterator"> 3151 </template-type-parameter> 3152 </template> 3153 <parameter name="first"> 3154 <paramtype>InputIterator</paramtype> 3155 </parameter> 3156 <parameter name="last"> 3157 <paramtype>InputIterator</paramtype> 3158 </parameter> 3159 <type>void</type> 3160 <description> 3161 <para>Inserts a range of elements into the container.</para> 3162 </description> 3163 <throws> 3164 <para>When inserting a single element, if an exception is thrown by an operation other than a call to <code>hasher</code> the function has no effect.</para> 3165 </throws> 3166 <notes> 3167 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para> 3168 <para>Pointers and references to elements are never invalidated.</para> 3169 </notes> 3170 </method> 3171 <method name="erase"> 3172 <parameter name="position"> 3173 <paramtype>const_iterator</paramtype> 3174 </parameter> 3175 <type>iterator</type> 3176 <description> 3177 <para>Erase the element pointed to by <code>position</code>.</para> 3178 </description> 3179 <returns> 3180 <para>The iterator following <code>position</code> before the erasure.</para> 3181 </returns> 3182 <throws> 3183 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 3184 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 3185 </throws> 3186 <notes> 3187 <para> 3188 When the number of elements is a lot smaller than the number of buckets 3189 this function can be very inefficient as it has to search through empty 3190 buckets for the next element, in order to return the iterator. 3191 The method <methodname>quick_erase</methodname> is faster, but has yet 3192 to be standardized. 3193 </para> 3194 </notes> 3195 </method> 3196 <method name="erase"> 3197 <parameter name="k"> 3198 <paramtype>key_type const&</paramtype> 3199 </parameter> 3200 <type>size_type</type> 3201 <description> 3202 <para>Erase all elements with key equivalent to <code>k</code>.</para> 3203 </description> 3204 <returns> 3205 <para>The number of elements erased.</para> 3206 </returns> 3207 <throws> 3208 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 3209 </throws> 3210 </method> 3211 <method name="erase"> 3212 <parameter name="first"> 3213 <paramtype>const_iterator</paramtype> 3214 </parameter> 3215 <parameter name="last"> 3216 <paramtype>const_iterator</paramtype> 3217 </parameter> 3218 <type>iterator</type> 3219 <description> 3220 <para>Erases the elements in the range from <code>first</code> to <code>last</code>.</para> 3221 </description> 3222 <returns> 3223 <para>The iterator following the erased elements - i.e. <code>last</code>.</para> 3224 </returns> 3225 <throws> 3226 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 3227 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 3228 </throws> 3229 </method> 3230 <method name="quick_erase"> 3231 <parameter name="position"> 3232 <paramtype>const_iterator</paramtype> 3233 </parameter> 3234 <type>void</type> 3235 <description> 3236 <para>Erase the element pointed to by <code>position</code>.</para> 3237 </description> 3238 <throws> 3239 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 3240 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 3241 </throws> 3242 <notes> 3243 <para> 3244 This method is faster than <methodname>erase</methodname> as 3245 it doesn't have to find the next element in the container - 3246 a potentially costly operation. 3247 </para> 3248 <para> 3249 As it hasn't been standardized, it's likely that this may 3250 change in the future. 3251 </para> 3252 </notes> 3253 </method> 3254 <method name="erase_return_void"> 3255 <parameter name="position"> 3256 <paramtype>const_iterator</paramtype> 3257 </parameter> 3258 <type>void</type> 3259 <description> 3260 <para>Erase the element pointed to by <code>position</code>.</para> 3261 </description> 3262 <throws> 3263 <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para> 3264 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para> 3265 </throws> 3266 <notes> 3267 <para> 3268 This method is now deprecated, use 3269 <methodname>quick_return</methodname> instead. Although be 3270 warned that as that isn't standardized yet, it could also 3271 change. 3272 </para> 3273 </notes> 3274 </method> 3275 <method name="clear"> 3276 <type>void</type> 3277 <description> 3278 <para>Erases all elements in the container.</para> 3279 </description> 3280 <postconditions> 3281 <para><code><methodname>size</methodname>() == 0</code></para> 3282 </postconditions> 3283 <throws> 3284 <para>Never throws an exception.</para> 3285 </throws> 3286 </method> 3287 <method name="swap"> 3288 <parameter> 3289 <paramtype>unordered_multimap&</paramtype> 3290 </parameter> 3291 <type>void</type> 3292 <throws> 3293 <para>If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of <code>key_equal</code> or <code>hasher</code>.</para> 3294 </throws> 3295 <notes> 3296 <para>For a discussion of the behavior when allocators aren't equal see 3297 <link linkend="unordered.rationale.swapping_containers_with_unequal_allocators">the implementation details</link>.</para> 3298 </notes> 3299 </method> 3300 </method-group> 3301 <method-group name="observers"> 3302 <method name="hash_function" cv="const"> 3303 <type>hasher</type> 3304 <returns>The container's hash function. 3305 </returns> 3306 </method> 3307 <method name="key_eq" cv="const"> 3308 <type>key_equal</type> 3309 <returns>The container's key equality predicate. 3310 </returns> 3311 </method> 3312 </method-group> 3313 <method-group name="lookup"> 3314 <overloaded-method name="find"> 3315 <signature> 3316 <parameter name="k"> 3317 <paramtype>key_type const&</paramtype> 3318 </parameter> 3319 <type>iterator</type> 3320 </signature> 3321 <signature cv="const"> 3322 <parameter name="k"> 3323 <paramtype>key_type const&</paramtype> 3324 </parameter> 3325 <type>const_iterator</type> 3326 </signature> 3327 <signature> 3328 <template> 3329 <template-type-parameter name="CompatibleKey"/> 3330 <template-type-parameter name="CompatibleHash"/> 3331 <template-type-parameter name="CompatiblePredicate"/> 3332 </template> 3333 <parameter name="k"> 3334 <paramtype>CompatibleKey const&</paramtype> 3335 </parameter> 3336 <parameter name="hash"> 3337 <paramtype>CompatibleHash const&</paramtype> 3338 </parameter> 3339 <parameter name="eq"> 3340 <paramtype>CompatiblePredicate const&</paramtype> 3341 </parameter> 3342 <type>iterator</type> 3343 </signature> 3344 <signature cv="const"> 3345 <template> 3346 <template-type-parameter name="CompatibleKey"/> 3347 <template-type-parameter name="CompatibleHash"/> 3348 <template-type-parameter name="CompatiblePredicate"/> 3349 </template> 3350 <parameter name="k"> 3351 <paramtype>CompatibleKey const&</paramtype> 3352 </parameter> 3353 <parameter name="hash"> 3354 <paramtype>CompatibleHash const&</paramtype> 3355 </parameter> 3356 <parameter name="eq"> 3357 <paramtype>CompatiblePredicate const&</paramtype> 3358 </parameter> 3359 <type>const_iterator</type> 3360 </signature> 3361 <returns> 3362 <para>An iterator pointing to an element with key equivalent to <code>k</code>, or <code>b.end()</code> if no such element exists.</para> 3363 </returns> 3364 <notes><para> 3365 The templated overloads are a non-standard extensions which 3366 allows you to use a compatible hash function and equality 3367 predicate for a key of a different type in order to avoid 3368 an expensive type cast. In general, its use is not encouraged. 3369 </para></notes> 3370 </overloaded-method> 3371 <method name="count" cv="const"> 3372 <parameter name="k"> 3373 <paramtype>key_type const&</paramtype> 3374 </parameter> 3375 <type>size_type</type> 3376 <returns> 3377 <para>The number of elements with key equivalent to <code>k</code>.</para> 3378 </returns> 3379 </method> 3380 <overloaded-method name="equal_range"> 3381 <signature> 3382 <parameter name="k"> 3383 <paramtype>key_type const&</paramtype> 3384 </parameter> 3385 <type>std::pair<iterator, iterator></type> 3386 </signature> 3387 <signature cv="const"> 3388 <parameter name="k"> 3389 <paramtype>key_type const&</paramtype> 3390 </parameter> 3391 <type>std::pair<const_iterator, const_iterator></type> 3392 </signature> 3393 <returns> 3394 <para>A range containing all elements with key equivalent to <code>k</code>. 3395 If the container doesn't container any such elements, returns 3396 <code><functionname>std::make_pair</functionname>(<methodname>b.end</methodname>(),<methodname>b.end</methodname>())</code>. 3397 </para> 3398 </returns> 3399 </overloaded-method> 3400 </method-group> 3401 <method-group name="bucket interface"> 3402 <method name="bucket_count" cv="const"> 3403 <type>size_type</type> 3404 <returns> 3405 <para>The number of buckets.</para> 3406 </returns> 3407 </method> 3408 <method name="max_bucket_count" cv="const"> 3409 <type>size_type</type> 3410 <returns> 3411 <para>An upper bound on the number of buckets.</para> 3412 </returns> 3413 </method> 3414 <method name="bucket_size" cv="const"> 3415 <parameter name="n"> 3416 <paramtype>size_type</paramtype> 3417 </parameter> 3418 <type>size_type</type> 3419 <requires> 3420 <para><code>n < <methodname>bucket_count</methodname>()</code></para> 3421 </requires> 3422 <returns> 3423 <para>The number of elements in bucket <code>n</code>.</para> 3424 </returns> 3425 </method> 3426 <method name="bucket" cv="const"> 3427 <parameter name="k"> 3428 <paramtype>key_type const&</paramtype> 3429 </parameter> 3430 <type>size_type</type> 3431 <returns> 3432 <para>The index of the bucket which would contain an element with key <code>k</code>.</para> 3433 </returns> 3434 <postconditions> 3435 <para>The return value is less than <code>bucket_count()</code></para> 3436 </postconditions> 3437 </method> 3438 <overloaded-method name="begin"> 3439 <signature> 3440 <parameter name="n"> 3441 <paramtype>size_type</paramtype> 3442 </parameter> 3443 <type>local_iterator</type> 3444 </signature> 3445 <signature cv="const"> 3446 <parameter name="n"> 3447 <paramtype>size_type</paramtype> 3448 </parameter> 3449 <type>const_local_iterator</type> 3450 </signature> 3451 <requires> 3452 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 3453 </requires> 3454 <returns> 3455 <para>A local iterator pointing the first element in the bucket with index <code>n</code>.</para> 3456 </returns> 3457 </overloaded-method> 3458 <overloaded-method name="end"> 3459 <signature> 3460 <parameter name="n"> 3461 <paramtype>size_type</paramtype> 3462 </parameter> 3463 <type>local_iterator</type> 3464 </signature> 3465 <signature cv="const"> 3466 <parameter name="n"> 3467 <paramtype>size_type</paramtype> 3468 </parameter> 3469 <type>const_local_iterator</type> 3470 </signature> 3471 <requires> 3472 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 3473 </requires> 3474 <returns> 3475 <para>A local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para> 3476 </returns> 3477 </overloaded-method> 3478 <method name="cbegin" cv="const"> 3479 <parameter name="n"> 3480 <paramtype>size_type</paramtype> 3481 </parameter> 3482 <type>const_local_iterator</type> 3483 <requires> 3484 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 3485 </requires> 3486 <returns> 3487 <para>A constant local iterator pointing the first element in the bucket with index <code>n</code>.</para> 3488 </returns> 3489 </method> 3490 <method name="cend"> 3491 <parameter name="n"> 3492 <paramtype>size_type</paramtype> 3493 </parameter> 3494 <type>const_local_iterator</type> 3495 <requires> 3496 <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para> 3497 </requires> 3498 <returns> 3499 <para>A constant local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para> 3500 </returns> 3501 </method> 3502 </method-group> 3503 <method-group name="hash policy"> 3504 <method name="load_factor" cv="const"> 3505 <type>float</type> 3506 <returns> 3507 <para>The average number of elements per bucket.</para> 3508 </returns> 3509 </method> 3510 <method name="max_load_factor" cv="const"> 3511 <type>float</type> 3512 <returns> 3513 <para>Returns the current maximum load factor.</para> 3514 </returns> 3515 </method> 3516 <method name="max_load_factor"> 3517 <parameter name="z"> 3518 <paramtype>float</paramtype> 3519 </parameter> 3520 <type>void</type> 3521 <effects> 3522 <para>Changes the container's maximum load factor, using <code>z</code> as a hint.</para> 3523 </effects> 3524 </method> 3525 <method name="rehash"> 3526 <parameter name="n"> 3527 <paramtype>size_type</paramtype> 3528 </parameter> 3529 <type>void</type> 3530 <description> 3531 <para>Changes the number of buckets so that there at least <code>n</code> buckets, and so that the load factor is less than the maximum load factor.</para> 3532 <para>Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.</para> 3533 </description> 3534 <throws> 3535 <para>The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.</para> 3536 </throws> 3537 </method> 3538 </method-group> 3539 <free-function-group name="Equality Comparisons"> 3540 <function name="operator=="> 3541 <template> 3542 <template-type-parameter name="Key"> 3543 </template-type-parameter> 3544 <template-type-parameter name="Mapped"> 3545 </template-type-parameter> 3546 <template-type-parameter name="Hash"> 3547 </template-type-parameter> 3548 <template-type-parameter name="Pred"> 3549 </template-type-parameter> 3550 <template-type-parameter name="Alloc"> 3551 </template-type-parameter> 3552 </template> 3553 <parameter name="x"> 3554 <paramtype>unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&</paramtype> 3555 </parameter> 3556 <parameter name="y"> 3557 <paramtype>unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&</paramtype> 3558 </parameter> 3559 <type>bool</type> 3560 <notes> 3561 <para>This is a boost extension.</para> 3562 <para>Behavior is undefined if the two containers don't have 3563 equivalent equality predicates.</para> 3564 </notes> 3565 </function> 3566 <function name="operator!="> 3567 <template> 3568 <template-type-parameter name="Key"> 3569 </template-type-parameter> 3570 <template-type-parameter name="Mapped"> 3571 </template-type-parameter> 3572 <template-type-parameter name="Hash"> 3573 </template-type-parameter> 3574 <template-type-parameter name="Pred"> 3575 </template-type-parameter> 3576 <template-type-parameter name="Alloc"> 3577 </template-type-parameter> 3578 </template> 3579 <parameter name="x"> 3580 <paramtype>unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&</paramtype> 3581 </parameter> 3582 <parameter name="y"> 3583 <paramtype>unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&</paramtype> 3584 </parameter> 3585 <type>bool</type> 3586 <notes> 3587 <para>This is a boost extension.</para> 3588 <para>Behavior is undefined if the two containers don't have 3589 equivalent equality predicates.</para> 3590 </notes> 3591 </function> 3592 </free-function-group> 3593 <free-function-group name="swap"> 3594 <function name="swap"> 3595 <template> 3596 <template-type-parameter name="Key"> 3597 </template-type-parameter> 3598 <template-type-parameter name="Mapped"> 3599 </template-type-parameter> 3600 <template-type-parameter name="Hash"> 3601 </template-type-parameter> 3602 <template-type-parameter name="Pred"> 3603 </template-type-parameter> 3604 <template-type-parameter name="Alloc"> 3605 </template-type-parameter> 3606 </template> 3607 <parameter name="x"> 3608 <paramtype>unordered_multimap<Key, Mapped, Hash, Pred, Alloc>&</paramtype> 3609 </parameter> 3610 <parameter name="y"> 3611 <paramtype>unordered_multimap<Key, Mapped, Hash, Pred, Alloc>&</paramtype> 3612 </parameter> 3613 <type>void</type> 3614 <effects> 3615 <para><code>x.swap(y)</code></para> 3616 </effects> 3617 <throws> 3618 <para>If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of <code>Hash</code> or <code>Pred</code>.</para> 3619 </throws> 3620 <notes> 3621 <para>For a discussion of the behavior when allocators aren't equal see 3622 <link linkend="unordered.rationale.swapping_containers_with_unequal_allocators">the implementation details</link>.</para> 3623 </notes> 3624 </function> 3625 </free-function-group> 3626 </class> 3627 </namespace> 3628 </header> 3629 </library-reference> 3630