mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
Merge 70bd2c9a6c9791005a57050fcf7c051fd417c80c into 297b331435d6dee09bf89c8a5ad974b01f18039b
This commit is contained in:
commit
d2b88ca235
@ -262,11 +262,13 @@ namespace std {
|
||||
template <>
|
||||
struct hash<xlnt::cell_reference>
|
||||
{
|
||||
size_t operator()(const xlnt::cell_reference &x) const
|
||||
size_t operator()(const xlnt::cell_reference &x) const // using Szudzik's pairing function
|
||||
{
|
||||
static_assert(std::is_same<decltype(x.row()), std::uint32_t>::value, "this hash function expects both row and column to be 32-bit numbers");
|
||||
static_assert(std::is_same<decltype(x.column_index()), std::uint32_t>::value, "this hash function expects both row and column to be 32-bit numbers");
|
||||
return hash<std::uint64_t>{}(x.row() | static_cast<std::uint64_t>(x.column_index()) << 32);
|
||||
if (x.column_index() >= x.row()) {
|
||||
return hash<size_t>{}(x.column_index() * x.column_index() + x.column_index() + x.row());
|
||||
} else {
|
||||
return hash<size_t>{}(x.column_index() + x.row() * x.row());
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
Loading…
x
Reference in New Issue
Block a user