BitChromosomeUtils.java

1
package net.bmahe.genetics4j.core.util;
2
3
import java.util.BitSet;
4
import java.util.Objects;
5
6
import org.apache.commons.lang3.Validate;
7
8
import net.bmahe.genetics4j.core.chromosomes.BitChromosome;
9
10
public class BitChromosomeUtils {
11
12
	public static int hammingDistance(final BitChromosome bc1, final BitChromosome bc2) {
13
		Objects.requireNonNull(bc1);
14
		Objects.requireNonNull(bc2);
15
		Validate.isTrue(bc1.getNumAlleles() == bc2.getNumAlleles());
16
17 1 1. hammingDistance : removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getBitSet → NO_COVERAGE
		final BitSet bitSet1 = bc1.getBitSet();
18 1 1. hammingDistance : removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getBitSet → NO_COVERAGE
		final BitSet bitSet2 = bc2.getBitSet();
19
20 1 1. hammingDistance : Substituted 0 with 1 → NO_COVERAGE
		int distance = 0;
21 6 1. hammingDistance : removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getNumAlleles → NO_COVERAGE
2. hammingDistance : removed conditional - replaced comparison check with true → NO_COVERAGE
3. hammingDistance : changed conditional boundary → NO_COVERAGE
4. hammingDistance : Substituted 0 with 1 → NO_COVERAGE
5. hammingDistance : negated conditional → NO_COVERAGE
6. hammingDistance : removed conditional - replaced comparison check with false → NO_COVERAGE
		for (int i = 0; i < bc1.getNumAlleles(); i++) {
22 5 1. hammingDistance : removed call to java/util/BitSet::get → NO_COVERAGE
2. hammingDistance : negated conditional → NO_COVERAGE
3. hammingDistance : removed conditional - replaced equality check with false → NO_COVERAGE
4. hammingDistance : removed call to java/util/BitSet::get → NO_COVERAGE
5. hammingDistance : removed conditional - replaced equality check with true → NO_COVERAGE
			if (bitSet1.get(i) != bitSet2.get(i)) {
23 2 1. hammingDistance : Changed increment from 1 to -1 → NO_COVERAGE
2. hammingDistance : Removed increment 1 → NO_COVERAGE
				distance += 1;
24
			}
25
		}
26
27 1 1. hammingDistance : replaced int return with 0 for net/bmahe/genetics4j/core/util/BitChromosomeUtils::hammingDistance → NO_COVERAGE
		return distance;
28
	}
29
}

Mutations

17

1.1
Location : hammingDistance
Killed by : none
removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getBitSet → NO_COVERAGE

18

1.1
Location : hammingDistance
Killed by : none
removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getBitSet → NO_COVERAGE

20

1.1
Location : hammingDistance
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

21

1.1
Location : hammingDistance
Killed by : none
removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getNumAlleles → NO_COVERAGE

2.2
Location : hammingDistance
Killed by : none
removed conditional - replaced comparison check with true → NO_COVERAGE

3.3
Location : hammingDistance
Killed by : none
changed conditional boundary → NO_COVERAGE

4.4
Location : hammingDistance
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

5.5
Location : hammingDistance
Killed by : none
negated conditional → NO_COVERAGE

6.6
Location : hammingDistance
Killed by : none
removed conditional - replaced comparison check with false → NO_COVERAGE

22

1.1
Location : hammingDistance
Killed by : none
removed call to java/util/BitSet::get → NO_COVERAGE

2.2
Location : hammingDistance
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : hammingDistance
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

4.4
Location : hammingDistance
Killed by : none
removed call to java/util/BitSet::get → NO_COVERAGE

5.5
Location : hammingDistance
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

23

1.1
Location : hammingDistance
Killed by : none
Changed increment from 1 to -1 → NO_COVERAGE

2.2
Location : hammingDistance
Killed by : none
Removed increment 1 → NO_COVERAGE

27

1.1
Location : hammingDistance
Killed by : none
replaced int return with 0 for net/bmahe/genetics4j/core/util/BitChromosomeUtils::hammingDistance → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.6