• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // float load_factor() const
17 
18 #include <unordered_set>
19 #include <cassert>
20 #include <cfloat>
21 
22 #include "min_allocator.h"
23 
main()24 int main()
25 {
26     {
27         typedef std::unordered_multiset<int> C;
28         typedef int P;
29         P a[] =
30         {
31             P(10),
32             P(20),
33             P(30),
34             P(40),
35             P(50),
36             P(60),
37             P(70),
38             P(80)
39         };
40         const C c(std::begin(a), std::end(a));
41         assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
42     }
43     {
44         typedef std::unordered_multiset<int> C;
45         typedef int P;
46         const C c;
47         assert(c.load_factor() == 0);
48     }
49 #if __cplusplus >= 201103L
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(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         typedef int P;
72         const C c;
73         assert(c.load_factor() == 0);
74     }
75 #endif
76 }
77