libcxx initial import

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2010-05-11 19:42:16 +00:00
commit bc8d3f97eb
3893 changed files with 1209942 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// Not a portable test
// <__hash_table>
// size_t __next_prime(size_t n);
// If n == 0, return 0, else return the lowest prime greater than or equal to n
#include <__hash_table>
#include <cassert>
bool
is_prime(size_t n)
{
switch (n)
{
case 0:
case 1:
return false;
}
for (size_t i = 2; i*i <= n; ++i)
{
if (n % i == 0)
return false;
}
return true;
}
int main()
{
assert(std::__next_prime(0) == 0);
for (std::size_t n = 1; n <= 100000; ++n)
{
std::size_t p = std::__next_prime(n);
assert(p >= n);
for (std::size_t i = n; i < p; ++i)
assert(!is_prime(i));
assert(is_prime(p));
}
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// size_type bucket(const key_type& __k) const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(std::begin(a), std::end(a));
size_t bc = c.bucket_count();
assert(bc >= 5);
for (size_t i = 0; i < 13; ++i)
assert(c.bucket(i) == i % bc);
}
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// size_type bucket_count() const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef C::const_iterator I;
typedef std::pair<int, std::string> P;
const C c;
assert(c.bucket_count() == 0);
}
{
typedef std::unordered_map<int, std::string> C;
typedef C::const_iterator I;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c(std::begin(a), std::end(a));
assert(c.bucket_count() >= 11);
}
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// size_type bucket_size(size_type n) const
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(std::begin(a), std::end(a));
assert(c.bucket_count() >= 5);
assert(c.bucket_size(0) == 0);
assert(c.bucket_size(1) == 1);
assert(c.bucket_size(2) == 1);
assert(c.bucket_size(3) == 1);
assert(c.bucket_size(4) == 1);
}
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// size_type count(const key_type& k) const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c(std::begin(a), std::end(a));
assert(c.count(30) == 1);
assert(c.count(5) == 0);
}
}

View File

@@ -0,0 +1,92 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash, class Pred, class Alloc>
// bool
// operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
// const unordered_map<Key, T, Hash, Pred, Alloc>& y);
//
// template <class Key, class T, class Hash, class Pred, class Alloc>
// bool
// operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
// const unordered_map<Key, T, Hash, Pred, Alloc>& y);
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c1(std::begin(a), std::end(a));
const C c2;
assert(!(c1 == c2));
assert( (c1 != c2));
}
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c1(std::begin(a), std::end(a));
const C c2 = c1;
assert( (c1 == c2));
assert(!(c1 != c2));
}
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(std::begin(a), std::end(a));
C c2 = c1;
c2.rehash(30);
assert( (c1 == c2));
assert(!(c1 != c2));
c2.insert(P(90, "ninety"));
assert(!(c1 == c2));
assert( (c1 != c2));
c1.insert(P(90, "ninety"));
assert( (c1 == c2));
assert(!(c1 != c2));
}
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef C::const_iterator I;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c(std::begin(a), std::end(a));
std::pair<I, I> r = c.equal_range(30);
assert(std::distance(r.first, r.second) == 1);
assert(r.first->first == 30);
assert(r.first->second == "thirty");
r = c.equal_range(5);
assert(std::distance(r.first, r.second) == 0);
}
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// pair<iterator, iterator> equal_range(const key_type& k);
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef C::iterator I;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c(std::begin(a), std::end(a));
std::pair<I, I> r = c.equal_range(30);
assert(std::distance(r.first, r.second) == 1);
assert(r.first->first == 30);
assert(r.first->second == "thirty");
r = c.equal_range(5);
assert(std::distance(r.first, r.second) == 0);
}
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// const_iterator find(const key_type& k) const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c(std::begin(a), std::end(a));
C::const_iterator i = c.find(30);
assert(i->first == 30);
assert(i->second == "thirty");
i = c.find(5);
assert(i == c.cend());
}
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// iterator find(const key_type& k);
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c(std::begin(a), std::end(a));
C::iterator i = c.find(30);
assert(i->first == 30);
assert(i->second == "thirty");
i = c.find(5);
assert(i == c.end());
}
}

View File

@@ -0,0 +1,65 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// iterator begin() {return __table_.begin();}
// iterator end() {return __table_.end();}
// const_iterator begin() const {return __table_.begin();}
// const_iterator end() const {return __table_.end();}
// const_iterator cbegin() const {return __table_.begin();}
// const_iterator cend() const {return __table_.end();}
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 5);
assert(c.size() == 4);
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
}
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 5);
assert(c.size() == 4);
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
}
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// float load_factor() const
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c(std::begin(a), std::end(a));
assert(c.load_factor() == (float)c.size() / c.bucket_count());
}
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
const C c;
assert(c.load_factor() == 0);
}
}

View File

@@ -0,0 +1,221 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// local_iterator begin (size_type n);
// local_iterator end (size_type n);
// const_local_iterator begin (size_type n) const;
// const_local_iterator end (size_type n) const;
// const_local_iterator cbegin(size_type n) const;
// const_local_iterator cend (size_type n) const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 5);
C::size_type b = c.bucket(0);
I i = c.begin(b);
I j = c.end(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 1);
assert(i->second == "one");
b = c.bucket(2);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 2);
assert(i->second == "two");
b = c.bucket(3);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
}
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::const_local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 5);
C::size_type b = c.bucket(0);
I i = c.begin(b);
I j = c.end(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 1);
assert(i->second == "one");
b = c.bucket(2);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 2);
assert(i->second == "two");
b = c.bucket(3);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
}
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::const_local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 5);
C::size_type b = c.bucket(0);
I i = c.cbegin(b);
I j = c.cend(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 1);
assert(i->second == "one");
b = c.bucket(2);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 2);
assert(i->second == "two");
b = c.bucket(3);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
}
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::const_local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 5);
C::size_type b = c.bucket(0);
I i = c.cbegin(b);
I j = c.cend(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 1);
assert(i->second == "one");
b = c.bucket(2);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 2);
assert(i->second == "two");
b = c.bucket(3);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
}
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// size_type max_bucket_count() const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef C::const_iterator I;
typedef std::pair<int, std::string> P;
const C c;
assert(c.max_bucket_count() > 0);
}
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// float max_load_factor() const;
// void max_load_factor(float mlf);
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
const C c;
assert(c.max_load_factor() == 1);
}
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
C c;
assert(c.max_load_factor() == 1);
c.max_load_factor(2.5);
assert(c.max_load_factor() == 2.5);
}
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// size_type max_size() const;
#include <unordered_map>
#include <cassert>
int main()
{
{
std::unordered_map<int, int> u;
assert(u.max_size() > 0);
}
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// void rehash(size_type n);
#include <unordered_map>
#include <string>
#include <cassert>
void test(const std::unordered_map<int, std::string>& c)
{
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
}
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
test(c);
assert(c.bucket_count() >= 5);
c.rehash(3);
assert(c.bucket_count() == 5);
test(c);
c.max_load_factor(2);
c.rehash(3);
assert(c.bucket_count() == 3);
test(c);
c.rehash(31);
assert(c.bucket_count() == 31);
test(c);
}
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// void reserve(size_type n);
#include <unordered_map>
#include <string>
#include <cassert>
void test(const std::unordered_map<int, std::string>& c)
{
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
}
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
test(c);
assert(c.bucket_count() >= 5);
c.reserve(3);
assert(c.bucket_count() == 5);
test(c);
c.max_load_factor(2);
c.reserve(3);
assert(c.bucket_count() >= 2);
test(c);
c.reserve(31);
assert(c.bucket_count() == 17);
test(c);
}
}

