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_set 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_set<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() >= 5); 43 assert(c.bucket_size(0) == 0); 44 assert(c.bucket_size(1) == 1); 45 assert(c.bucket_size(2) == 1); 46 assert(c.bucket_size(3) == 1); 47 assert(c.bucket_size(4) == 1); 48 } 49 #if __cplusplus >= 201103L 50 { 51 typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; 52 typedef int P; 53 P a[] = 54 { 55 P(1), 56 P(2), 57 P(3), 58 P(4), 59 P(1), 60 P(2) 61 }; 62 const C c(std::begin(a), std::end(a)); 63 assert(c.bucket_count() >= 5); 64 assert(c.bucket_size(0) == 0); 65 assert(c.bucket_size(1) == 1); 66 assert(c.bucket_size(2) == 1); 67 assert(c.bucket_size(3) == 1); 68 assert(c.bucket_size(4) == 1); 69 } 70 #endif 71 #if _LIBCPP_DEBUG_LEVEL >= 1 72 { 73 typedef std::unordered_set<int> C; 74 C c; 75 C::size_type i = c.bucket_size(3); 76 assert(false); 77 } 78 #endif 79 } 80