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 //===----------------------------------------------------------------------===//
8 #ifndef CHECK_CONSECUTIVE_H
9 #define CHECK_CONSECUTIVE_H
11 // <unordered_multiset>
12 // <unordered_multimap>
18 // Check consecutive equal values in an unordered_multiset iterator
19 template <typename Iter
>
20 void CheckConsecutiveValues(Iter pos
, Iter end
, typename
Iter::value_type value
, size_t count
)
22 for ( size_t i
= 0; i
< count
; ++i
)
25 assert(*pos
== value
);
28 assert(pos
== end
|| *pos
!= value
);
31 // Check consecutive equal keys in an unordered_multimap iterator
32 template <typename Iter
>
33 void CheckConsecutiveKeys(Iter pos
, Iter end
, typename
Iter::value_type::first_type key
, std::multiset
<typename
Iter::value_type::second_type
>& values
)
35 while (!values
.empty())
38 assert(pos
->first
== key
);
39 assert(values
.find(pos
->second
) != values
.end());
40 values
.erase(values
.find(pos
->second
));
43 assert(pos
== end
|| pos
->first
!= key
);