1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
12 // class Alloc = allocator<pair<const Key, T>>>
13 // class unordered_multimap
15 // local_iterator begin (size_type n);
16 // local_iterator end (size_type n);
17 // const_local_iterator begin (size_type n) const;
18 // const_local_iterator end (size_type n) const;
19 // const_local_iterator cbegin(size_type n) const;
20 // const_local_iterator cend (size_type n) const;
22 #include <unordered_map>
26 #include "test_macros.h"
31 typedef std::unordered_multimap
<int, std::string
> C
;
32 typedef std::pair
<int, std::string
> P
;
33 typedef C::local_iterator I
;
43 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
44 LIBCPP_ASSERT(c
.bucket_count() == 7);
45 C::size_type b
= c
.bucket(0);
48 assert(std::distance(i
, j
) == 0);
53 assert(std::distance(i
, j
) == 2);
54 assert(i
->first
== 1);
55 assert(i
->second
== "one");
57 assert(i
->first
== 1);
58 assert(i
->second
== "four");
64 assert(std::distance(i
, j
) == 2);
65 assert(i
->first
== 2);
66 assert(i
->second
== "two");
68 assert(i
->first
== 2);
69 assert(i
->second
== "four");
74 assert(std::distance(i
, j
) == 1);
75 assert(i
->first
== 3);
76 assert(i
->second
== "three");
81 assert(std::distance(i
, j
) == 1);
82 assert(i
->first
== 4);
83 assert(i
->second
== "four");
88 assert(std::distance(i
, j
) == 0);
93 assert(std::distance(i
, j
) == 0);
96 typedef std::unordered_multimap
<int, std::string
> C
;
97 typedef std::pair
<int, std::string
> P
;
98 typedef C::const_local_iterator I
;
108 const C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
109 LIBCPP_ASSERT(c
.bucket_count() == 7);
110 C::size_type b
= c
.bucket(0);
113 assert(std::distance(i
, j
) == 0);
118 assert(std::distance(i
, j
) == 2);
119 assert(i
->first
== 1);
120 assert(i
->second
== "one");
122 assert(i
->first
== 1);
123 assert(i
->second
== "four");
128 assert(std::distance(i
, j
) == 2);
129 assert(i
->first
== 2);
130 assert(i
->second
== "two");
132 assert(i
->first
== 2);
133 assert(i
->second
== "four");
138 assert(std::distance(i
, j
) == 1);
139 assert(i
->first
== 3);
140 assert(i
->second
== "three");
145 assert(std::distance(i
, j
) == 1);
146 assert(i
->first
== 4);
147 assert(i
->second
== "four");
152 assert(std::distance(i
, j
) == 0);
157 assert(std::distance(i
, j
) == 0);
160 typedef std::unordered_multimap
<int, std::string
> C
;
161 typedef std::pair
<int, std::string
> P
;
162 typedef C::const_local_iterator I
;
172 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
173 LIBCPP_ASSERT(c
.bucket_count() == 7);
174 C::size_type b
= c
.bucket(0);
177 assert(std::distance(i
, j
) == 0);
182 assert(std::distance(i
, j
) == 2);
183 assert(i
->first
== 1);
184 assert(i
->second
== "one");
186 assert(i
->first
== 1);
187 assert(i
->second
== "four");
192 assert(std::distance(i
, j
) == 2);
193 assert(i
->first
== 2);
194 assert(i
->second
== "two");
196 assert(i
->first
== 2);
197 assert(i
->second
== "four");
202 assert(std::distance(i
, j
) == 1);
203 assert(i
->first
== 3);
204 assert(i
->second
== "three");
209 assert(std::distance(i
, j
) == 1);
210 assert(i
->first
== 4);
211 assert(i
->second
== "four");
216 assert(std::distance(i
, j
) == 0);
221 assert(std::distance(i
, j
) == 0);
224 typedef std::unordered_multimap
<int, std::string
> C
;
225 typedef std::pair
<int, std::string
> P
;
226 typedef C::const_local_iterator I
;
236 const C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
237 LIBCPP_ASSERT(c
.bucket_count() == 7);
238 C::size_type b
= c
.bucket(0);
241 assert(std::distance(i
, j
) == 0);
246 assert(std::distance(i
, j
) == 2);
247 assert(i
->first
== 1);
248 assert(i
->second
== "one");
250 assert(i
->first
== 1);
251 assert(i
->second
== "four");
256 assert(std::distance(i
, j
) == 2);
257 assert(i
->first
== 2);
258 assert(i
->second
== "two");
260 assert(i
->first
== 2);
261 assert(i
->second
== "four");
266 assert(std::distance(i
, j
) == 1);
267 assert(i
->first
== 3);
268 assert(i
->second
== "three");
273 assert(std::distance(i
, j
) == 1);
274 assert(i
->first
== 4);
275 assert(i
->second
== "four");
280 assert(std::distance(i
, j
) == 0);
285 assert(std::distance(i
, j
) == 0);