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 // size_type bucket_size(size_type n) const
     17 
     18 #ifdef _LIBCPP_DEBUG
     19 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
     20 #endif
     21 
     22 #include <unordered_set>
     23 #include <cassert>
     24 
     25 #include "min_allocator.h"
     26 
     27 int main()
     28 {
     29     {
     30         typedef std::unordered_multiset<int> C;
     31         typedef int P;
     32         P a[] =
     33         {
     34             P(1),
     35             P(2),
     36             P(3),
     37             P(4),
     38             P(1),
     39             P(2)
     40         };
     41         const C c(std::begin(a), std::end(a));
     42         assert(c.bucket_count() >= 7);
     43         assert(c.bucket_size(0) == 0);
     44         assert(c.bucket_size(1) == 2);
     45         assert(c.bucket_size(2) == 2);
     46         assert(c.bucket_size(3) == 1);
     47         assert(c.bucket_size(4) == 1);
     48         assert(c.bucket_size(5) == 0);
     49         assert(c.bucket_size(6) == 0);
     50     }
     51 #if __cplusplus >= 201103L
     52     {
     53         typedef std::unordered_multiset<int, std::hash<int>,
     54                                       std::equal_to<int>, min_allocator<int>> C;
     55         typedef int P;
     56         P a[] =
     57         {
     58             P(1),
     59             P(2),
     60             P(3),
     61             P(4),
     62             P(1),
     63             P(2)
     64         };
     65         const C c(std::begin(a), std::end(a));
     66         assert(c.bucket_count() >= 7);
     67         assert(c.bucket_size(0) == 0);
     68         assert(c.bucket_size(1) == 2);
     69         assert(c.bucket_size(2) == 2);
     70         assert(c.bucket_size(3) == 1);
     71         assert(c.bucket_size(4) == 1);
     72         assert(c.bucket_size(5) == 0);
     73         assert(c.bucket_size(6) == 0);
     74     }
     75 #endif
     76 #if _LIBCPP_DEBUG_LEVEL >= 1
     77     {
     78         typedef std::unordered_multiset<int> C;
     79         C c;
     80         C::size_type i = c.bucket_size(3);
     81         assert(false);
     82     }
     83 #endif
     84 }
     85