Make XORFastHash's number of hashable elements compile time constant
Still constraint by the usage of uint32_t and subsequent splitting into two uint16_t we use for indexing into the tables.
This commit is contained in:
parent
1417d43430
commit
a6e7954128
@ -1096,7 +1096,7 @@ class GraphContractor
|
|||||||
// self-loops are added.
|
// self-loops are added.
|
||||||
std::vector<EdgeWeight> node_weights;
|
std::vector<EdgeWeight> node_weights;
|
||||||
std::vector<bool> is_core_node;
|
std::vector<bool> is_core_node;
|
||||||
util::XORFastHash fast_hash;
|
util::XORFastHash<> fast_hash;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,12 @@ namespace util
|
|||||||
10: ret
|
10: ret
|
||||||
|
|
||||||
*/
|
*/
|
||||||
class XORFastHash
|
template <std::size_t MaxNumElements = (1u << 16u)> class XORFastHash
|
||||||
{ // 65k entries
|
{
|
||||||
std::array<std::uint16_t, (1u << 16u)> table1;
|
static_assert(MaxNumElements <= (1u << 16u), "only 65536 elements indexable with uint16_t");
|
||||||
std::array<std::uint16_t, (1u << 16u)> table2;
|
|
||||||
|
std::array<std::uint16_t, MaxNumElements> table1;
|
||||||
|
std::array<std::uint16_t, MaxNumElements> table2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XORFastHash()
|
XORFastHash()
|
||||||
|
@ -78,7 +78,7 @@ template <typename NodeID, typename Key> class XORFastHashStorage
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<HashCell> positions;
|
std::vector<HashCell> positions;
|
||||||
XORFastHash fast_hasher;
|
XORFastHash<> fast_hasher;
|
||||||
unsigned current_timestamp;
|
unsigned current_timestamp;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user