Home | History | Annotate | Download | only in unord.multiset
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <unordered_set>
     11 
     12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
     13 //           class Alloc = allocator<Value>>
     14 // class unordered_multiset
     15 
     16 // void rehash(size_type n);
     17 
     18 #include <unordered_set>
     19 #include <cassert>
     20 
     21 void test(const std::unordered_multiset<int>& c)
     22 {
     23     assert(c.size() == 6);
     24     assert(c.count(1) == 2);
     25     assert(c.count(2) == 2);
     26     assert(c.count(3) == 1);
     27     assert(c.count(4) == 1);
     28 }
     29 
     30 int main()
     31 {
     32     {
     33         typedef std::unordered_multiset<int> C;
     34         typedef int P;
     35         P a[] =
     36         {
     37             P(1),
     38             P(2),
     39             P(3),
     40             P(4),
     41             P(1),
     42             P(2)
     43         };
     44         C c(a, a + sizeof(a)/sizeof(a[0]));
     45         test(c);
     46         assert(c.bucket_count() >= 7);
     47         c.rehash(3);
     48         assert(c.bucket_count() == 7);
     49         test(c);
     50         c.max_load_factor(2);
     51         c.rehash(3);
     52         assert(c.bucket_count() == 3);
     53         test(c);
     54         c.rehash(31);
     55         assert(c.bucket_count() == 31);
     56         test(c);
     57     }
     58 }
     59