1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <unordered_map>
11
12 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
13 // class Alloc = allocator<pair<const Key, T>>>
14 // class unordered_multimap
15
16 // iterator begin() {return __table_.begin();}
17 // iterator end() {return __table_.end();}
18 // const_iterator begin() const {return __table_.begin();}
19 // const_iterator end() const {return __table_.end();}
20 // const_iterator cbegin() const {return __table_.begin();}
21 // const_iterator cend() const {return __table_.end();}
22
23 #include <unordered_map>
24 #include <string>
25 #include <cassert>
26
27 #include "test_macros.h"
28
main()29 int main()
30 {
31 {
32 typedef std::unordered_multimap<int, std::string> C;
33 typedef std::pair<int, std::string> P;
34 P a[] =
35 {
36 P(1, "one"),
37 P(2, "two"),
38 P(3, "three"),
39 P(4, "four"),
40 P(1, "four"),
41 P(2, "four"),
42 };
43 C c(a, a + sizeof(a)/sizeof(a[0]));
44 LIBCPP_ASSERT(c.bucket_count() == 7);
45 assert(c.size() == 6);
46 assert(std::distance(c.begin(), c.end()) == c.size());
47 assert(std::distance(c.cbegin(), c.cend()) == c.size());
48 C::iterator i = c.begin();
49 i->second = "ONE";
50 assert(i->second == "ONE");
51 i->first = 2;
52 }
53 {
54 typedef std::unordered_multimap<int, std::string> C;
55 typedef std::pair<int, std::string> P;
56 P a[] =
57 {
58 P(1, "one"),
59 P(2, "two"),
60 P(3, "three"),
61 P(4, "four"),
62 P(1, "four"),
63 P(2, "four"),
64 };
65 const C c(a, a + sizeof(a)/sizeof(a[0]));
66 LIBCPP_ASSERT(c.bucket_count() == 7);
67 assert(c.size() == 6);
68 assert(std::distance(c.begin(), c.end()) == c.size());
69 assert(std::distance(c.cbegin(), c.cend()) == c.size());
70 }
71 }
72