Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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> |
Howard Hinnant | f836d53 | 2011-12-02 21:23:14 +0000 | [diff] [blame] | 20 | #include <cfloat> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 21 | |
Marshall Clow | 061d0cc | 2013-11-26 20:58:02 +0000 | [diff] [blame] | 22 | #include "min_allocator.h" |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 23 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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)); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 41 | assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 42 | } |
| 43 | { |
| 44 | typedef std::unordered_multiset<int> C; |
| 45 | typedef int P; |
| 46 | const C c; |
| 47 | assert(c.load_factor() == 0); |
| 48 | } |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 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)); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 66 | assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 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 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 76 | } |