View File

@@ -0,0 +1,389 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// void swap(unordered_map& __u);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../test_compare.h"
#include "../../test_hash.h"
#include "../../test_allocator.h"
int main()
{
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.at(10) == "ten");
assert(c1.at(20) == "twenty");
assert(c1.at(30) == "thirty");
assert(c1.at(40) == "fourty");
assert(c1.at(50) == "fifty");
assert(c1.at(60) == "sixty");
assert(c1.at(70) == "seventy");
assert(c1.at(80) == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 5);
assert(c2.size() == 4);
assert(c2.at(1) == "one");
assert(c2.at(2) == "two");
assert(c2.at(3) == "three");
assert(c2.at(4) == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.at(10) == "ten");
assert(c1.at(20) == "twenty");
assert(c1.at(30) == "thirty");
assert(c1.at(40) == "fourty");
assert(c1.at(50) == "fifty");
assert(c1.at(60) == "sixty");
assert(c1.at(70) == "seventy");
assert(c1.at(80) == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 5);
assert(c2.size() == 4);
assert(c2.at(1) == "one");
assert(c2.at(2) == "two");
assert(c2.at(3) == "three");
assert(c2.at(4) == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.at(10) == "ten");
assert(c1.at(20) == "twenty");
assert(c1.at(30) == "thirty");
assert(c1.at(40) == "fourty");
assert(c1.at(50) == "fifty");
assert(c1.at(60) == "sixty");
assert(c1.at(70) == "seventy");
assert(c1.at(80) == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 5);
assert(c2.size() == 4);
assert(c2.at(1) == "one");
assert(c2.at(2) == "two");
assert(c2.at(3) == "three");
assert(c2.at(4) == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.at(10) == "ten");
assert(c1.at(20) == "twenty");
assert(c1.at(30) == "thirty");
assert(c1.at(40) == "fourty");
assert(c1.at(50) == "fifty");
assert(c1.at(60) == "sixty");
assert(c1.at(70) == "seventy");
assert(c1.at(80) == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 5);
assert(c2.size() == 4);
assert(c2.at(1) == "one");
assert(c2.at(2) == "two");
assert(c2.at(3) == "three");
assert(c2.at(4) == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// {
// public:
// // types
// typedef Key key_type;
// typedef T mapped_type;
// typedef Hash hasher;
// typedef Pred key_equal;
// typedef Alloc allocator_type;
// typedef pair<const key_type, mapped_type> value_type;
// typedef value_type& reference;
// typedef const value_type& const_reference;
// typedef typename allocator_traits<allocator_type>::pointer pointer;
// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
// typedef typename allocator_traits<allocator_type>::size_type size_type;
// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
#include <unordered_map>
#include <type_traits>
int main()
{
{
typedef std::unordered_map<char, short> C;
static_assert((std::is_same<C::key_type, char>::value), "");
static_assert((std::is_same<C::mapped_type, short>::value), "");
static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
static_assert((std::is_same<C::reference, C::value_type&>::value), "");
static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// explicit unordered_map(const allocator_type& __a);
#include <unordered_map>
#include <cassert>
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<NotConstructible, NotConstructible,
test_hash<std::hash<NotConstructible> >,
test_compare<std::equal_to<NotConstructible> >,
test_allocator<std::pair<const NotConstructible,
NotConstructible> >
> C;
C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
assert(c.bucket_count() == 0);
assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
assert(c.size() == 0);
assert(c.empty());
assert(std::distance(c.begin(), c.end()) == 0);
assert(c.load_factor() == 0);
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,118 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map& operator=(const unordered_map& u);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef test_allocator<std::pair<const int, std::string> > A;
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(a, a + 2,
7,
test_hash<std::hash<int> >(2),
test_compare<std::equal_to<int> >(3),
A(4)
);
c = c0;
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() == A(4));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
{
typedef other_allocator<std::pair<const int, std::string> > A;
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(a, a + 2,
7,
test_hash<std::hash<int> >(2),
test_compare<std::equal_to<int> >(3),
A(4)
);
c = c0;
assert(c.bucket_count() >= 5);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() == A(10));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map& operator=(initializer_list<value_type> il);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::allocator<std::pair<const int, std::string> > A;
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
C c = {
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
c = {
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
assert(c.bucket_count() >= 5);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#endif
}

View File

@@ -0,0 +1,167 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map& operator=(unordered_map&& u);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef test_allocator<std::pair<const int, std::string> > A;
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(a, a + 2,
7,
test_hash<std::hash<int> >(2),
test_compare<std::equal_to<int> >(3),
A(4)
);
c = std::move(c0);
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() == A(4));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
{
typedef test_allocator<std::pair<const int, std::string> > A;
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(a, a + 2,
7,
test_hash<std::hash<int> >(2),
test_compare<std::equal_to<int> >(3),
A(10)
);
c = std::move(c0);
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() == A(10));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c0.size() == 0);
}
{
typedef other_allocator<std::pair<const int, std::string> > A;
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(a, a + 2,
7,
test_hash<std::hash<int> >(2),
test_compare<std::equal_to<int> >(3),
A(4)
);
c = std::move(c0);
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() == A(10));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c0.size() == 0);
}
#endif
}

View File

@@ -0,0 +1,108 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(const unordered_map& u);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
C c = c0;
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >(10)));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
other_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
other_allocator<std::pair<const int, std::string> >(10)
);
C c = c0;
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(other_allocator<std::pair<const int, std::string> >(-2)));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#endif
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(const unordered_map& u, const allocator_type& a);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
C c(c0, test_allocator<std::pair<const int, std::string> >(5));
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >(5)));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map();
#include <unordered_map>
#include <cassert>
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<NotConstructible, NotConstructible,
test_hash<std::hash<NotConstructible> >,
test_compare<std::equal_to<NotConstructible> >,
test_allocator<std::pair<const NotConstructible,
NotConstructible> >
> C;
C c;
assert(c.bucket_count() == 0);
assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
assert(c.size() == 0);
assert(c.empty());
assert(std::distance(c.begin(), c.end()) == 0);
assert(c.load_factor() == 0);
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(initializer_list<value_type> il);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
C c = {
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
assert(c.bucket_count() >= 5);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >()));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#endif
}

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(initializer_list<value_type> il, size_type n);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
C c({
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
},
7
);
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >()));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#endif
}

