"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "19e559d5e91920e8637ba6391a6c42537b404d88"
Commit 6d5ad339 authored by Davis King's avatar Davis King
Browse files

Made hamming_distance() a little more general.

parent bc377891
...@@ -54,6 +54,26 @@ namespace dlib ...@@ -54,6 +54,26 @@ namespace dlib
return count_bits(a^b); return count_bits(a^b);
} }
// ----------------------------------------------------------------------------------------
template <
typename T
>
T hamming_distance (
const std::pair<T,T>& a,
const std::pair<T,T>& b
)
/*!
requires
- T is an unsigned integral type or a std::pair that, recursively, eventually
contains unsigned integral types.
ensures
- returns the number of bits which differ between a and b.
!*/
{
return hamming_distance(a.first,b.first) + hamming_distance(a.second, b.second);
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment