Lines Matching full:map
175 PetscErrorCode view_map(const map_type &map) const noexcept in view_map()
181 PetscCallCXX(oss << "map: '" << this->map_name << "'\n"); in view_map()
182 PetscCallCXX(oss << " size: " << map.size() << '\n'); in view_map()
183 PetscCallCXX(oss << " capacity: " << map.capacity() << '\n'); in view_map()
184 PetscCallCXX(oss << " bucket count: " << map.bucket_count() << '\n'); in view_map()
185 PetscCallCXX(oss << " empty: " << map.empty() << '\n'); in view_map()
189 …for (auto &&entry : map) PetscCallCXX(oss << " key: [" << this->key_printer(entry.first) << "] … in view_map()
203 PetscErrorCode check_size_capacity_coherent(map_type &map) const noexcept in check_size_capacity_coherent()
205 const auto msize = map.size(); in check_size_capacity_coherent()
206 const auto mcap = map.capacity(); in check_size_capacity_coherent()
209 …map, msize == map.size(), PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map size appears to change each time i… in check_size_capacity_coherent()
210 …map, mcap == map.capacity(), PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map capacity appears to change each… in check_size_capacity_coherent()
211 MapCheck(map, msize >= 0, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map size %zu unexpected!", msize); in check_size_capacity_coherent()
212 MapCheck(map, mcap >= 0, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map capacity %zu unexpected!", mcap); in check_size_capacity_coherent()
213 …MapCheck(map, mcap >= msize, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map capacity %zu < map size %zu!", … in check_size_capacity_coherent()
217 …PetscErrorCode check_size_capacity_coherent(map_type &map, std::size_t expected_size, std::size_t … in check_size_capacity_coherent() argument
220 PetscCall(check_size_capacity_coherent(map)); in check_size_capacity_coherent()
221 …MapCheck(map, map.size() == expected_size, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map size %zu did not … in check_size_capacity_coherent()
222 …MapCheck(map, map.capacity() >= expected_min_capacity, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map capac… in check_size_capacity_coherent()
226 PetscErrorCode test_insert(map_type &map) noexcept in test_insert() argument
230 auto size_before = map.size(); in test_insert()
231 auto capacity_before = map.capacity(); in test_insert()
242 …MapCheck(map, !ret.second, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s reinserted key '%s'", op, this->ke… in test_insert()
243 …MapCheck(map, ret.first->first == key, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s returned iterator key … in test_insert()
244 …MapCheck(map, ret.first->second == value, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s returned iterator v… in test_insert()
245 …MapCheck(map, map[key] == value, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s map[%s] '%s' != '%s'", op, t… in test_insert()
246 …pCheck(map, map[key_const] == value_const, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s changed value '%s'… in test_insert()
253 PetscCall(CHECK_REINSERT(map.emplace(key, value))); in test_insert()
254 …PetscCall(CHECK_REINSERT(map.emplace(std::piecewise_construct, std::make_tuple(key), std::make_tup… in test_insert()
255 PetscCall(CHECK_REINSERT(map.insert(std::make_pair(key, value)))); in test_insert()
256 PetscCall(CHECK_REINSERT(map.insert(pair))); in test_insert()
262 PetscCall(this->check_size_capacity_coherent(map)); in test_insert()
263 // put key in map in test_insert()
264 PetscCallCXX(map[key] = value); in test_insert()
266 PetscCall(this->check_size_capacity_coherent(map, size_before + 1, capacity_before)); in test_insert()
268 …MapCheck(map, map[key] == value, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map default key %s != map value… in test_insert()
277 capacity_before = map.capacity(); in test_insert()
278 PetscCall(map.clear()); in test_insert()
280 PetscCall(this->check_size_capacity_coherent(map, 0, capacity_before)); in test_insert()
282 // test that all inserted values are found in the map in test_insert()
288 PetscCall(map.clear()); in test_insert()
289 PetscCall(this->check_size_capacity_coherent(map, 0, 0)); in test_insert()
291 // map size should exactly match the size of the vector, but we don't care about capacity in test_insert()
292 PetscCall(this->check_size_capacity_coherent(map, key_value_pairs.size(), 0)); in test_insert()
296 for (auto it = map.cbegin(); it != map.cend(); ++it) { in test_insert()
302 …MapCheck(map, found != key_value_pairs.cend(), PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map contained key… in test_insert()
303 …MapCheck(map, dist >= 0, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Index of found key-value pair… in test_insert()
308 // there should only be 1 instance of each key-value in the map in test_insert()
310 …MapCheck(map, found_key_value[i] == 1, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map failed to insert key … in test_insert()
322 PetscCallCXX(map[key_value.first] = key_value.second); in test_insert()
345 …lCXX(std::copy(key_value_pairs.cbegin(), key_value_pairs.cend(), std::inserter(map, map.begin()))); in test_insert()
352 auto it = map.find(saved_value.first); in test_insert()
354 // can't use map[] since that might inadvertently insert it in test_insert()
355 …MapCheck(map, it != map.end(), PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map failed no longer contains key… in test_insert()
356 …MapCheck(map, it->first == saved_value.first, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map founnd iterato… in test_insert()
357 …MapCheck(map, it->second == saved_value.second, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map founnd itera… in test_insert()
364 map_type map; in test_insert() local
367 PetscCall(test_insert(map)); in test_insert()
371 PetscErrorCode test_find(map_type &map) noexcept in test_find() argument
377 map = map_type(sample_values.begin(), sample_values.end()); in test_find()
381 auto it = map.find(key); in test_find()
383 …MapCheck(map, it != map.end(), PETSC_COMM_SELF, PETSC_ERR_PLIB, "Failed to find %s in map", this->… in test_find()
384 …MapCheck(map, it->first == key, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Find iterator key %s != expected… in test_find()
385 …MapCheck(map, it->second == value, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Find iterator value %s != exp… in test_find()
386 …MapCheck(map, map.contains(key), PETSC_COMM_SELF, PETSC_ERR_PLIB, "map.contains(key) reports false… in test_find()
387 …MapCheck(map, map.count(key) == 1, PETSC_COMM_SELF, PETSC_ERR_PLIB, "map.count(%s) %zu != 1", this… in test_find()
390 const auto range = map.equal_range(key); in test_find()
394 …MapCheck(map, range_size == 1, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map equal_range() returned a rang… in test_find()
395 …MapCheck(map, range_begin->first == key, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Equal range iterator ke… in test_find()
396 …MapCheck(map, range_begin->second == value, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Equal range iterator… in test_find()
405 map_type map; in test_find() local
408 PetscCall(test_find(map)); in test_find()
412 PetscErrorCode test_erase(map_type &map) noexcept in test_erase() argument
416 const auto check_map_is_truly_empty = [&](map_type &map) { in test_erase() argument
418 …MapCheck(map, map.size() == 0, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Erasing map via iterator range di… in test_erase()
419 …MapCheck(map, map.empty(), PETSC_COMM_SELF, PETSC_ERR_PLIB, "Erasing map via iterators didn't work… in test_erase()
421 … map.begin(); it != map.end(); ++it) MapCheck(map, false, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Erasin… in test_erase()
426 PetscCallCXX(map = backup); in test_erase()
429 const auto it = map.begin(); in test_erase()
433 PetscCallCXX(map.erase(it)); in test_erase()
434 …for (auto &&kv : map) MapCheck(map, kv.first != begin_key, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Erasi… in test_erase()
436 PetscCallCXX(map[begin_key] = begin_val); in test_erase()
440 for (auto it = map.begin(); it != map.end(); ++it) { in test_erase()
443 PetscCallCXX(map.erase(it)); in test_erase()
444 …MapCheck(map, before == it, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Iterator changed during erase%s", ""… in test_erase()
445 …MapCheck(map, map.occupied(before) == false, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Iterator (%s -> %s)… in test_erase()
449 PetscCall(check_map_is_truly_empty(map)); in test_erase()
450 PetscCallCXX(map = backup); in test_erase()
451 PetscCallCXX(map.erase(map.begin(), map.end())); in test_erase()
452 PetscCall(check_map_is_truly_empty(map)); in test_erase()
455 PetscCallCXX(map = backup); in test_erase()
456 PetscCall(map.clear()); in test_erase()
457 PetscCall(check_map_is_truly_empty(map)); in test_erase()
462 PetscCallCXX(map = backup); in test_erase()
463 cap_before = map.capacity(); in test_erase()
464 PetscCall(map.clear()); in test_erase()
465 PetscCall(check_map_is_truly_empty(map)); in test_erase()
466 …map, map.capacity() == cap_before, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map capacity decreased on cle… in test_erase()
467 PetscCall(map.shrink_to_fit()); in test_erase()
468 …MapCheck(map, map.capacity() == 0, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map capacity should be 0 (hav… in test_erase()
469 PetscCall(check_map_is_truly_empty(map)); in test_erase()
473 PetscCallCXX(map.insert(generator())); in test_erase()
474 PetscCallCXX(map.insert(generator())); in test_erase()
475 PetscCallCXX(map.insert(generator())); in test_erase()
476 PetscCallCXX(map.insert(generator())); in test_erase()
477 PetscCallCXX(map.erase(map.begin(), map.end())); in test_erase()
478 PetscCall(check_map_is_truly_empty(map)); in test_erase()
480 // test erase by member function swapping with empty map in test_erase()
481 for (auto &&kv : sample_values) PetscCallCXX(map.emplace(kv.first, kv.second)); in test_erase()
485 // has the effect of clearing the map in test_erase()
486 PetscCallCXX(map.swap(alt)); in test_erase()
488 PetscCall(check_map_is_truly_empty(map)); in test_erase()
490 // test erase by std::swap with empty map in test_erase()
491 PetscCallCXX(map = backup); in test_erase()
496 // has the effect of clearing the map in test_erase()
497 PetscCallCXX(swap(map, alt)); in test_erase()
499 PetscCall(check_map_is_truly_empty(map)); in test_erase()
503 std::copy(sample_values.cbegin(), sample_values.cend(), std::inserter(map, map.begin())); in test_erase()
504 for (auto &&kv : sample_values) PetscCallCXX(map.erase(kv.first)); in test_erase()
505 PetscCall(check_map_is_truly_empty(map)); in test_erase()
511 map_type map; in test_erase() local
514 PetscCall(test_erase(map)); in test_erase()
520 PetscErrorCode test_iterators(map_type &map, It it, It it2) noexcept in test_iterators() argument
529 …MapCheck(map, it == it2, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s iterator does not equal itself?", it… in test_iterators()
532 …MapCheck(map, it == it2, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s iterator does not equal itself after… in test_iterators()
535 …MapCheck(map, it == it2, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s iterator does not equal itself after… in test_iterators()
536 …apCheck(map, map.size() < max_iter, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Forward progress test only w… in test_iterators()
542 PetscCallCXX(it = map.begin()); in test_iterators()
544 if (it == map.end()) break; in test_iterators()
547 …map, i < max_iter, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s iterator did not appear to make forward pr… in test_iterators()
548 PetscCallCXX(it = map.begin()); in test_iterators()
550 if (it == map.end()) break; in test_iterators()
553 …map, i < max_iter, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s iterator did not appear to make forward pr… in test_iterators()
556 PetscCallCXX(it = std::prev(map.end())); in test_iterators()
558 if (it == map.begin()) break; in test_iterators()
561 …map, i < max_iter, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s iterator did not appear to make forward pr… in test_iterators()
562 PetscCallCXX(it = std::prev(map.end())); in test_iterators()
564 if (it == map.begin()) break; in test_iterators()
567 …map, i < max_iter, PETSC_COMM_SELF, PETSC_ERR_PLIB, "%s iterator did not appear to make forward pr… in test_iterators()
575 map_type map(sample_values.begin(), sample_values.end()); in test_misc() local
578 PetscCall(this->test_iterators(map, map.begin(), map.begin())); in test_misc()
579 PetscCall(this->test_iterators(map, map.cbegin(), map.cbegin())); in test_misc()
581 const auto backup = map; in test_misc()
582 auto map_copy = map; in test_misc()
585 // the original map should not have changed at all in test_misc()
586 …MapCheck(map, map == backup, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Map does not equal the original map… in test_misc()
590 …MapCheck(map_copy, map == map_copy, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Copy of map does not equal t… in test_misc()
592 // test that the copied map works OK in test_misc()
599 PetscCallCXX(map_copy = map); in test_misc()
603 …MapCheck(moved_copy, map == moved_copy, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Moved copy of map does n… in test_misc()
716 …PetscCall(make_tester<int, double>(vwr, "int-double basic map", int_printer, double_printer, int_d… in main()
717 …PetscCall(make_tester<int, double, BadHash>(vwr, "int-double bad hash map", int_printer, double_pr… in main()
720 …PetscCall(make_tester<int, Foo, BadHash>(vwr, "int-foo bad hash map", int_printer, foo_printer, in… in main()
723 …PetscCall(make_tester<Foo, Bar>(vwr, "foo-bar basic map", foo_printer, bar_printer, foo_bar_genera… in main()
724 …PetscCall(make_tester<Foo, Bar, BadHash>(vwr, "foo-bar bad hash map", foo_printer, bar_printer, fo… in main()
727 // value_type of the map and hashers is both the same thing in main()
732 …>, std::pair<int, double>>(vwr, "pair<int, double>-pair<int, double> basic map", pair_printer, pai… in main()
733 …<int, double>, BadHash>(vwr, "pair<int, double>-pair<int, double> bad hash map", pair_printer, pai… in main()