View File

@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
C c({
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
},
7,
test_hash<std::hash<int> >(8)
);
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >()));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#endif
}

View File

@@ -0,0 +1,66 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(initializer_list<value_type> il, size_type n,
// const hasher& hf, const key_equal& eql);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
C c({
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
},
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9)
);
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >()));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#endif
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(initializer_list<value_type> il, size_type n,
// const hasher& hf, const key_equal& eql, const allocator_type& a);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
C c({
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
},
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >(10)));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#endif
}

View File

@@ -0,0 +1,107 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(unordered_map&& u);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
C c = std::move(c0);
assert(c.bucket_count() == 7);
assert(c.size() == 0);
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >(10)));
assert(c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == 0);
assert(c.max_load_factor() == 1);
assert(c0.empty());
}
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
C c = std::move(c0);
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >(10)));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c0.empty());
}
#endif
}

View File

@@ -0,0 +1,112 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(unordered_map&& u, const allocator_type& a);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::pair<int, std::string> P;
typedef test_allocator<std::pair<const int, std::string>> A;
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(std::move(c0), A(12));
assert(c.bucket_count() >= 5);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() == A(12));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c0.empty());
}
{
typedef std::pair<int, std::string> P;
typedef test_allocator<std::pair<const int, std::string>> A;
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(std::move(c0), A(10));
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() == A(10));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c0.empty());
}
#endif
}

View File

@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// template <class InputIterator>
// unordered_map(InputIterator first, InputIterator last);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
assert(c.bucket_count() >= 5);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >()));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,66 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// template <class InputIterator>
// unordered_map(InputIterator first, InputIterator last, size_type n);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
10
);
assert(c.bucket_count() == 11);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >()));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,68 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// template <class InputIterator>
// unordered_map(InputIterator first, InputIterator last, size_type n,
// const hasher& hf);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
7,
test_hash<std::hash<int> >(8)
);
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >()));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// template <class InputIterator>
// unordered_map(InputIterator first, InputIterator last, size_type n,
// const hasher& hf, const key_equal& eql);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9)
);
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >()));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// template <class InputIterator>
// unordered_map(InputIterator first, InputIterator last, size_type n,
// const hasher& hf, const key_equal& eql,
// const allocator_type& a);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
assert(c.bucket_count() == 7);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >(10)));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(size_type n);
#include <unordered_map>
#include <cassert>
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<NotConstructible, NotConstructible,
test_hash<std::hash<NotConstructible> >,
test_compare<std::equal_to<NotConstructible> >,
test_allocator<std::pair<const NotConstructible,
NotConstructible> >
> C;
C c = 7;
assert(c.bucket_count() == 7);
assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
assert(c.size() == 0);
assert(c.empty());
assert(std::distance(c.begin(), c.end()) == 0);
assert(c.load_factor() == 0);
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(size_type n);
#include <unordered_map>
#include <cassert>
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<NotConstructible, NotConstructible,
test_hash<std::hash<NotConstructible> >,
test_compare<std::equal_to<NotConstructible> >,
test_allocator<std::pair<const NotConstructible,
NotConstructible> >
> C;
C c(7);
assert(c.bucket_count() == 7);
assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
assert(c.size() == 0);
assert(c.empty());
assert(std::distance(c.begin(), c.end()) == 0);
assert(c.load_factor() == 0);
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(size_type n, const hasher& hf);
#include <unordered_map>
#include <cassert>
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<NotConstructible, NotConstructible,
test_hash<std::hash<NotConstructible> >,
test_compare<std::equal_to<NotConstructible> >,
test_allocator<std::pair<const NotConstructible,
NotConstructible> >
> C;
C c(7,
test_hash<std::hash<NotConstructible> >(8)
);
assert(c.bucket_count() == 7);
assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
assert(c.size() == 0);
assert(c.empty());
assert(std::distance(c.begin(), c.end()) == 0);
assert(c.load_factor() == 0);
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(size_type n, const hasher& hf, const key_equal& eql);
#include <unordered_map>
#include <cassert>
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<NotConstructible, NotConstructible,
test_hash<std::hash<NotConstructible> >,
test_compare<std::equal_to<NotConstructible> >,
test_allocator<std::pair<const NotConstructible,
NotConstructible> >
> C;
C c(7,
test_hash<std::hash<NotConstructible> >(8),
test_compare<std::equal_to<NotConstructible> >(9)
);
assert(c.bucket_count() == 7);
assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
assert(c.size() == 0);
assert(c.empty());
assert(std::distance(c.begin(), c.end()) == 0);
assert(c.load_factor() == 0);
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// unordered_map(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
#include <unordered_map>
#include <cassert>
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_map<NotConstructible, NotConstructible,
test_hash<std::hash<NotConstructible> >,
test_compare<std::equal_to<NotConstructible> >,
test_allocator<std::pair<const NotConstructible,
NotConstructible> >
> C;
C c(7,
test_hash<std::hash<NotConstructible> >(8),
test_compare<std::equal_to<NotConstructible> >(9),
test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
);
assert(c.bucket_count() == 7);
assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
assert(c.size() == 0);
assert(c.empty());
assert(std::distance(c.begin(), c.end()) == 0);
assert(c.load_factor() == 0);
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,78 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// mapped_type& at(const key_type& k);
// const mapped_type& at(const key_type& k) const;
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.size() == 4);
c.at(1) = "ONE";
assert(c.at(1) == "ONE");
try
{
c.at(11) = "eleven";
assert(false);
}
catch (std::out_of_range&)
{
}
assert(c.size() == 4);
}
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.size() == 4);
assert(c.at(1) == "one");
try
{
c.at(11);
assert(false);
}
catch (std::out_of_range&)
{
}
assert(c.size() == 4);
}
}

View File

@@ -0,0 +1,68 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// mapped_type& operator[](const key_type& k);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.size() == 4);
c[1] = "ONE";
assert(c.at(1) == "ONE");
c[11] = "eleven";
assert(c.size() == 5);
assert(c.at(11) == "eleven");
}
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<MoveOnly, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.size() == 4);
c[1] = "ONE";
assert(c.at(1) == "ONE");
c[11] = "eleven";
assert(c.size() == 5);
assert(c.at(11) == "eleven");
}
#endif
}

View File

