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 | // size_type bucket_size(size_type n) const |
16 | |
17 | #include <unordered_set> |
18 | #include <cassert> |
19 | |
20 | #include "test_macros.h" |
21 | #include "min_allocator.h" |
22 | |
23 | int main(int, char**) |
24 | { |
25 | { |
26 | typedef std::unordered_multiset<int> C; |
27 | typedef int P; |
28 | P a[] = |
29 | { |
30 | P(1), |
31 | P(2), |
32 | P(3), |
33 | P(4), |
34 | P(1), |
35 | P(2) |
36 | }; |
37 | const C c(std::begin(arr&: a), std::end(arr&: a)); |
38 | assert(c.bucket_count() >= 7); |
39 | LIBCPP_ASSERT(c.bucket_size(n: 0) == 0); |
40 | LIBCPP_ASSERT(c.bucket_size(n: 1) == 2); |
41 | LIBCPP_ASSERT(c.bucket_size(n: 2) == 2); |
42 | LIBCPP_ASSERT(c.bucket_size(n: 3) == 1); |
43 | LIBCPP_ASSERT(c.bucket_size(n: 4) == 1); |
44 | LIBCPP_ASSERT(c.bucket_size(n: 5) == 0); |
45 | LIBCPP_ASSERT(c.bucket_size(n: 6) == 0); |
46 | } |
47 | #if TEST_STD_VER >= 11 |
48 | { |
49 | typedef std::unordered_multiset<int, std::hash<int>, |
50 | std::equal_to<int>, min_allocator<int>> C; |
51 | typedef int P; |
52 | P a[] = |
53 | { |
54 | P(1), |
55 | P(2), |
56 | P(3), |
57 | P(4), |
58 | P(1), |
59 | P(2) |
60 | }; |
61 | const C c(std::begin(a), std::end(a)); |
62 | assert(c.bucket_count() >= 7); |
63 | LIBCPP_ASSERT(c.bucket_size(0) == 0); |
64 | LIBCPP_ASSERT(c.bucket_size(1) == 2); |
65 | LIBCPP_ASSERT(c.bucket_size(2) == 2); |
66 | LIBCPP_ASSERT(c.bucket_size(3) == 1); |
67 | LIBCPP_ASSERT(c.bucket_size(4) == 1); |
68 | LIBCPP_ASSERT(c.bucket_size(5) == 0); |
69 | LIBCPP_ASSERT(c.bucket_size(6) == 0); |
70 | } |
71 | #endif |
72 | return 0; |
73 | } |
74 | |