1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
13 // class Alloc = allocator<Value>>
14 // class unordered_set
16 // void rehash(size_type n);
18 #include <unordered_set>
21 #include "min_allocator.h"
24 void rehash_postcondition(const C& c, size_t n)
26 assert(c.bucket_count() >= c.size() / c.max_load_factor() && c.bucket_count() >= n);
32 assert(c.size() == 4);
33 assert(c.count(1) == 1);
34 assert(c.count(2) == 1);
35 assert(c.count(3) == 1);
36 assert(c.count(4) == 1);
42 typedef std::unordered_set<int> C;
53 C c(a, a + sizeof(a)/sizeof(a[0]));
55 assert(c.bucket_count() >= 5);
57 rehash_postcondition(c, 3);
58 assert(c.bucket_count() == 5);
62 rehash_postcondition(c, 3);
63 assert(c.bucket_count() == 3);
66 rehash_postcondition(c, 31);
67 assert(c.bucket_count() == 31);
70 #if __cplusplus >= 201103L
72 typedef std::unordered_set<int, std::hash<int>,
73 std::equal_to<int>, min_allocator<int>> C;
84 C c(a, a + sizeof(a)/sizeof(a[0]));
86 assert(c.bucket_count() >= 5);
88 rehash_postcondition(c, 3);
89 assert(c.bucket_count() == 5);
93 rehash_postcondition(c, 3);
94 assert(c.bucket_count() == 3);
97 rehash_postcondition(c, 31);
98 assert(c.bucket_count() == 31);