@@ -0,0 +1,389 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// void swap(unordered_map& __u);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
swap(c1, c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
swap(c1, c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.at(10) == "ten");
assert(c1.at(20) == "twenty");
assert(c1.at(30) == "thirty");
assert(c1.at(40) == "fourty");
assert(c1.at(50) == "fifty");
assert(c1.at(60) == "sixty");
assert(c1.at(70) == "seventy");
assert(c1.at(80) == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
swap(c1, c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 5);
assert(c2.size() == 4);
assert(c2.at(1) == "one");
assert(c2.at(2) == "two");
assert(c2.at(3) == "three");
assert(c2.at(4) == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
swap(c1, c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.at(10) == "ten");
assert(c1.at(20) == "twenty");
assert(c1.at(30) == "thirty");
assert(c1.at(40) == "fourty");
assert(c1.at(50) == "fifty");
assert(c1.at(60) == "sixty");
assert(c1.at(70) == "seventy");
assert(c1.at(80) == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 5);
assert(c2.size() == 4);
assert(c2.at(1) == "one");
assert(c2.at(2) == "two");
assert(c2.at(3) == "three");
assert(c2.at(4) == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
swap(c1, c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
swap(c1, c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.at(10) == "ten");
assert(c1.at(20) == "twenty");
assert(c1.at(30) == "thirty");
assert(c1.at(40) == "fourty");
assert(c1.at(50) == "fifty");
assert(c1.at(60) == "sixty");
assert(c1.at(70) == "seventy");
assert(c1.at(80) == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
swap(c1, c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 5);
assert(c2.size() == 4);
assert(c2.at(1) == "one");
assert(c2.at(2) == "two");
assert(c2.at(3) == "three");
assert(c2.at(4) == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
swap(c1, c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.at(10) == "ten");
assert(c1.at(20) == "twenty");
assert(c1.at(30) == "thirty");
assert(c1.at(40) == "fourty");
assert(c1.at(50) == "fifty");
assert(c1.at(60) == "sixty");
assert(c1.at(70) == "seventy");
assert(c1.at(80) == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 5);
assert(c2.size() == 4);
assert(c2.at(1) == "one");
assert(c2.at(2) == "two");
assert(c2.at(3) == "three");
assert(c2.at(4) == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// void clear()
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
c.clear();
assert(c.size() == 0);
}
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// template <class... Args>
// pair<iterator, bool> emplace(Args&&... args);
#include <unordered_map>
#include <cassert>
#include "../../../Emplaceable.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<int, Emplaceable> C;
typedef std::pair<C::iterator, bool> R;
C c;
R r = c.emplace(3);
assert(r.second);
assert(c.size() == 1);
assert(r.first->first == 3);
assert(r.first->second == Emplaceable());
r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
assert(r.second);
assert(c.size() == 2);
assert(r.first->first == 4);
assert(r.first->second == Emplaceable(5, 6));
r = c.emplace(5, 6, 7);
assert(r.second);
assert(c.size() == 3);
assert(r.first->first == 5);
assert(r.first->second == Emplaceable(6, 7));
}
#endif
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// template <class... Args>
// iterator emplace_hint(const_iterator p, Args&&... args);
#include <unordered_map>
#include <cassert>
#include "../../../Emplaceable.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<int, Emplaceable> C;
typedef C::iterator R;
C c;
C::const_iterator e = c.end();
R r = c.emplace_hint(e, 3);
assert(c.size() == 1);
assert(r->first == 3);
assert(r->second == Emplaceable());
r = c.emplace_hint(e, std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
assert(c.size() == 2);
assert(r->first == 4);
assert(r->second == Emplaceable(5, 6));
r = c.emplace_hint(e, 5, 6, 7);
assert(c.size() == 3);
assert(r->first == 5);
assert(r->second == Emplaceable(6, 7));
}
#endif
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// iterator erase(const_iterator p)
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
C::const_iterator i = c.find(2);
C::iterator j = c.erase(i);
assert(c.size() == 3);
assert(c.at(1) == "one");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
}
}

View File

@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// size_type erase(const key_type& k);
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.erase(5) == 0);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.erase(2) == 1);
assert(c.size() == 3);
assert(c.at(1) == "one");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.erase(2) == 0);
assert(c.size() == 3);
assert(c.at(1) == "one");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
assert(c.erase(4) == 1);
assert(c.size() == 2);
assert(c.at(1) == "one");
assert(c.at(3) == "three");
assert(c.erase(4) == 0);
assert(c.size() == 2);
assert(c.at(1) == "one");
assert(c.at(3) == "three");
assert(c.erase(1) == 1);
assert(c.size() == 1);
assert(c.at(3) == "three");
assert(c.erase(1) == 0);
assert(c.size() == 1);
assert(c.at(3) == "three");
assert(c.erase(3) == 1);
assert(c.size() == 0);
assert(c.erase(3) == 0);
assert(c.size() == 0);
}
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// iterator erase(const_iterator first, const_iterator last)
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
C::const_iterator i = c.find(2);
C::const_iterator j = next(i, 1);
C::iterator k = c.erase(i, i);
assert(k == i);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
k = c.erase(i, j);
assert(c.size() == 3);
assert(k == j);
assert(c.at(1) == "one");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
k = c.erase(c.cbegin(), c.cend());
assert(k == c.cend());
assert(c.size() == 0);
assert(k == c.end());
}
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// pair<iterator, bool> insert(const value_type& x);
#include <unordered_map>
#include <cassert>
int main()
{
{
typedef std::unordered_map<double, int> C;
typedef std::pair<C::iterator, bool> R;
typedef C::value_type P;
C c;
R r = c.insert(P(3.5, 3));
assert(r.second);
assert(c.size() == 1);
assert(r.first->first == 3.5);
assert(r.first->second == 3);
r = c.insert(P(3.5, 4));
assert(!r.second);
assert(c.size() == 1);
assert(r.first->first == 3.5);
assert(r.first->second == 3);
r = c.insert(P(4.5, 4));
assert(r.second);
assert(c.size() == 2);
assert(r.first->first == 4.5);
assert(r.first->second == 4);
r = c.insert(P(5.5, 4));
assert(r.second);
assert(c.size() == 3);
assert(r.first->first == 5.5);
assert(r.first->second == 4);
}
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// iterator insert(const_iterator p, const value_type& x);
#include <unordered_map>
#include <cassert>
int main()
{
{
typedef std::unordered_map<double, int> C;
typedef C::iterator R;
typedef C::value_type P;
C c;
C::const_iterator e = c.end();
R r = c.insert(e, P(3.5, 3));
assert(c.size() == 1);
assert(r->first == 3.5);
assert(r->second == 3);
r = c.insert(e, P(3.5, 4));
assert(c.size() == 1);
assert(r->first == 3.5);
assert(r->second == 3);
r = c.insert(e, P(4.5, 4));
assert(c.size() == 2);
assert(r->first == 4.5);
assert(r->second == 4);
r = c.insert(e, P(5.5, 4));
assert(c.size() == 3);
assert(r->first == 5.5);
assert(r->second == 4);
}
}

View File

@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// template <class P,
// class = typename enable_if<is_convertible<P, value_type>::value>::type>
// iterator insert(const_iterator p, P&& x);
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
{
typedef std::unordered_map<double, int> C;
typedef C::iterator R;
typedef std::pair<double, short> P;
C c;
C::const_iterator e = c.end();
R r = c.insert(e, P(3.5, 3));
assert(c.size() == 1);
assert(r->first == 3.5);
assert(r->second == 3);
r = c.insert(e, P(3.5, 4));
assert(c.size() == 1);
assert(r->first == 3.5);
assert(r->second == 3);
r = c.insert(e, P(4.5, 4));
assert(c.size() == 2);
assert(r->first == 4.5);
assert(r->second == 4);
r = c.insert(e, P(5.5, 4));
assert(c.size() == 3);
assert(r->first == 5.5);
assert(r->second == 4);
}
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<MoveOnly, MoveOnly> C;
typedef C::iterator R;
typedef std::pair<MoveOnly, MoveOnly> P;
C c;
C::const_iterator e = c.end();
R r = c.insert(e, P(3, 3));
assert(c.size() == 1);
assert(r->first == 3);
assert(r->second == 3);
r = c.insert(e, P(3, 4));
assert(c.size() == 1);
assert(r->first == 3);
assert(r->second == 3);
r = c.insert(e, P(4, 4));
assert(c.size() == 2);
assert(r->first == 4);
assert(r->second == 4);
r = c.insert(e, P(5, 4));
assert(c.size() == 3);
assert(r->first == 5);
assert(r->second == 4);
}
#endif
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// void insert(initializer_list<value_type> il);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
C c;
c.insert(
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
}
);
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
}
#endif
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// template <class InputIterator>
// void insert(InputIterator first, InputIterator last);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
int main()
{
{
typedef std::unordered_map<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c;
c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
assert(c.size() == 4);
assert(c.at(1) == "one");
assert(c.at(2) == "two");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
}
}

