MCPcopy Create free account
hub / github.com/Tessil/ordered-map / hash

Class hash

tests/ordered_map_tests.cpp:1480–1488  ·  view source on GitHub ↗

Use a KeyEqual and Hash where any odd unsigned number 'x' is equal to 'x-1'. Make sure that KeyEqual is called (and not ==).

Source from the content-addressed store, hash-verified

1478 // Use a KeyEqual and Hash where any odd unsigned number 'x' is equal to
1479 // 'x-1'. Make sure that KeyEqual is called (and not ==).
1480 struct hash {
1481 std::size_t operator()(std::uint64_t v) const {
1482 if (v % 2u == 1u) {
1483 return std::hash<std::uint64_t>()(v - 1);
1484 } else {
1485 return std::hash<std::uint64_t>()(v);
1486 }
1487 }
1488 };
1489
1490 struct key_equal {
1491 bool operator()(std::uint64_t lhs, std::uint64_t rhs) const {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected