1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // <unordered_set> |
10 | |
11 | // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, |
12 | // class Alloc = allocator<Value>> |
13 | // class unordered_multiset |
14 | |
15 | // float load_factor() const |
16 | |
17 | #include <unordered_set> |
18 | #include <cassert> |
19 | #include <cfloat> |
20 | #include <cmath> |
21 | |
22 | #include "test_macros.h" |
23 | #include "min_allocator.h" |
24 | |
25 | int main(int, char**) |
26 | { |
27 | { |
28 | typedef std::unordered_multiset<int> C; |
29 | typedef int P; |
30 | P a[] = |
31 | { |
32 | P(10), |
33 | P(20), |
34 | P(30), |
35 | P(40), |
36 | P(50), |
37 | P(60), |
38 | P(70), |
39 | P(80) |
40 | }; |
41 | const C c(std::begin(arr&: a), std::end(arr&: a)); |
42 | assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); |
43 | } |
44 | { |
45 | typedef std::unordered_multiset<int> C; |
46 | const C c; |
47 | assert(c.load_factor() == 0); |
48 | } |
49 | #if TEST_STD_VER >= 11 |
50 | { |
51 | typedef std::unordered_multiset<int, std::hash<int>, |
52 | std::equal_to<int>, min_allocator<int>> C; |
53 | typedef int P; |
54 | P a[] = |
55 | { |
56 | P(10), |
57 | P(20), |
58 | P(30), |
59 | P(40), |
60 | P(50), |
61 | P(60), |
62 | P(70), |
63 | P(80) |
64 | }; |
65 | const C c(std::begin(a), std::end(a)); |
66 | assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); |
67 | } |
68 | { |
69 | typedef std::unordered_multiset<int, std::hash<int>, |
70 | std::equal_to<int>, min_allocator<int>> C; |
71 | const C c; |
72 | assert(c.load_factor() == 0); |
73 | } |
74 | #endif |
75 | |
76 | return 0; |
77 | } |
78 | |