View File

@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_map
// template <class P,
// class = typename enable_if<is_convertible<P, value_type>::value>::type>
// pair<iterator, bool> insert(P&& x);
#include <unordered_map>
#include <cassert>
#include "../../../MoveOnly.h"
int main()
{
{
typedef std::unordered_map<double, int> C;
typedef std::pair<C::iterator, bool> R;
typedef std::pair<double, short> P;
C c;
R r = c.insert(P(3.5, 3));
assert(r.second);
assert(c.size() == 1);
assert(r.first->first == 3.5);
assert(r.first->second == 3);
r = c.insert(P(3.5, 4));
assert(!r.second);
assert(c.size() == 1);
assert(r.first->first == 3.5);
assert(r.first->second == 3);
r = c.insert(P(4.5, 4));
assert(r.second);
assert(c.size() == 2);
assert(r.first->first == 4.5);
assert(r.first->second == 4);
r = c.insert(P(5.5, 4));
assert(r.second);
assert(c.size() == 3);
assert(r.first->first == 5.5);
assert(r.first->second == 4);
}
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_map<MoveOnly, MoveOnly> C;
typedef std::pair<C::iterator, bool> R;
typedef std::pair<MoveOnly, MoveOnly> P;
C c;
R r = c.insert(P(3, 3));
assert(r.second);
assert(c.size() == 1);
assert(r.first->first == 3);
assert(r.first->second == 3);
r = c.insert(P(3, 4));
assert(!r.second);
assert(c.size() == 1);
assert(r.first->first == 3);
assert(r.first->second == 3);
r = c.insert(P(4, 4));
assert(r.second);
assert(c.size() == 2);
assert(r.first->first == 4);
assert(r.first->second == 4);
r = c.insert(P(5, 4));
assert(r.second);
assert(c.size() == 3);
assert(r.first->first == 5);
assert(r.first->second == 4);
}
#endif
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
#include <unordered_map>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// size_type bucket(const key_type& __k) const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(std::begin(a), std::end(a));
size_t bc = c.bucket_count();
assert(bc >= 7);
for (size_t i = 0; i < 13; ++i)
assert(c.bucket(i) == i % bc);
}
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// size_type bucket_count() const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef C::const_iterator I;
typedef std::pair<int, std::string> P;
const C c;
assert(c.bucket_count() == 0);
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef C::const_iterator I;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c(std::begin(a), std::end(a));
assert(c.bucket_count() >= 11);
}
}

View File

@@ -0,0 +1,46 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// size_type bucket_size(size_type n) const
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(std::begin(a), std::end(a));
assert(c.bucket_count() >= 7);
assert(c.bucket_size(0) == 0);
assert(c.bucket_size(1) == 2);
assert(c.bucket_size(2) == 2);
assert(c.bucket_size(3) == 1);
assert(c.bucket_size(4) == 1);
assert(c.bucket_size(5) == 0);
assert(c.bucket_size(6) == 0);
}
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// size_type count(const key_type& k) const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(50, "fiftyA"),
P(50, "fiftyB"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c(std::begin(a), std::end(a));
assert(c.count(30) == 1);
assert(c.count(50) == 3);
assert(c.count(5) == 0);
}
}

View File

@@ -0,0 +1,101 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash, class Pred, class Alloc>
// bool
// operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
// const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
//
// template <class Key, class T, class Hash, class Pred, class Alloc>
// bool
// operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
// const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(20, "twenty 2"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(50, "fifty 2"),
P(50, "fifty 3"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c1(std::begin(a), std::end(a));
const C c2;
assert(!(c1 == c2));
assert( (c1 != c2));
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(20, "twenty 2"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(50, "fifty 2"),
P(50, "fifty 3"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c1(std::begin(a), std::end(a));
const C c2 = c1;
assert( (c1 == c2));
assert(!(c1 != c2));
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(20, "twenty 2"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(50, "fifty 2"),
P(50, "fifty 3"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(std::begin(a), std::end(a));
C c2 = c1;
c2.rehash(30);
assert( (c1 == c2));
assert(!(c1 != c2));
c2.insert(P(90, "ninety"));
assert(!(c1 == c2));
assert( (c1 != c2));
c1.insert(P(90, "ninety"));
assert( (c1 == c2));
assert(!(c1 != c2));
}
}

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef C::const_iterator I;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(50, "fiftyA"),
P(50, "fiftyB"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c(std::begin(a), std::end(a));
std::pair<I, I> r = c.equal_range(30);
assert(std::distance(r.first, r.second) == 1);
assert(r.first->first == 30);
assert(r.first->second == "thirty");
r = c.equal_range(5);
assert(std::distance(r.first, r.second) == 0);
r = c.equal_range(50);
assert(r.first->first == 50);
assert(r.first->second == "fifty");
++r.first;
assert(r.first->first == 50);
assert(r.first->second == "fiftyA");
++r.first;
assert(r.first->first == 50);
assert(r.first->second == "fiftyB");
}
}

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// pair<iterator, iterator> equal_range(const key_type& k);
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef C::iterator I;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(50, "fiftyA"),
P(50, "fiftyB"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c(std::begin(a), std::end(a));
std::pair<I, I> r = c.equal_range(30);
assert(std::distance(r.first, r.second) == 1);
assert(r.first->first == 30);
assert(r.first->second == "thirty");
r = c.equal_range(5);
assert(std::distance(r.first, r.second) == 0);
r = c.equal_range(50);
assert(r.first->first == 50);
assert(r.first->second == "fifty");
++r.first;
assert(r.first->first == 50);
assert(r.first->second == "fiftyA");
++r.first;
assert(r.first->first == 50);
assert(r.first->second == "fiftyB");
}
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// const_iterator find(const key_type& k) const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c(std::begin(a), std::end(a));
C::const_iterator i = c.find(30);
assert(i->first == 30);
assert(i->second == "thirty");
i = c.find(5);
assert(i == c.cend());
}
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// iterator find(const key_type& k);
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c(std::begin(a), std::end(a));
C::iterator i = c.find(30);
assert(i->first == 30);
assert(i->second == "thirty");
i = c.find(5);
assert(i == c.end());
}
}

