 All Implemented Interfaces:
SequenceDistanceMeasurer
,SequenceDistanceMeasurerDouble
Most other implementations of Hamming distance require the two strings to be of the same length. Ours does not. If the two sequences (i.e., arrays or Strings) are of different lengths, then the difference in length affects distance. E.g., although "abbd" is a distance of 1 from "abcd" since they differ in one position, "abbd" is a distance of 4 from "abcdefg" (the one difference, plus the three extra characters).
Runtime: O(n), where n is the length of the shorter of the two sequences.
If your sequences are guaranteed not to have duplicates, and to contain the same set of
elements, then consider instead using the ExactMatchDistance
class, which assumes permutations of the
integers from 0 to N1.
Exact match distance was introduced specifically for permutations in:
S. Ronald, "More distance functions for orderbased encodings," in Proc. IEEE CEC. IEEE Press,
1998, pp. 558–563.

Constructor Summary
ConstructorDescriptionConstructs the distance measurer as specified in the class documentation. 
Method Summary
Modifier and TypeMethodDescriptionint
distance
(boolean[] s1, boolean[] s2) Measures the distance between two arrays.int
distance
(byte[] s1, byte[] s2) Measures the distance between two arrays.int
distance
(char[] s1, char[] s2) Measures the distance between two arrays.int
distance
(double[] s1, double[] s2) Measures the distance between two arrays.int
distance
(float[] s1, float[] s2) Measures the distance between two arrays.int
distance
(int[] s1, int[] s2) Measures the distance between two arrays.int
distance
(long[] s1, long[] s2) Measures the distance between two arrays.int
distance
(short[] s1, short[] s2) Measures the distance between two arrays.int
Measures the distance between two arrays of objects.int
Measures the distance between two Strings.<T> int
Measures the distance between two lists of objects.

Constructor Details

ExactMatchDistance
public ExactMatchDistance()Constructs the distance measurer as specified in the class documentation.


Method Details

distance
public int distance(int[] s1, int[] s2) Description copied from interface:SequenceDistanceMeasurer
Measures the distance between two arrays. Specified by:
distance
in interfaceSequenceDistanceMeasurer
 Parameters:
s1
 First array.s2
 Second array. Returns:
 distance between s1 and s2

distance
public int distance(long[] s1, long[] s2) Description copied from interface:SequenceDistanceMeasurer
Measures the distance between two arrays. Specified by:
distance
in interfaceSequenceDistanceMeasurer
 Parameters:
s1
 First array.s2
 Second array. Returns:
 distance between s1 and s2

distance
public int distance(short[] s1, short[] s2) Description copied from interface:SequenceDistanceMeasurer
Measures the distance between two arrays. Specified by:
distance
in interfaceSequenceDistanceMeasurer
 Parameters:
s1
 First array.s2
 Second array. Returns:
 distance between s1 and s2

distance
public int distance(byte[] s1, byte[] s2) Description copied from interface:SequenceDistanceMeasurer
Measures the distance between two arrays. Specified by:
distance
in interfaceSequenceDistanceMeasurer
 Parameters:
s1
 First array.s2
 Second array. Returns:
 distance between s1 and s2

distance
public int distance(char[] s1, char[] s2) Description copied from interface:SequenceDistanceMeasurer
Measures the distance between two arrays. Specified by:
distance
in interfaceSequenceDistanceMeasurer
 Parameters:
s1
 First array.s2
 Second array. Returns:
 distance between s1 and s2

distance
public int distance(boolean[] s1, boolean[] s2) Description copied from interface:SequenceDistanceMeasurer
Measures the distance between two arrays. Specified by:
distance
in interfaceSequenceDistanceMeasurer
 Parameters:
s1
 First array.s2
 Second array. Returns:
 distance between s1 and s2

distance
public int distance(double[] s1, double[] s2) Description copied from interface:SequenceDistanceMeasurer
Measures the distance between two arrays. Specified by:
distance
in interfaceSequenceDistanceMeasurer
 Parameters:
s1
 First array.s2
 Second array. Returns:
 distance between s1 and s2

distance
public int distance(float[] s1, float[] s2) Description copied from interface:SequenceDistanceMeasurer
Measures the distance between two arrays. Specified by:
distance
in interfaceSequenceDistanceMeasurer
 Parameters:
s1
 First array.s2
 Second array. Returns:
 distance between s1 and s2

distance
Description copied from interface:SequenceDistanceMeasurer
Measures the distance between two Strings. Specified by:
distance
in interfaceSequenceDistanceMeasurer
 Parameters:
s1
 First String.s2
 Second String. Returns:
 distance between s1 and s2

distance
Description copied from interface:SequenceDistanceMeasurer
Measures the distance between two arrays of objects. The objects in the arrays must be of a class that has overridden the Object.equals method. Specified by:
distance
in interfaceSequenceDistanceMeasurer
 Parameters:
s1
 First array.s2
 Second array. Returns:
 distance between s1 and s2

distance
Description copied from interface:SequenceDistanceMeasurer
Measures the distance between two lists of objects. The objects in the lists must be of a class that has overridden the Object.equals method. Specified by:
distance
in interfaceSequenceDistanceMeasurer
 Type Parameters:
T
 Type of List elements. Parameters:
s1
 First list.s2
 Second list. Returns:
 distance between s1 and s2
