Core/Console: Add CountOf function
Former-commit-id: 8ea1456bc8debae102ca616176febb15d3759d17
This commit is contained in:
parent
b9ec4a4fc4
commit
adf5946711
|
|
@ -23,6 +23,8 @@ namespace Nz
|
||||||
template<typename O, typename F, typename Tuple> auto Apply(O& object, F&& fn, Tuple&& t);
|
template<typename O, typename F, typename Tuple> auto Apply(O& object, F&& fn, Tuple&& t);
|
||||||
template<typename T> ByteArray ComputeHash(HashType hash, const T& v);
|
template<typename T> ByteArray ComputeHash(HashType hash, const T& v);
|
||||||
template<typename T> ByteArray ComputeHash(AbstractHash* hash, const T& v);
|
template<typename T> ByteArray ComputeHash(AbstractHash* hash, const T& v);
|
||||||
|
template<typename T, std::size_t N> constexpr std::size_t CountOf(T(&name)[N]) noexcept;
|
||||||
|
template<typename T> std::size_t CountOf(const T& c);
|
||||||
template<typename T> void HashCombine(std::size_t& seed, const T& v);
|
template<typename T> void HashCombine(std::size_t& seed, const T& v);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,18 @@ namespace Nz
|
||||||
return hash->End();
|
return hash->End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr std::size_t CountOf(T(&name)[N]) noexcept
|
||||||
|
{
|
||||||
|
return N;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::size_t CountOf(const T& c)
|
||||||
|
{
|
||||||
|
return c.size();
|
||||||
|
}
|
||||||
|
|
||||||
// Algorithme venant de CityHash par Google
|
// Algorithme venant de CityHash par Google
|
||||||
// http://stackoverflow.com/questions/8513911/how-to-create-a-good-hash-combine-with-64-bit-output-inspired-by-boosthash-co
|
// http://stackoverflow.com/questions/8513911/how-to-create-a-good-hash-combine-with-64-bit-output-inspired-by-boosthash-co
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue