hammingDistance<E> function
Finds the Hamming distance between two lists.
Parameters
source
andtarget
are two list of items.test
is an optional equality matcher.
Details
Hamming distance is between two equal-length list of items is the number of positions at which the corresponding items are different.
If length of the lists are not equal, a RangeError is thrown.
Complexity: Time O(n)
| Space O(1)
Implementation
int hammingDistance<E>(
List<E> source,
List<E> target, {
DualEqualityTest<E, E>? test,
}) {
if (test == null) {
return hammingDistanceDefault(source, target);
}
return hammingDistanceCustom(source, target, test);
}