1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Class template unordered_set</title>
<link rel="stylesheet" href="../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../unordered/reference.html#header.boost.unordered_set_hpp" title="Header <boost/unordered_set.hpp>">
<link rel="prev" href="../unordered/reference.html" title="Reference">
<link rel="next" href="unordered_multiset.html" title="Class template unordered_multiset">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
<td align="center"><a href="../../../index.html">Home</a></td>
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../unordered/reference.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../unordered/reference.html#header.boost.unordered_set_hpp"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="unordered_multiset.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
</div>
<div class="refentry" title="Class template unordered_set">
<a name="boost.unordered_set"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template unordered_set</span></h2>
<p>boost::unordered_set —
An unordered associative container that stores unique values.
</p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="emphasis"><em>// In header: <<a class="link" href="../unordered/reference.html#header.boost.unordered_set_hpp" title="Header <boost/unordered_set.hpp>">boost/unordered_set.hpp</a>>
</em></span><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Value, <span class="bold"><strong>typename</strong></span> Hash = <span class="type">boost::hash<Value></span>,
<span class="bold"><strong>typename</strong></span> Pred = <span class="type">std::equal_to<Value></span>,
<span class="bold"><strong>typename</strong></span> Alloc = <span class="type">std::allocator<Value></span> >
<span class="bold"><strong>class</strong></span> <a class="link" href="unordered_set.html" title="Class template unordered_set">unordered_set</a> {
<span class="bold"><strong>public</strong></span>:
<span class="emphasis"><em>// <a class="link" href="unordered_set.html#boost.unordered_settypes">types</a></em></span>
<span class="bold"><strong>typedef</strong></span> Value <a name="boost.unordered_set.key_type"></a>key_type;
<span class="bold"><strong>typedef</strong></span> Value <a name="boost.unordered_set.value_type"></a>value_type;
<span class="bold"><strong>typedef</strong></span> Hash <a name="boost.unordered_set.hasher"></a>hasher;
<span class="bold"><strong>typedef</strong></span> Pred <a name="boost.unordered_set.key_equal"></a>key_equal;
<span class="bold"><strong>typedef</strong></span> Alloc <a name="boost.unordered_set.allocator_type"></a>allocator_type;
<span class="bold"><strong>typedef</strong></span> <span class="bold"><strong>typename</strong></span> allocator_type::pointer <a name="boost.unordered_set.pointer"></a>pointer;
<span class="bold"><strong>typedef</strong></span> <span class="bold"><strong>typename</strong></span> allocator_type::const_pointer <a name="boost.unordered_set.const_pointer"></a>const_pointer;
<span class="bold"><strong>typedef</strong></span> <span class="bold"><strong>typename</strong></span> allocator_type::reference <a name="boost.unordered_set.reference"></a>reference; <span class="emphasis"><em>// lvalue of <span class="type">value_type</span>.</em></span>
<span class="bold"><strong>typedef</strong></span> <span class="bold"><strong>typename</strong></span> allocator_type::const_reference <a name="boost.unordered_set.const_reference"></a>const_reference; <span class="emphasis"><em>// const lvalue of <span class="type">value_type</span>.</em></span>
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a class="link" href="unordered_set.html#boost.unordered_set.size_type">size_type</a>;
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a class="link" href="unordered_set.html#boost.unordered_set.difference_type">difference_type</a>;
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a class="link" href="unordered_set.html#boost.unordered_set.iterator">iterator</a>;
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a class="link" href="unordered_set.html#boost.unordered_set.const_iterator">const_iterator</a>;
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a class="link" href="unordered_set.html#boost.unordered_set.local_iterator">local_iterator</a>;
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a class="link" href="unordered_set.html#boost.unordered_set.const_local_iterator">const_local_iterator</a>;
<span class="emphasis"><em>// <a class="link" href="unordered_set.html#boost.unordered_setconstruct-copy-destruct">construct/copy/destruct</a></em></span>
<span class="bold"><strong>explicit</strong></span> <a class="link" href="unordered_set.html#id1339873-bb">unordered_set</a>(size_type = <span class="emphasis"><em>implementation-defined</em></span>,
hasher <span class="bold"><strong>const</strong></span>& = hasher(),
key_equal <span class="bold"><strong>const</strong></span>& = key_equal(),
allocator_type <span class="bold"><strong>const</strong></span>& = allocator_type());
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> <a class="link" href="../InputIterator.html" title="Concept InputIterator">InputIterator</a>>
<a class="link" href="unordered_set.html#id1339954-bb">unordered_set</a>(InputIterator, InputIterator,
size_type = implementation-defined,
hasher <span class="bold"><strong>const</strong></span>& = hasher(), key_equal <span class="bold"><strong>const</strong></span>& = key_equal(),
allocator_type <span class="bold"><strong>const</strong></span>& = allocator_type());
<a class="link" href="unordered_set.html#id1340053-bb">unordered_set</a>(unordered_set <span class="bold"><strong>const</strong></span>&);
<a class="link" href="unordered_set.html#id1340084-bb">unordered_set</a>(unordered_set &&);
<span class="bold"><strong>explicit</strong></span> <a class="link" href="unordered_set.html#id1340125-bb">unordered_set</a>(Allocator <span class="bold"><strong>const</strong></span>&);
<a class="link" href="unordered_set.html#id1340153-bb">unordered_set</a>(unordered_set <span class="bold"><strong>const</strong></span>&, Allocator <span class="bold"><strong>const</strong></span>&);
<a class="link" href="unordered_set.html#id1340193-bb">~unordered_set</a>();
<span class="type">unordered_set&</span> <a class="link" href="unordered_set.html#id1340205-bb"><span class="bold"><strong>operator</strong></span>=</a>(unordered_set <span class="bold"><strong>const</strong></span>&);
<span class="type">unordered_set&</span> <a class="link" href="unordered_set.html#id1340257-bb"><span class="bold"><strong>operator</strong></span>=</a>(unordered_set &&);
<span class="type">allocator_type</span> <a class="link" href="unordered_set.html#id1340310-bb">get_allocator</a>() <span class="bold"><strong>const</strong></span>;
<span class="emphasis"><em>// <a class="link" href="unordered_set.html#id1340322-bb">size and capacity</a></em></span>
<span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="unordered_set.html#id1340326-bb">empty</a>() <span class="bold"><strong>const</strong></span>;
<span class="type">size_type</span> <a class="link" href="unordered_set.html#id1340348-bb">size</a>() <span class="bold"><strong>const</strong></span>;
<span class="type">size_type</span> <a class="link" href="unordered_set.html#id1340375-bb">max_size</a>() <span class="bold"><strong>const</strong></span>;
<span class="emphasis"><em>// <a class="link" href="unordered_set.html#id1340398-bb">iterators</a></em></span>
<span class="type">iterator</span> <a class="link" href="unordered_set.html#id1340407-bb">begin</a>();
<span class="type">const_iterator</span> <a class="link" href="unordered_set.html#id1340412-bb">begin</a>() <span class="bold"><strong>const</strong></span>;
<span class="type">iterator</span> <a class="link" href="unordered_set.html#id1340430-bb">end</a>();
<span class="type">const_iterator</span> <a class="link" href="unordered_set.html#id1340438-bb">end</a>() <span class="bold"><strong>const</strong></span>;
<span class="type">const_iterator</span> <a class="link" href="unordered_set.html#id1340454-bb">cbegin</a>() <span class="bold"><strong>const</strong></span>;
<span class="type">const_iterator</span> <a class="link" href="unordered_set.html#id1340472-bb">cend</a>() <span class="bold"><strong>const</strong></span>;
<span class="emphasis"><em>// <a class="link" href="unordered_set.html#id1340490-bb">modifiers</a></em></span>
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span>... Args> <span class="type">std::pair<iterator, <span class="bold"><strong>bool</strong></span>></span> <a class="link" href="unordered_set.html#id1340495-bb">emplace</a>(Args&&...);
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span>... Args> <span class="type">iterator</span> <a class="link" href="unordered_set.html#id1340592-bb">emplace_hint</a>(const_iterator, Args&&...);
<span class="type">std::pair<iterator, <span class="bold"><strong>bool</strong></span>></span> <a class="link" href="unordered_set.html#id1340706-bb">insert</a>(value_type <span class="bold"><strong>const</strong></span>&);
<span class="type">iterator</span> <a class="link" href="unordered_set.html#id1340777-bb">insert</a>(const_iterator, value_type <span class="bold"><strong>const</strong></span>&);
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> <a class="link" href="../InputIterator.html" title="Concept InputIterator">InputIterator</a>> <span class="type"><span class="bold"><strong>void</strong></span></span> <a class="link" href="unordered_set.html#id1340865-bb">insert</a>(InputIterator, InputIterator);
<span class="type">iterator</span> <a class="link" href="unordered_set.html#id1340942-bb">erase</a>(const_iterator);
<span class="type">size_type</span> <a class="link" href="unordered_set.html#id1341026-bb">erase</a>(key_type <span class="bold"><strong>const</strong></span>&);
<span class="type">iterator</span> <a class="link" href="unordered_set.html#id1341081-bb">erase</a>(const_iterator, const_iterator);
<span class="type"><span class="bold"><strong>void</strong></span></span> <a class="link" href="unordered_set.html#id1341161-bb">erase_return_void</a>(const_iterator);
<span class="type"><span class="bold"><strong>void</strong></span></span> <a class="link" href="unordered_set.html#id1341234-bb">clear</a>();
<span class="type"><span class="bold"><strong>void</strong></span></span> <a class="link" href="unordered_set.html#id1341271-bb">swap</a>(unordered_set&);
<span class="emphasis"><em>// <a class="link" href="unordered_set.html#id1341323-bb">observers</a></em></span>
<span class="type">hasher</span> <a class="link" href="unordered_set.html#id1341327-bb">hash_function</a>() <span class="bold"><strong>const</strong></span>;
<span class="type">key_equal</span> <a class="link" href="unordered_set.html#id1341343-bb">key_eq</a>() <span class="bold"><strong>const</strong></span>;
<span class="emphasis"><em>// <a class="link" href="unordered_set.html#id1341361-bb">lookup</a></em></span>
<span class="type">iterator</span> <a class="link" href="unordered_set.html#id1341370-bb">find</a>(key_type <span class="bold"><strong>const</strong></span>&);
<span class="type">const_iterator</span> <a class="link" href="unordered_set.html#id1341388-bb">find</a>(key_type <span class="bold"><strong>const</strong></span>&) <span class="bold"><strong>const</strong></span>;
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> CompatibleKey, <span class="bold"><strong>typename</strong></span> CompatibleHash,
<span class="bold"><strong>typename</strong></span> CompatiblePredicate>
<span class="type">iterator</span> <a class="link" href="unordered_set.html#id1341408-bb">find</a>(CompatibleKey <span class="bold"><strong>const</strong></span>&, CompatibleHash <span class="bold"><strong>const</strong></span>&,
CompatiblePredicate <span class="bold"><strong>const</strong></span>&);
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> CompatibleKey, <span class="bold"><strong>typename</strong></span> CompatibleHash,
<span class="bold"><strong>typename</strong></span> CompatiblePredicate>
<span class="type">const_iterator</span>
<a class="link" href="unordered_set.html#id1341467-bb">find</a>(CompatibleKey <span class="bold"><strong>const</strong></span>&, CompatibleHash <span class="bold"><strong>const</strong></span>&,
CompatiblePredicate <span class="bold"><strong>const</strong></span>&) <span class="bold"><strong>const</strong></span>;
<span class="type">size_type</span> <a class="link" href="unordered_set.html#id1341555-bb">count</a>(key_type <span class="bold"><strong>const</strong></span>&) <span class="bold"><strong>const</strong></span>;
<span class="type">std::pair<iterator, iterator></span> <a class="link" href="unordered_set.html#id1341593-bb">equal_range</a>(key_type <span class="bold"><strong>const</strong></span>&);
<span class="type">std::pair<const_iterator, const_iterator></span> <a class="link" href="unordered_set.html#id1341612-bb">equal_range</a>(key_type <span class="bold"><strong>const</strong></span>&) <span class="bold"><strong>const</strong></span>;
<span class="emphasis"><em>// <a class="link" href="unordered_set.html#id1341663-bb">bucket interface</a></em></span>
<span class="type">size_type</span> <a class="link" href="unordered_set.html#id1341668-bb">bucket_count</a>() <span class="bold"><strong>const</strong></span>;
<span class="type">size_type</span> <a class="link" href="unordered_set.html#id1341688-bb">max_bucket_count</a>() <span class="bold"><strong>const</strong></span>;
<span class="type">size_type</span> <a class="link" href="unordered_set.html#id1341708-bb">bucket_size</a>(size_type) <span class="bold"><strong>const</strong></span>;
<span class="type">size_type</span> <a class="link" href="unordered_set.html#id1341754-bb">bucket</a>(key_type <span class="bold"><strong>const</strong></span>&) <span class="bold"><strong>const</strong></span>;
<span class="type">local_iterator</span> <a class="link" href="unordered_set.html#id1341803-bb">begin</a>(size_type);
<span class="type">const_local_iterator</span> <a class="link" href="unordered_set.html#id1341821-bb">begin</a>(size_type) <span class="bold"><strong>const</strong></span>;
<span class="type">local_iterator</span> <a class="link" href="unordered_set.html#id1341874-bb">end</a>(size_type);
<span class="type">const_local_iterator</span> <a class="link" href="unordered_set.html#id1341893-bb">end</a>(size_type) <span class="bold"><strong>const</strong></span>;
<span class="type">const_local_iterator</span> <a class="link" href="unordered_set.html#id1341942-bb">cbegin</a>(size_type) <span class="bold"><strong>const</strong></span>;
<span class="type">const_local_iterator</span> <a class="link" href="unordered_set.html#id1341990-bb">cend</a>(size_type);
<span class="emphasis"><em>// <a class="link" href="unordered_set.html#id1342039-bb">hash policy</a></em></span>
<span class="type"><span class="bold"><strong>float</strong></span></span> <a class="link" href="unordered_set.html#id1342043-bb">load_factor</a>() <span class="bold"><strong>const</strong></span>;
<span class="type"><span class="bold"><strong>float</strong></span></span> <a class="link" href="unordered_set.html#id1309346-bb">max_load_factor</a>() <span class="bold"><strong>const</strong></span>;
<span class="type"><span class="bold"><strong>void</strong></span></span> <a class="link" href="unordered_set.html#id1309366-bb">max_load_factor</a>(<span class="bold"><strong>float</strong></span>);
<span class="type"><span class="bold"><strong>void</strong></span></span> <a class="link" href="unordered_set.html#id1309398-bb">rehash</a>(size_type);
};
<span class="emphasis"><em>// <a class="link" href="unordered_set.html#id1309448-bb">Equality Comparisons</a></em></span>
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Value, <span class="bold"><strong>typename</strong></span> Hash, <span class="bold"><strong>typename</strong></span> Pred, <span class="bold"><strong>typename</strong></span> Alloc>
<span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="unordered_set.html#boost.operator==_id1309452"><span class="bold"><strong>operator</strong></span>==</a>(unordered_set<Value, Hash, Pred, Alloc> <span class="bold"><strong>const</strong></span>&,
unordered_set<Value, Hash, Pred, Alloc> <span class="bold"><strong>const</strong></span>&);
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Value, <span class="bold"><strong>typename</strong></span> Hash, <span class="bold"><strong>typename</strong></span> Pred, <span class="bold"><strong>typename</strong></span> Alloc>
<span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="unordered_set.html#boost.operator!=_id1309526"><span class="bold"><strong>operator</strong></span>!=</a>(unordered_set<Value, Hash, Pred, Alloc> <span class="bold"><strong>const</strong></span>&,
unordered_set<Value, Hash, Pred, Alloc> <span class="bold"><strong>const</strong></span>&);
<span class="emphasis"><em>// <a class="link" href="unordered_set.html#id1309600-bb">swap</a></em></span>
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Value, <span class="bold"><strong>typename</strong></span> Hash, <span class="bold"><strong>typename</strong></span> Pred, <span class="bold"><strong>typename</strong></span> Alloc>
<span class="type"><span class="bold"><strong>void</strong></span></span> <a class="link" href="unordered_set.html#boost.swap_id1309605">swap</a>(unordered_set<Value, Hash, Pred, Alloc>&,
unordered_set<Value, Hash, Pred, Alloc>&);</pre></div>
<div class="refsect1" title="Description">
<a name="id2019087"></a><h2>Description</h2>
<p>Based on chapter 23 of
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2960.pdf" target="_top">the working draft of the C++ standard [n2960]</a>.
But without the updated rules for allocators.
</p>
<p><span class="bold"><strong>Template Parameters</strong></span>
</p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<tbody>
<tr>
<td><span class="emphasis"><em>Value</em></span></td>
<td>Value must be Assignable and CopyConstructible</td>
</tr>
<tr>
<td><span class="emphasis"><em>Hash</em></span></td>
<td>A unary function object type that acts a hash function for a <code class="computeroutput">Value</code>. It takes a single argument of type <code class="computeroutput">Value</code> and returns a value of type std::size_t.</td>
</tr>
<tr>
<td><span class="emphasis"><em>Pred</em></span></td>
<td>A binary function object that implements an equivalence relation on values of type <code class="computeroutput">Value</code>.
A binary function object that induces an equivalence relation on values of type Key.
It takes two arguments of type Key and returns a value of type bool.</td>
</tr>
<tr>
<td><span class="emphasis"><em>Alloc</em></span></td>
<td>An allocator whose value type is the same as the container's value type.</td>
</tr>
</tbody>
</table></div>
<p>The elements are organized into buckets. Keys with the same hash code are stored in the same bucket.</p>
<p>The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash.</p>
<div class="refsect2" title="unordered_set public types">
<a name="id2019194"></a><h3>
<a name="boost.unordered_settypes"></a><code class="computeroutput">unordered_set</code>
public
types</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<p>
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a name="boost.unordered_set.size_type"></a>size_type;</p>
<p>An unsigned integral type.</p>
<p><span class="type">size_type</span> can represent any non-negative value of <span class="type">difference_type</span>.</p>
</li>
<li class="listitem">
<p>
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a name="boost.unordered_set.difference_type"></a>difference_type;</p>
<p>A signed integral type.</p>
<p>Is identical to the difference type of <span class="type">iterator</span> and <span class="type">const_iterator</span>.</p>
</li>
<li class="listitem">
<p>
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a name="boost.unordered_set.iterator"></a>iterator;</p>
<p>A constant iterator whose value type is <span class="type">value_type</span>. </p>
<p>The iterator category is at least a forward iterator.</p>
<p>Convertible to <span class="type">const_iterator</span>.</p>
</li>
<li class="listitem">
<p>
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a name="boost.unordered_set.const_iterator"></a>const_iterator;</p>
<p>A constant iterator whose value type is <span class="type">value_type</span>. </p>
<p>The iterator category is at least a forward iterator.</p>
</li>
<li class="listitem">
<p>
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a name="boost.unordered_set.local_iterator"></a>local_iterator;</p>
<p>An iterator with the same value type, difference type and pointer and reference type as <span class="type">iterator</span>.</p>
<p>A local_iterator object can be used to iterate through a single bucket.</p>
</li>
<li class="listitem">
<p>
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>implementation-defined</em></span> <a name="boost.unordered_set.const_local_iterator"></a>const_local_iterator;</p>
<p>A constant iterator with the same value type, difference type and pointer and reference type as <span class="type">const_iterator</span>.</p>
<p>A const_local_iterator object can be used to iterate through a single bucket.</p>
</li>
</ol></div>
</div>
<div class="refsect2" title="unordered_set public construct/copy/destruct">
<a name="id2019419"></a><h3>
<a name="boost.unordered_setconstruct-copy-destruct"></a><code class="computeroutput">unordered_set</code>
public
construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="bold"><strong>explicit</strong></span> <a name="id1339873-bb"></a>unordered_set(size_type n = <span class="emphasis"><em>implementation-defined</em></span>,
hasher <span class="bold"><strong>const</strong></span>& hf = hasher(),
key_equal <span class="bold"><strong>const</strong></span>& eq = key_equal(),
allocator_type <span class="bold"><strong>const</strong></span>& a = allocator_type());</pre>
<p>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.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><code class="computeroutput"><a class="link" href="unordered_set.html#id1340348-bb">size</a>() == 0</code></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> <a class="link" href="../InputIterator.html" title="Concept InputIterator">InputIterator</a>>
<a name="id1339954-bb"></a>unordered_set(InputIterator f, InputIterator l,
size_type n = implementation-defined,
hasher <span class="bold"><strong>const</strong></span>& hf = hasher(),
key_equal <span class="bold"><strong>const</strong></span>& eq = key_equal(),
allocator_type <span class="bold"><strong>const</strong></span>& a = allocator_type());</pre>
<p>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.</p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id1340053-bb"></a>unordered_set(unordered_set <span class="bold"><strong>const</strong></span>&);</pre>
<p>The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p><code class="computeroutput">value_type</code> is copy constructible</p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id1340084-bb"></a>unordered_set(unordered_set &&);</pre>
<p>The move constructor.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td><p>This is emulated on compilers without rvalue references.</p></td>
</tr>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p>
<code class="computeroutput">value_type</code> is move constructible.
(TODO: This is not actually required in this implementation).
</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="bold"><strong>explicit</strong></span> <a name="id1340125-bb"></a>unordered_set(Allocator <span class="bold"><strong>const</strong></span>& a);</pre>
<p>Constructs an empty container, using allocator <code class="computeroutput">a</code>.</p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id1340153-bb"></a>unordered_set(unordered_set <span class="bold"><strong>const</strong></span>& x, Allocator <span class="bold"><strong>const</strong></span>& a);</pre>
<p>Constructs an container, copying <code class="computeroutput">x</code>'s contained elements, hash function, predicate, maximum load factor, but using allocator <code class="computeroutput">a</code>.</p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id1340193-bb"></a>~unordered_set();</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Notes:</span></p></td>
<td><p>The destructor is applied to every element, and all memory is deallocated</p></td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
<pre class="literallayout"><span class="type">unordered_set&</span> <a name="id1340205-bb"></a><span class="bold"><strong>operator</strong></span>=(unordered_set <span class="bold"><strong>const</strong></span>&);</pre>
<p>The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td><p>
On compilers without rvalue references, there is a single assignment
operator with the signature <code class="computeroutput">operator=(unordered_set)</code>
in order to emulate move semantics.
</p></td>
</tr>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p><code class="computeroutput">value_type</code> is copy constructible</p></td>
</tr>
</tbody>
</table></div>
<pre class="literallayout"><span class="type">unordered_set&</span> <a name="id1340257-bb"></a><span class="bold"><strong>operator</strong></span>=(unordered_set &&);</pre>
<p>The move assignment operator.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td><p>
On compilers without rvalue references, there is a single assignment
operator with the signature <code class="computeroutput">operator=(unordered_set)</code>
in order to emulate move semantics.
</p></td>
</tr>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p>
<code class="computeroutput">value_type</code> is move constructible.
(TODO: This is not actually required in this implementation).
</p></td>
</tr>
</tbody>
</table></div>
<pre class="literallayout"><span class="type">allocator_type</span> <a name="id1340310-bb"></a>get_allocator() <span class="bold"><strong>const</strong></span>;</pre>
<div class="refsect2" title="unordered_set size and capacity">
<a name="id2019897"></a><h3>
<a name="id1340322-bb"></a><code class="computeroutput">unordered_set</code> size and capacity</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id1340326-bb"></a>empty() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><code class="computeroutput"><a class="link" href="unordered_set.html#id1340348-bb">size</a>() == 0</code></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">size_type</span> <a name="id1340348-bb"></a>size() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><code class="computeroutput">std::distance(<a class="link" href="unordered_set.html#id1340402-bb">begin</a>(), <a class="link" href="unordered_set.html#id1340426-bb">end</a>())</code></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">size_type</span> <a name="id1340375-bb"></a>max_size() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td>
<code class="computeroutput"><a class="link" href="unordered_set.html#id1340348-bb">size</a>()</code> of the largest possible container.
</td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2" title="unordered_set iterators">
<a name="id2020057"></a><h3>
<a name="id1340398-bb"></a><code class="computeroutput">unordered_set</code> iterators</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="id1340402-bb"></a><span class="type">iterator</span> <a name="id1340407-bb"></a>begin();
<span class="type">const_iterator</span> <a name="id1340412-bb"></a>begin() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td>An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container.
</td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id1340426-bb"></a><span class="type">iterator</span> <a name="id1340430-bb"></a>end();
<span class="type">const_iterator</span> <a name="id1340438-bb"></a>end() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td>An iterator which refers to the past-the-end value for the container.
</td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">const_iterator</span> <a name="id1340454-bb"></a>cbegin() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td>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.
</td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">const_iterator</span> <a name="id1340472-bb"></a>cend() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td>A constant iterator which refers to the past-the-end value for the container.
</td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2" title="unordered_set modifiers">
<a name="id2020243"></a><h3>
<a name="id1340490-bb"></a><code class="computeroutput">unordered_set</code> modifiers</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span>... Args> <span class="type">std::pair<iterator, <span class="bold"><strong>bool</strong></span>></span> <a name="id1340495-bb"></a>emplace(Args&&... args);</pre>
<p>Inserts an object, constructed with the arguments <code class="computeroutput">args</code>, in the container if and only if there is no element in the container with an equivalent value.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td>
<p>The bool component of the return type is true if an insert took place.</p>
<p>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.</p>
</td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>If an exception is thrown by an operation other than a call to <code class="computeroutput">hasher</code> the function has no effect.</p></td>
</tr>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td>
<p>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</p>
<p>Pointers and references to elements are never invalidated.</p>
<p>If the compiler doesn't support variadic template arguments or rvalue
references, this is emulated for up to 10 arguments, with no support
for rvalue references or move semantics.</p>
</td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span>... Args>
<span class="type">iterator</span> <a name="id1340592-bb"></a>emplace_hint(const_iterator hint, Args&&... args);</pre>
<p>Inserts an object, constructed with the arguments <code class="computeroutput">args</code>, in the container if and only if there is no element in the container with an equivalent value.</p>
<p>hint is a suggestion to where the element should be inserted.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.</p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>If an exception is thrown by an operation other than a call to <code class="computeroutput">hasher</code> the function has no effect.</p></td>
</tr>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td>
<p>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. </p>
<p>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</p>
<p>Pointers and references to elements are never invalidated.</p>
<p>If the compiler doesn't support variadic template arguments or rvalue
references, this is emulated for up to 10 arguments, with no support
for rvalue references or move semantics.</p>
</td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">std::pair<iterator, <span class="bold"><strong>bool</strong></span>></span> <a name="id1340706-bb"></a>insert(value_type <span class="bold"><strong>const</strong></span>& obj);</pre>
<p>Inserts obj in the container if and only if there is no element in the container with an equivalent value.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td>
<p>The bool component of the return type is true if an insert took place.</p>
<p>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.</p>
</td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>If an exception is thrown by an operation other than a call to <code class="computeroutput">hasher</code> the function has no effect.</p></td>
</tr>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td>
<p>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</p>
<p>Pointers and references to elements are never invalidated.</p>
</td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">iterator</span> <a name="id1340777-bb"></a>insert(const_iterator hint, value_type <span class="bold"><strong>const</strong></span>& obj);</pre>
<p>Inserts obj in the container if and only if there is no element in the container with an equivalent value.</p>
<p>hint is a suggestion to where the element should be inserted.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value.</p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>If an exception is thrown by an operation other than a call to <code class="computeroutput">hasher</code> the function has no effect.</p></td>
</tr>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td>
<p>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. </p>
<p>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</p>
<p>Pointers and references to elements are never invalidated.</p>
</td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> <a class="link" href="../InputIterator.html" title="Concept InputIterator">InputIterator</a>>
<span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id1340865-bb"></a>insert(InputIterator first, InputIterator last);</pre>
<p>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.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>When inserting a single element, if an exception is thrown by an operation other than a call to <code class="computeroutput">hasher</code> the function has no effect.</p></td>
</tr>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td>
<p>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</p>
<p>Pointers and references to elements are never invalidated.</p>
</td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">iterator</span> <a name="id1340942-bb"></a>erase(const_iterator position);</pre>
<p>Erase the element pointed to by <code class="computeroutput">position</code>.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The iterator following <code class="computeroutput">position</code> before the erasure.</p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td>
<p>Only throws an exception if it is thrown by <code class="computeroutput">hasher</code> or <code class="computeroutput">key_equal</code>.</p>
<p>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.</p>
</td>
</tr>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td><p>
When the number of elements is a lot smaller than the number of buckets
this function can be very inefficient as it has to search through empty
buckets for the next element, in order to return the iterator.
As a temporary workaround, the container has the method
<a class="link" href="unordered_set.html#id1341161-bb">erase_return_void</a> which will be faster.
</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">size_type</span> <a name="id1341026-bb"></a>erase(key_type <span class="bold"><strong>const</strong></span>& k);</pre>
<p>Erase all elements with key equivalent to <code class="computeroutput">k</code>.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The number of elements erased.</p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>Only throws an exception if it is thrown by <code class="computeroutput">hasher</code> or <code class="computeroutput">key_equal</code>.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">iterator</span> <a name="id1341081-bb"></a>erase(const_iterator first, const_iterator last);</pre>
<p>Erases the elements in the range from <code class="computeroutput">first</code> to <code class="computeroutput">last</code>.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The iterator following the erased elements - i.e. <code class="computeroutput">last</code>.</p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td>
<p>Only throws an exception if it is thrown by <code class="computeroutput">hasher</code> or <code class="computeroutput">key_equal</code>.</p>
<p>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.</p>
</td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id1341161-bb"></a>erase_return_void(const_iterator position);</pre>
<p>Erase the element pointed to by <code class="computeroutput">position</code>.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td>
<p>Only throws an exception if it is thrown by <code class="computeroutput">hasher</code> or <code class="computeroutput">key_equal</code>.</p>
<p>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.</p>
</td>
</tr>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td><p>
This is a temporary workaround for the inefficient
<a class="link" href="unordered_set.html#id1340942-bb">erase</a> method. Hopefully, in a future
version the signature of <a class="link" href="unordered_set.html#id1340942-bb">erase</a> will
be changed and this will be deprecated.
</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id1341234-bb"></a>clear();</pre>
<p>Erases all elements in the container.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><a class="link" href="unordered_set.html#id1340348-bb">size</a>() == 0</code></p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>Never throws an exception.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id1341271-bb"></a>swap(unordered_set&);</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of <code class="computeroutput">key_equal</code> or <code class="computeroutput">hasher</code>.</p></td>
</tr>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td><p>For a discussion of the behavior when allocators aren't equal see
<a class="link" href="../unordered/rationale.html#unordered.rationale.swapping_containers_with_unequal_allocators">the implementation details</a>.</p></td>
</tr>
</tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2" title="unordered_set observers">
<a name="id2021097"></a><h3>
<a name="id1341323-bb"></a><code class="computeroutput">unordered_set</code> observers</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="type">hasher</span> <a name="id1341327-bb"></a>hash_function() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td>The container's hash function.
</td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">key_equal</span> <a name="id1341343-bb"></a>key_eq() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td>The container's key equality predicate.
</td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2" title="unordered_set lookup">
<a name="id2021183"></a><h3>
<a name="id1341361-bb"></a><code class="computeroutput">unordered_set</code> lookup</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="id1341365-bb"></a><span class="type">iterator</span> <a name="id1341370-bb"></a>find(key_type <span class="bold"><strong>const</strong></span>& k);
<span class="type">const_iterator</span> <a name="id1341388-bb"></a>find(key_type <span class="bold"><strong>const</strong></span>& k) <span class="bold"><strong>const</strong></span>;
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> CompatibleKey, <span class="bold"><strong>typename</strong></span> CompatibleHash,
<span class="bold"><strong>typename</strong></span> CompatiblePredicate>
<span class="type">iterator</span> <a name="id1341408-bb"></a>find(CompatibleKey <span class="bold"><strong>const</strong></span>& k, CompatibleHash <span class="bold"><strong>const</strong></span>& hash,
CompatiblePredicate <span class="bold"><strong>const</strong></span>& eq);
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> CompatibleKey, <span class="bold"><strong>typename</strong></span> CompatibleHash,
<span class="bold"><strong>typename</strong></span> CompatiblePredicate>
<span class="type">const_iterator</span>
<a name="id1341467-bb"></a>find(CompatibleKey <span class="bold"><strong>const</strong></span>& k, CompatibleHash <span class="bold"><strong>const</strong></span>& hash,
CompatiblePredicate <span class="bold"><strong>const</strong></span>& eq) <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>An iterator pointing to an element with key equivalent to <code class="computeroutput">k</code>, or <code class="computeroutput">b.end()</code> if no such element exists.</p></td>
</tr>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td><p>
The templated overloads are a non-standard extensions which
allows you to use a compatible hash function and equality
predicate for a key of a different type in order to avoid
an expensive type cast. In general, its use is not encouraged.
</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">size_type</span> <a name="id1341555-bb"></a>count(key_type <span class="bold"><strong>const</strong></span>& k) <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The number of elements with key equivalent to <code class="computeroutput">k</code>.</p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id1341589-bb"></a><span class="type">std::pair<iterator, iterator></span> <a name="id1341593-bb"></a>equal_range(key_type <span class="bold"><strong>const</strong></span>& k);
<span class="type">std::pair<const_iterator, const_iterator></span> <a name="id1341612-bb"></a>equal_range(key_type <span class="bold"><strong>const</strong></span>& k) <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>A range containing all elements with key equivalent to <code class="computeroutput">k</code>.
If the container doesn't container any such elements, returns
<code class="computeroutput">std::make_pair(b.end(),b.end())</code>.
</p></td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2" title="unordered_set bucket interface">
<a name="id2021519"></a><h3>
<a name="id1341663-bb"></a><code class="computeroutput">unordered_set</code> bucket interface</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="type">size_type</span> <a name="id1341668-bb"></a>bucket_count() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The number of buckets.</p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">size_type</span> <a name="id1341688-bb"></a>max_bucket_count() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>An upper bound on the number of buckets.</p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">size_type</span> <a name="id1341708-bb"></a>bucket_size(size_type n) <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p><code class="computeroutput">n < <a class="link" href="unordered_set.html#id1341668-bb">bucket_count</a>()</code></p></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The number of elements in bucket <code class="computeroutput">n</code>.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">size_type</span> <a name="id1341754-bb"></a>bucket(key_type <span class="bold"><strong>const</strong></span>& k) <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The index of the bucket which would contain an element with key <code class="computeroutput">k</code>.</p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p>The return value is less than <code class="computeroutput">bucket_count()</code></p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id1341798-bb"></a><span class="type">local_iterator</span> <a name="id1341803-bb"></a>begin(size_type n);
<span class="type">const_local_iterator</span> <a name="id1341821-bb"></a>begin(size_type n) <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p><code class="computeroutput">n</code> shall be in the range <code class="computeroutput">[0, bucket_count())</code>.</p></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>A local iterator pointing the first element in the bucket with index <code class="computeroutput">n</code>.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id1341870-bb"></a><span class="type">local_iterator</span> <a name="id1341874-bb"></a>end(size_type n);
<span class="type">const_local_iterator</span> <a name="id1341893-bb"></a>end(size_type n) <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p><code class="computeroutput">n</code> shall be in the range <code class="computeroutput">[0, bucket_count())</code>.</p></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>A local iterator pointing the 'one past the end' element in the bucket with index <code class="computeroutput">n</code>.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">const_local_iterator</span> <a name="id1341942-bb"></a>cbegin(size_type n) <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p><code class="computeroutput">n</code> shall be in the range <code class="computeroutput">[0, bucket_count())</code>.</p></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>A constant local iterator pointing the first element in the bucket with index <code class="computeroutput">n</code>.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type">const_local_iterator</span> <a name="id1341990-bb"></a>cend(size_type n);</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p><code class="computeroutput">n</code> shall be in the range <code class="computeroutput">[0, bucket_count())</code>.</p></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>A constant local iterator pointing the 'one past the end' element in the bucket with index <code class="computeroutput">n</code>.</p></td>
</tr>
</tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2" title="unordered_set hash policy">
<a name="id2021980"></a><h3>
<a name="id1342039-bb"></a><code class="computeroutput">unordered_set</code> hash policy</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>float</strong></span></span> <a name="id1342043-bb"></a>load_factor() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The average number of elements per bucket.</p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>float</strong></span></span> <a name="id1309346-bb"></a>max_load_factor() <span class="bold"><strong>const</strong></span>;</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>Returns the current maximum load factor.</p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id1309366-bb"></a>max_load_factor(<span class="bold"><strong>float</strong></span> z);</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Effects:</span></p></td>
<td><p>Changes the container's maximum load factor, using <code class="computeroutput">z</code> as a hint.</p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id1309398-bb"></a>rehash(size_type n);</pre>
<p>Changes the number of buckets so that there at least <code class="computeroutput">n</code> buckets, and so that the load factor is less than the maximum load factor.</p>
<p>Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.</p></td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2" title="unordered_set Equality Comparisons">
<a name="id2022166"></a><h3>
<a name="id1309448-bb"></a><code class="computeroutput">unordered_set</code> Equality Comparisons</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Value, <span class="bold"><strong>typename</strong></span> Hash, <span class="bold"><strong>typename</strong></span> Pred, <span class="bold"><strong>typename</strong></span> Alloc>
<span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="boost.operator==_id1309452"></a><span class="bold"><strong>operator</strong></span>==(unordered_set<Value, Hash, Pred, Alloc> <span class="bold"><strong>const</strong></span>& x,
unordered_set<Value, Hash, Pred, Alloc> <span class="bold"><strong>const</strong></span>& y);</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Notes:</span></p></td>
<td>
<p>This is a boost extension.</p>
<p>Behavior is undefined if the two containers don't have
equivalent equality predicates.</p>
</td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Value, <span class="bold"><strong>typename</strong></span> Hash, <span class="bold"><strong>typename</strong></span> Pred, <span class="bold"><strong>typename</strong></span> Alloc>
<span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="boost.operator!=_id1309526"></a><span class="bold"><strong>operator</strong></span>!=(unordered_set<Value, Hash, Pred, Alloc> <span class="bold"><strong>const</strong></span>& x,
unordered_set<Value, Hash, Pred, Alloc> <span class="bold"><strong>const</strong></span>& y);</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term">Notes:</span></p></td>
<td>
<p>This is a boost extension.</p>
<p>Behavior is undefined if the two containers don't have
equivalent equality predicates.</p>
</td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2" title="unordered_set swap">
<a name="id2022353"></a><h3>
<a name="id1309600-bb"></a><code class="computeroutput">unordered_set</code> swap</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Value, <span class="bold"><strong>typename</strong></span> Hash, <span class="bold"><strong>typename</strong></span> Pred, <span class="bold"><strong>typename</strong></span> Alloc>
<span class="type"><span class="bold"><strong>void</strong></span></span> <a name="boost.swap_id1309605"></a>swap(unordered_set<Value, Hash, Pred, Alloc>& x,
unordered_set<Value, Hash, Pred, Alloc>& y);</pre>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Effects:</span></p></td>
<td><p><code class="computeroutput">x.swap(y)</code></p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>If the allocators are equal, doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of <code class="computeroutput">Hash</code> or <code class="computeroutput">Pred</code>.</p></td>
</tr>
<tr>
<td><p><span class="term">Notes:</span></p></td>
<td><p>For a discussion of the behavior when allocators aren't equal see
<a class="link" href="../unordered/rationale.html#unordered.rationale.swapping_containers_with_unequal_allocators">the implementation details</a>.</p></td>
</tr>
</tbody>
</table></div>
</li></ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2003, 2004 Jeremy B. Maitin-Shepard<br>Copyright © 2005-2008 Daniel
James<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../unordered/reference.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../unordered/reference.html#header.boost.unordered_set_hpp"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="unordered_multiset.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
</div>
</body>
</html>
|