View File

@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// iterator begin() {return __table_.begin();}
// iterator end() {return __table_.end();}
// const_iterator begin() const {return __table_.begin();}
// const_iterator end() const {return __table_.end();}
// const_iterator cbegin() const {return __table_.begin();}
// const_iterator cend() const {return __table_.end();}
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() == 7);
assert(c.size() == 6);
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
C::iterator i = c.begin();
i->second = "ONE";
assert(i->second == "ONE");
i->first = 2;
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() == 7);
assert(c.size() == 6);
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
}
}

View File

@@ -0,0 +1,68 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// iterator begin() {return __table_.begin();}
// iterator end() {return __table_.end();}
// const_iterator begin() const {return __table_.begin();}
// const_iterator end() const {return __table_.end();}
// const_iterator cbegin() const {return __table_.begin();}
// const_iterator cend() const {return __table_.end();}
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 7);
assert(c.size() == 6);
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
C::iterator i = c.begin();
i->second = "ONE";
assert(i->second == "ONE");
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 7);
assert(c.size() == 6);
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
}
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// float load_factor() const
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
const C c(std::begin(a), std::end(a));
assert(c.load_factor() == (float)c.size() / c.bucket_count());
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
const C c;
assert(c.load_factor() == 0);
}
}

View File

@@ -0,0 +1,286 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// local_iterator begin (size_type n);
// local_iterator end (size_type n);
// const_local_iterator begin (size_type n) const;
// const_local_iterator end (size_type n) const;
// const_local_iterator cbegin(size_type n) const;
// const_local_iterator cend (size_type n) const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() == 7);
C::size_type b = c.bucket(0);
I i = c.begin(b);
I j = c.end(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
i->first = 2;
b = c.bucket(2);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
b = c.bucket(3);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
b = c.bucket(5);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 0);
b = c.bucket(6);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 0);
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::const_local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() == 7);
C::size_type b = c.bucket(0);
I i = c.begin(b);
I j = c.end(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
b = c.bucket(2);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
b = c.bucket(3);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
b = c.bucket(5);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 0);
b = c.bucket(6);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 0);
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::const_local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() == 7);
C::size_type b = c.bucket(0);
I i = c.cbegin(b);
I j = c.cend(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
b = c.bucket(2);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
b = c.bucket(3);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
b = c.bucket(5);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 0);
b = c.bucket(6);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 0);
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::const_local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() == 7);
C::size_type b = c.bucket(0);
I i = c.cbegin(b);
I j = c.cend(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
b = c.bucket(2);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
b = c.bucket(3);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
b = c.bucket(5);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 0);
b = c.bucket(6);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 0);
}
}

View File

@@ -0,0 +1,285 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// local_iterator begin (size_type n);
// local_iterator end (size_type n);
// const_local_iterator begin (size_type n) const;
// const_local_iterator end (size_type n) const;
// const_local_iterator cbegin(size_type n) const;
// const_local_iterator cend (size_type n) const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 7);
C::size_type b = c.bucket(0);
I i = c.begin(b);
I j = c.end(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
b = c.bucket(2);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
b = c.bucket(3);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
b = c.bucket(5);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 0);
b = c.bucket(6);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 0);
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::const_local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 7);
C::size_type b = c.bucket(0);
I i = c.begin(b);
I j = c.end(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
b = c.bucket(2);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 2);
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
b = c.bucket(3);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
b = c.bucket(5);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 0);
b = c.bucket(6);
i = c.begin(b);
j = c.end(b);
assert(std::distance(i, j) == 0);
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::const_local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 7);
C::size_type b = c.bucket(0);
I i = c.cbegin(b);
I j = c.cend(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
b = c.bucket(2);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
b = c.bucket(3);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
b = c.bucket(5);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 0);
b = c.bucket(6);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 0);
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
typedef C::const_local_iterator I;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
const C c(a, a + sizeof(a)/sizeof(a[0]));
assert(c.bucket_count() >= 7);
C::size_type b = c.bucket(0);
I i = c.cbegin(b);
I j = c.cend(b);
assert(std::distance(i, j) == 0);
b = c.bucket(1);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
b = c.bucket(2);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 2);
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
b = c.bucket(3);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 3);
assert(i->second == "three");
b = c.bucket(4);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 1);
assert(i->first == 4);
assert(i->second == "four");
b = c.bucket(5);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 0);
b = c.bucket(6);
i = c.cbegin(b);
j = c.cend(b);
assert(std::distance(i, j) == 0);
}
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// size_type max_bucket_count() const;
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef C::const_iterator I;
typedef std::pair<int, std::string> P;
const C c;
assert(c.max_bucket_count() > 0);
}
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// float max_load_factor() const;
// void max_load_factor(float mlf);
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
const C c;
assert(c.max_load_factor() == 1);
}
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
C c;
assert(c.max_load_factor() == 1);
c.max_load_factor(2.5);
assert(c.max_load_factor() == 2.5);
}
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// size_type max_size() const;
#include <unordered_map>
#include <cassert>
int main()
{
{
std::unordered_multimap<int, int> u;
assert(u.max_size() > 0);
}
}

View File

@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// void rehash(size_type n);
#include <unordered_map>
#include <string>
#include <cassert>
void test(const std::unordered_multimap<int, std::string>& c)
{
typedef std::unordered_multimap<int, std::string> C;
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
}
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
test(c);
assert(c.bucket_count() >= 7);
c.rehash(3);
assert(c.bucket_count() == 7);
test(c);
c.max_load_factor(2);
c.rehash(3);
assert(c.bucket_count() == 3);
test(c);
c.rehash(31);
assert(c.bucket_count() == 31);
test(c);
}
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// void rehash(size_type n);
#include <unordered_map>
#include <string>
#include <cassert>
void test(const std::unordered_multimap<int, std::string>& c)
{
assert(c.size() == 6);
assert(c.find(1)->second == "one");
assert(next(c.find(1))->second == "four");
assert(c.find(2)->second == "two");
assert(next(c.find(2))->second == "four");
assert(c.find(3)->second == "three");
assert(c.find(4)->second == "four");
}
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(a, a + sizeof(a)/sizeof(a[0]));
test(c);
assert(c.bucket_count() >= 7);
c.reserve(3);
assert(c.bucket_count() == 7);
test(c);
c.max_load_factor(2);
c.reserve(3);
assert(c.bucket_count() == 3);
test(c);
c.reserve(31);
assert(c.bucket_count() == 17);
test(c);
}
}

