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 Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12 // class Alloc = allocator<Value>>
13 // class unordered_multiset
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_set>
25 #include "test_macros.h"
26 #include "min_allocator.h"
31 typedef std::unordered_multiset
<int> C
;
33 typedef C::local_iterator I
;
43 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
44 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);
61 assert(std::distance(i
, j
) == 2);
69 assert(std::distance(i
, j
) == 1);
75 assert(std::distance(i
, j
) == 1);
81 assert(std::distance(i
, j
) == 0);
86 assert(std::distance(i
, j
) == 0);
89 typedef std::unordered_multiset
<int> C
;
91 typedef C::const_local_iterator I
;
101 const C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
102 assert(c
.bucket_count() >= 7);
103 C::size_type b
= c
.bucket(0);
106 assert(std::distance(i
, j
) == 0);
111 assert(std::distance(i
, j
) == 2);
119 assert(std::distance(i
, j
) == 2);
127 assert(std::distance(i
, j
) == 1);
133 assert(std::distance(i
, j
) == 1);
139 assert(std::distance(i
, j
) == 0);
144 assert(std::distance(i
, j
) == 0);
147 typedef std::unordered_multiset
<int> C
;
149 typedef C::const_local_iterator I
;
159 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
160 assert(c
.bucket_count() >= 7);
161 C::size_type b
= c
.bucket(0);
164 assert(std::distance(i
, j
) == 0);
169 assert(std::distance(i
, j
) == 2);
177 assert(std::distance(i
, j
) == 2);
185 assert(std::distance(i
, j
) == 1);
191 assert(std::distance(i
, j
) == 1);
197 assert(std::distance(i
, j
) == 0);
202 assert(std::distance(i
, j
) == 0);
205 typedef std::unordered_multiset
<int> C
;
207 typedef C::const_local_iterator I
;
217 const C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
218 assert(c
.bucket_count() >= 7);
219 C::size_type b
= c
.bucket(0);
222 assert(std::distance(i
, j
) == 0);
227 assert(std::distance(i
, j
) == 2);
235 assert(std::distance(i
, j
) == 2);
243 assert(std::distance(i
, j
) == 1);
249 assert(std::distance(i
, j
) == 1);
255 assert(std::distance(i
, j
) == 0);
260 assert(std::distance(i
, j
) == 0);
262 #if TEST_STD_VER >= 11
264 typedef std::unordered_multiset
<int, std::hash
<int>,
265 std::equal_to
<int>, min_allocator
<int>> C
;
267 typedef C::local_iterator I
;
277 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
278 assert(c
.bucket_count() >= 7);
279 C::size_type b
= c
.bucket(0);
282 assert(std::distance(i
, j
) == 0);
287 assert(std::distance(i
, j
) == 2);
295 assert(std::distance(i
, j
) == 2);
303 assert(std::distance(i
, j
) == 1);
309 assert(std::distance(i
, j
) == 1);
315 assert(std::distance(i
, j
) == 0);
320 assert(std::distance(i
, j
) == 0);
323 typedef std::unordered_multiset
<int, std::hash
<int>,
324 std::equal_to
<int>, min_allocator
<int>> C
;
326 typedef C::const_local_iterator I
;
336 const C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
337 assert(c
.bucket_count() >= 7);
338 C::size_type b
= c
.bucket(0);
341 assert(std::distance(i
, j
) == 0);
346 assert(std::distance(i
, j
) == 2);
354 assert(std::distance(i
, j
) == 2);
362 assert(std::distance(i
, j
) == 1);
368 assert(std::distance(i
, j
) == 1);
374 assert(std::distance(i
, j
) == 0);
379 assert(std::distance(i
, j
) == 0);
382 typedef std::unordered_multiset
<int, std::hash
<int>,
383 std::equal_to
<int>, min_allocator
<int>> C
;
385 typedef C::const_local_iterator I
;
395 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
396 assert(c
.bucket_count() >= 7);
397 C::size_type b
= c
.bucket(0);
400 assert(std::distance(i
, j
) == 0);
405 assert(std::distance(i
, j
) == 2);
413 assert(std::distance(i
, j
) == 2);
421 assert(std::distance(i
, j
) == 1);
427 assert(std::distance(i
, j
) == 1);
433 assert(std::distance(i
, j
) == 0);
438 assert(std::distance(i
, j
) == 0);
441 typedef std::unordered_multiset
<int, std::hash
<int>,
442 std::equal_to
<int>, min_allocator
<int>> C
;
444 typedef C::const_local_iterator I
;
454 const C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
455 assert(c
.bucket_count() >= 7);
456 C::size_type b
= c
.bucket(0);
459 assert(std::distance(i
, j
) == 0);
464 assert(std::distance(i
, j
) == 2);
472 assert(std::distance(i
, j
) == 2);
480 assert(std::distance(i
, j
) == 1);
486 assert(std::distance(i
, j
) == 1);
492 assert(std::distance(i
, j
) == 0);
497 assert(std::distance(i
, j
) == 0);