@Override
	protected MutatorResult<Chromosome<G>> mutate(
		final Chromosome<G> chromosome,
		final double p,
		final RandomGenerator random
	) {
		final MutatorResult<Chromosome<G>> result;
		if (chromosome.length() > 1) {
			final MSeq<G> genes = MSeq.of(chromosome);
			final int mutations = (int)indexes(random, genes.length(), p)
				.peek(i -> genes.swap(i, random.nextInt(genes.length())))
				.count();

			result = new MutatorResult<>(
				chromosome.newInstance(genes.toISeq()),
				mutations
			);
		} else {
			result = new MutatorResult<>(chromosome, 0);
		}

		return result;
	}
Swaps the genes in the given array, with the mutation probability of this
mutation.
jenetics/src/main/java/io/jenetics/SwapMutator.java