View File

@@ -0,0 +1,397 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// void swap(unordered_multimap& __u);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../test_compare.h"
#include "../../test_hash.h"
#include "../../test_allocator.h"
int main()
{
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.find(10)->second == "ten");
assert(c1.find(20)->second == "twenty");
assert(c1.find(30)->second == "thirty");
assert(c1.find(40)->second == "fourty");
assert(c1.find(50)->second == "fifty");
assert(c1.find(60)->second == "sixty");
assert(c1.find(70)->second == "seventy");
assert(c1.find(80)->second == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 7);
assert(c2.size() == 6);
assert(c2.find(1)->second == "one");
assert(next(c2.find(1))->second == "four");
assert(c2.find(2)->second == "two");
assert(next(c2.find(2))->second == "four");
assert(c2.find(3)->second == "three");
assert(c2.find(4)->second == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.find(10)->second == "ten");
assert(c1.find(20)->second == "twenty");
assert(c1.find(30)->second == "thirty");
assert(c1.find(40)->second == "fourty");
assert(c1.find(50)->second == "fifty");
assert(c1.find(60)->second == "sixty");
assert(c1.find(70)->second == "seventy");
assert(c1.find(80)->second == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(1));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 7);
assert(c2.size() == 6);
assert(c2.find(1)->second == "one");
assert(next(c2.find(1))->second == "four");
assert(c2.find(2)->second == "two");
assert(next(c2.find(2))->second == "four");
assert(c2.find(3)->second == "three");
assert(c2.find(4)->second == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(2));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.find(10)->second == "ten");
assert(c1.find(20)->second == "twenty");
assert(c1.find(30)->second == "thirty");
assert(c1.find(40)->second == "fourty");
assert(c1.find(50)->second == "fifty");
assert(c1.find(60)->second == "sixty");
assert(c1.find(70)->second == "seventy");
assert(c1.find(80)->second == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() == 0);
assert(c2.size() == 0);
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() == 0);
assert(c1.size() == 0);
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 7);
assert(c2.size() == 6);
assert(c2.find(1)->second == "one");
assert(next(c2.find(1))->second == "four");
assert(c2.find(2)->second == "two");
assert(next(c2.find(2))->second == "four");
assert(c2.find(3)->second == "three");
assert(c2.find(4)->second == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "fourty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
c1.swap(c2);
assert(c1.bucket_count() >= 11);
assert(c1.size() == 8);
assert(c1.find(10)->second == "ten");
assert(c1.find(20)->second == "twenty");
assert(c1.find(30)->second == "thirty");
assert(c1.find(40)->second == "fourty");
assert(c1.find(50)->second == "fifty");
assert(c1.find(60)->second == "sixty");
assert(c1.find(70)->second == "seventy");
assert(c1.find(80)->second == "eighty");
assert(c1.hash_function() == Hash(2));
assert(c1.key_eq() == Compare(2));
assert(c1.get_allocator() == Alloc(2));
assert(std::distance(c1.begin(), c1.end()) == c1.size());
assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
assert(c1.max_load_factor() == 2);
assert(c2.bucket_count() >= 7);
assert(c2.size() == 6);
assert(c2.find(1)->second == "one");
assert(next(c2.find(1))->second == "four");
assert(c2.find(2)->second == "two");
assert(next(c2.find(2))->second == "four");
assert(c2.find(3)->second == "three");
assert(c2.find(4)->second == "four");
assert(c2.hash_function() == Hash(1));
assert(c2.key_eq() == Compare(1));
assert(c2.get_allocator() == Alloc(1));
assert(std::distance(c2.begin(), c2.end()) == c2.size());
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// {
// public:
// // types
// typedef Key key_type;
// typedef T mapped_type;
// typedef Hash hasher;
// typedef Pred key_equal;
// typedef Alloc allocator_type;
// typedef pair<const key_type, mapped_type> value_type;
// typedef value_type& reference;
// typedef const value_type& const_reference;
// typedef typename allocator_traits<allocator_type>::pointer pointer;
// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
// typedef typename allocator_traits<allocator_type>::size_type size_type;
// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
#include <unordered_map>
#include <type_traits>
int main()
{
{
typedef std::unordered_multimap<char, short> C;
static_assert((std::is_same<C::key_type, char>::value), "");
static_assert((std::is_same<C::mapped_type, short>::value), "");
static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
static_assert((std::is_same<C::reference, C::value_type&>::value), "");
static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// explicit unordered_multimap(const allocator_type& __a);
#include <unordered_map>
#include <cassert>
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_multimap<NotConstructible, NotConstructible,
test_hash<std::hash<NotConstructible> >,
test_compare<std::equal_to<NotConstructible> >,
test_allocator<std::pair<const NotConstructible,
NotConstructible> >
> C;
C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
assert(c.bucket_count() == 0);
assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
assert(c.size() == 0);
assert(c.empty());
assert(std::distance(c.begin(), c.end()) == 0);
assert(c.load_factor() == 0);
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,146 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap& operator=(const unordered_multimap& u);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef test_allocator<std::pair<const int, std::string> > A;
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(a, a + 2,
7,
test_hash<std::hash<int> >(2),
test_compare<std::equal_to<int> >(3),
A(4)
);
c = c0;
assert(c.bucket_count() == 7);
assert(c.size() == 6);
C::const_iterator i = c.cbegin();
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
++i;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
++i;
assert(i->first == 3);
assert(i->second == "three");
++i;
assert(i->first == 4);
assert(i->second == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() == A(4));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
{
typedef other_allocator<std::pair<const int, std::string> > A;
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(a, a + 2,
7,
test_hash<std::hash<int> >(2),
test_compare<std::equal_to<int> >(3),
A(4)
);
c = c0;
assert(c.bucket_count() >= 7);
assert(c.size() == 6);
C::const_iterator i = c.cbegin();
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
++i;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
++i;
assert(i->first == 3);
assert(i->second == "three");
++i;
assert(i->first == 4);
assert(i->second == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() == A(10));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,86 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap& operator=(initializer_list<value_type> il);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef test_allocator<std::pair<const int, std::string> > A;
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
C c = {
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
c = {
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
assert(c.bucket_count() >= 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#endif
}

View File

@@ -0,0 +1,225 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap& operator=(unordered_multimap&& u);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef test_allocator<std::pair<const int, std::string> > A;
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(a, a + 2,
7,
test_hash<std::hash<int> >(2),
test_compare<std::equal_to<int> >(3),
A(4)
);
c = std::move(c0);
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
{
typedef test_allocator<std::pair<const int, std::string> > A;
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(a, a + 2,
7,
test_hash<std::hash<int> >(2),
test_compare<std::equal_to<int> >(3),
A(10)
);
c = std::move(c0);
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
{
typedef other_allocator<std::pair<const int, std::string> > A;
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(a, a + 2,
7,
test_hash<std::hash<int> >(2),
test_compare<std::equal_to<int> >(3),
A(4)
);
c = std::move(c0);
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#endif
}

View File

@@ -0,0 +1,136 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap(const unordered_multimap& u);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
C c = c0;
assert(c.bucket_count() == 7);
assert(c.size() == 6);
C::const_iterator i = c.cbegin();
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
++i;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
++i;
assert(i->first == 3);
assert(i->second == "three");
++i;
assert(i->first == 4);
assert(i->second == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >(10)));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
other_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
other_allocator<std::pair<const int, std::string> >(10)
);
C c = c0;
assert(c.bucket_count() == 7);
assert(c.size() == 6);
C::const_iterator i = c.cbegin();
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
++i;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
++i;
assert(i->first == 3);
assert(i->second == "three");
++i;
assert(i->first == 4);
assert(i->second == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(other_allocator<std::pair<const int, std::string> >(-2)));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
#endif
}

View File

@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap(const unordered_multimap& u, const allocator_type& a);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
C c(c0, test_allocator<std::pair<const int, std::string> >(5));
assert(c.bucket_count() == 7);
assert(c.size() == 6);
C::const_iterator i = c.cbegin();
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
++i;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
++i;
assert(i->first == 3);
assert(i->second == "three");
++i;
assert(i->first == 4);
assert(i->second == "four");
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >(5)));
assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap();
#include <unordered_map>
#include <cassert>
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_multimap<NotConstructible, NotConstructible,
test_hash<std::hash<NotConstructible> >,
test_compare<std::equal_to<NotConstructible> >,
test_allocator<std::pair<const NotConstructible,
NotConstructible> >
> C;
C c;
assert(c.bucket_count() == 0);
assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
assert(c.get_allocator() ==
(test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
assert(c.size() == 0);
assert(c.empty());
assert(std::distance(c.begin(), c.end()) == 0);
assert(c.load_factor() == 0);
assert(c.max_load_factor() == 1);
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap(initializer_list<value_type> il);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
C c = {
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
assert(c.bucket_count() >= 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
}
#endif
}

View File

@@ -0,0 +1,85 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap(initializer_list<value_type> il, size_type n);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
C c({
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
},
7
);
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
}
#endif
}

View File

@@ -0,0 +1,86 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
C c({
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
},
7,
test_hash<std::hash<int> >(8)
);
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
}
#endif
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap(initializer_list<value_type> il, size_type n,
// const hasher& hf, const key_equal& eql);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
C c({
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
},
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9)
);
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
}
#endif
}

