blob: 07980c2afc85109a14c30204bef39d9c845dad63 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
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>
Howard Hinnantf836d532011-12-02 21:23:14 +000020#include <cfloat>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000021
Marshall Clow061d0cc2013-11-26 20:58:02 +000022#include "min_allocator.h"
Howard Hinnant7a6b7ce2013-06-22 15:21:29 +000023
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000024int 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));
Dan Albert1d4a1ed2016-05-25 22:36:09 -070041 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000042 }
43 {
44 typedef std::unordered_multiset<int> C;
45 typedef int P;
46 const C c;
47 assert(c.load_factor() == 0);
48 }
Howard Hinnant7a6b7ce2013-06-22 15:21:29 +000049#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));
Dan Albert1d4a1ed2016-05-25 22:36:09 -070066 assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
Howard Hinnant7a6b7ce2013-06-22 15:21:29 +000067 }
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
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000076}