mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Made hamming_distance() a little more general.
This commit is contained in:
parent
bc37789144
commit
6d5ad339c7
@ -54,6 +54,26 @@ namespace dlib
|
||||
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);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user