View File

@@ -0,0 +1,89 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap(initializer_list<value_type> il, size_type n,
// const hasher& hf, const key_equal& eql, const allocator_type& a);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
C c({
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
},
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
}
#endif
}

View File

@@ -0,0 +1,129 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap(unordered_multimap&& u);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
C c = std::move(c0);
assert(c.bucket_count() == 7);
assert(c.size() == 0);
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert(c.get_allocator() ==
(test_allocator<std::pair<const int, std::string> >(10)));
assert(c.empty());
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == 0);
assert(c.max_load_factor() == 1);
assert(c0.empty());
}
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
C c = std::move(c0);
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
assert(c0.empty());
}
#endif
}

View File

@@ -0,0 +1,160 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// unordered_multimap(unordered_multimap&& u, const allocator_type& a);
#include <iostream>
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
typedef std::pair<int, std::string> P;
typedef test_allocator<std::pair<const int, std::string>> A;
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(std::move(c0), A(12));
assert(c.bucket_count() >= 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(12)));
assert(c0.empty());
}
{
typedef std::pair<int, std::string> P;
typedef test_allocator<std::pair<const int, std::string>> A;
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
A
> C;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c0(a, a + sizeof(a)/sizeof(a[0]),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
A(10)
);
C c(std::move(c0), A(10));
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
assert(c0.empty());
}
#endif
}

View File

@@ -0,0 +1,86 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// template <class InputIterator>
// unordered_multimap(InputIterator first, InputIterator last);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
assert(c.bucket_count() >= 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
}
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// template <class InputIterator>
// unordered_multimap(InputIterator first, InputIterator last, size_type n);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
10
);
assert(c.bucket_count() == 11);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
}
}

View File

@@ -0,0 +1,90 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// template <class InputIterator>
// unordered_multimap(InputIterator first, InputIterator last, size_type n,
// const hasher& hf);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
7,
test_hash<std::hash<int> >(8)
);
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >());
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
}
}

View File

@@ -0,0 +1,91 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// template <class InputIterator>
// unordered_multimap(InputIterator first, InputIterator last, size_type n,
// const hasher& hf, const key_equal& eql);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9)
);
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
}
}

View File

@@ -0,0 +1,93 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
// class Alloc = allocator<pair<const Key, T>>>
// class unordered_multimap
// template <class InputIterator>
// unordered_multimap(InputIterator first, InputIterator last, size_type n,
// const hasher& hf, const key_equal& eql,
// const allocator_type& a);
#include <unordered_map>
#include <string>
#include <cassert>
#include "../../../iterators.h"
#include "../../../NotConstructible.h"
#include "../../../test_compare.h"
#include "../../../test_hash.h"
#include "../../../test_allocator.h"
int main()
{
{
typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
typedef std::pair<int, std::string> P;
P a[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
test_allocator<std::pair<const int, std::string> >(10)
);
assert(c.bucket_count() == 7);
assert(c.size() == 6);
typedef std::pair<C::const_iterator, C::const_iterator> Eq;
Eq eq = c.equal_range(1);
assert(std::distance(eq.first, eq.second) == 2);
C::const_iterator i = eq.first;
assert(i->first == 1);
assert(i->second == "one");
++i;
assert(i->first == 1);
assert(i->second == "four");
eq = c.equal_range(2);
assert(std::distance(eq.first, eq.second) == 2);
i = eq.first;
assert(i->first == 2);
assert(i->second == "two");
++i;
assert(i->first == 2);
assert(i->second == "four");
eq = c.equal_range(3);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 3);
assert(i->second == "three");
eq = c.equal_range(4);
assert(std::distance(eq.first, eq.second) == 1);
i = eq.first;
assert(i->first == 4);
assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count());
assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
}
}

Some files were not shown because too many files have changed in this diff Show More