For further explanation about the Hamming Distance, take a look at its Wikipedia page at https://en.wikipedia.org/wiki/Hamming_distance.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Integer | Returns: distance.the first input, must not be null. left, final CharSequence the second input, must not be null. right)Implements org. Computes the Hamming Distance between two strings with the same length. |
| public < The type of similarity score unit. E> Integer | Returns: distance.the first input, must not be null. left, final SimilarityInput<E> the second input, must not be null. right)Implements org. Computes the Hamming Distance between two strings with the same length. |
| HammingDistance | back to summary |
|---|---|
| public HammingDistance() Creates a new instance. | |
| apply | back to summary |
|---|---|
| public Integer apply(final CharSequence left, final CharSequence right) Implements org. Computes the Hamming Distance between two strings with the same length. The distance starts with zero, and for each occurrence of a different character in either String, it increments the distance by 1, and finally return its value. Since the Hamming Distance can only be calculated between strings of equal length, input of different lengths will throw IllegalArgumentException
distance.apply("", "") = 0
distance.apply("pappa", "pappa") = 0
distance.apply("1011101", "1011111") = 1
distance.apply("ATCG", "ACCC") = 2
distance.apply("karolin", "kerstin" = 3
| |
| apply | back to summary |
|---|---|
| public <E> Integer apply(final SimilarityInput<E> left, final SimilarityInput<E> right) Implements org. Computes the Hamming Distance between two strings with the same length. The distance starts with zero, and for each occurrence of a different character in either String, it increments the distance by 1, and finally return its value. Since the Hamming Distance can only be calculated between strings of equal length, input of different lengths will throw IllegalArgumentException
distance.apply("", "") = 0
distance.apply("pappa", "pappa") = 0
distance.apply("1011101", "1011111") = 1
distance.apply("ATCG", "ACCC") = 2
distance.apply("karolin", "kerstin" = 3
| |