blob: 0c17583d371de4650d42f2e4f02357881daa890d [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// void reserve(size_type n);
17
18#include <unordered_set>
19#include <cassert>
20
Marshall Clow061d0cc2013-11-26 20:58:02 +000021#include "min_allocator.h"
Howard Hinnant7a6b7ce2013-06-22 15:21:29 +000022
23template <class C>
24void test(const C& c)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000025{
26 assert(c.size() == 6);
27 assert(c.count(1) == 2);
28 assert(c.count(2) == 2);
29 assert(c.count(3) == 1);
30 assert(c.count(4) == 1);
31}
32
33int main()
34{
35 {
36 typedef std::unordered_multiset<int> C;
37 typedef int P;
38 P a[] =
39 {
40 P(1),
41 P(2),
42 P(3),
43 P(4),
44 P(1),
45 P(2)
46 };
47 C c(a, a + sizeof(a)/sizeof(a[0]));
48 test(c);
49 assert(c.bucket_count() >= 7);
50 c.reserve(3);
51 assert(c.bucket_count() == 7);
52 test(c);
53 c.max_load_factor(2);
54 c.reserve(3);
55 assert(c.bucket_count() == 3);
56 test(c);
57 c.reserve(31);
Howard Hinnant7a445152012-07-06 17:31:14 +000058 assert(c.bucket_count() >= 16);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000059 test(c);
60 }
Howard Hinnant7a6b7ce2013-06-22 15:21:29 +000061#if __cplusplus >= 201103L
62 {
63 typedef std::unordered_multiset<int, std::hash<int>,
64 std::equal_to<int>, min_allocator<int>> C;
65 typedef int P;
66 P a[] =
67 {
68 P(1),
69 P(2),
70 P(3),
71 P(4),
72 P(1),
73 P(2)
74 };
75 C c(a, a + sizeof(a)/sizeof(a[0]));
76 test(c);
77 assert(c.bucket_count() >= 7);
78 c.reserve(3);
79 assert(c.bucket_count() == 7);
80 test(c);
81 c.max_load_factor(2);
82 c.reserve(3);
83 assert(c.bucket_count() == 3);
84 test(c);
85 c.reserve(31);
86 assert(c.bucket_count() >= 16);
87 test(c);
88 }
89#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000090}