int main() { { typedef std::unordered_set<int> C; typedef int P; P a[] = { P(10), P(20), P(30), P(40), P(50), P(60), P(70), P(80) }; const C c(std::begin(a), std::end(a)); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_set<int> C; typedef int P; const C c; assert(c.load_factor() == 0); } #if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; P a[] = { P(10), P(20), P(30), P(40), P(50), P(60), P(70), P(80) }; const C c(std::begin(a), std::end(a)); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; const C c; assert(c.load_factor() == 0); } #endif }
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(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_multimap<int, std::string> C; typedef std::pair<int, std::string> P; const C c; assert(c.load_factor() == 0); } #if __cplusplus >= 201103L { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const 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(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; typedef std::pair<int, std::string> P; const C c; assert(c.load_factor() == 0); } #endif }
int main(int, char**) { { 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, "forty"), P(50, "fifty"), P(60, "sixty"), P(70, "seventy"), P(80, "eighty"), }; const C c(std::begin(a), std::end(a)); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_map<int, std::string> C; const C c; assert(c.load_factor() == 0); } #if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; typedef std::pair<int, std::string> P; P a[] = { P(10, "ten"), P(20, "twenty"), P(30, "thirty"), P(40, "forty"), P(50, "fifty"), P(60, "sixty"), P(70, "seventy"), P(80, "eighty"), }; const C c(std::begin(a), std::end(a)); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; const C c; assert(c.load_factor() == 0); } #endif return 0; }
int main() { { typedef std::unordered_multiset<int> C; typedef int P; P a[] = { P(10), P(20), P(30), P(40), P(50), P(60), P(70), P(80) }; const C c(std::begin(a), std::end(a)); assert(c.load_factor() == (float)c.size() / c.bucket_count()); } { typedef std::unordered_multiset<int> C; typedef int P; const C c; assert(c.load_factor() == 0); } }
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(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_map<int, std::string> C; typedef std::pair<int, std::string> P; const C c; assert(c.load_factor() == 0); } }