Home | History | Annotate | Download | only in unord.multimap
      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 int main()
     28 {
     29     {
     30         typedef std::unordered_multimap<int, std::string> C;
     31         typedef std::pair<int, std::string> P;
     32         P a[] =
     33         {
     34             P(1, "one"),
     35             P(2, "two"),
     36             P(3, "three"),
     37             P(4, "four"),
     38             P(1, "four"),
     39             P(2, "four"),
     40         };
     41         C c(a, a + sizeof(a)/sizeof(a[0]));
     42         assert(c.bucket_count() == 7);
     43         assert(c.size() == 6);
     44         assert(std::distance(c.begin(), c.end()) == c.size());
     45         assert(std::distance(c.cbegin(), c.cend()) == c.size());
     46         C::iterator i = c.begin();
     47         i->second = "ONE";
     48         assert(i->second == "ONE");
     49         i->first = 2;
     50     }
     51     {
     52         typedef std::unordered_multimap<int, std::string> C;
     53         typedef std::pair<int, std::string> P;
     54         P a[] =
     55         {
     56             P(1, "one"),
     57             P(2, "two"),
     58             P(3, "three"),
     59             P(4, "four"),
     60             P(1, "four"),
     61             P(2, "four"),
     62         };
     63         const C c(a, a + sizeof(a)/sizeof(a[0]));
     64         assert(c.bucket_count() == 7);
     65         assert(c.size() == 6);
     66         assert(std::distance(c.begin(), c.end()) == c.size());
     67         assert(std::distance(c.cbegin(), c.cend()) == c.size());
     68     }
     69 }
     70