@Test public void toByteArray() { byte[] data = new byte[16]; for (int i = 0; i < data.length; ++i) { data[i] = (byte)(Math.random()*256); } BitChromosome bc = new BitChromosome(data); Assert.assertEquals(bc.toByteArray(), data); }
private static byte[] toByteArray(final CharSequence value) { final byte[] bytes = Bits.newArray(value.length()); for (int i = value.length(); --i >= 0;) { final char c = value.charAt(i); if (c == '1') { Bits.set(bytes, i); } else if (c != '0') { throw new IllegalArgumentException(format( "Illegal character '%s' at position %d", c, i )); } } return bytes; }
BitChromosome extends Number implements
		Chromosome<BitGene>,
		Comparable<BitChromosome>,
		Serializable { private static byte[] toByteArray(final CharSequence value) { final byte[] bytes = Bits.newArray(value.length()); for (int i = value.length(); --i >= 0;) { final char c = value.charAt(i); if (c == '1') { Bits.set(bytes, i); } else if (c != '0') { throw new IllegalArgumentException(format( "Illegal character '%s' at position %d", c, i )); } } return bytes; } }
BitChromosome extends Number implements
		Chromosome<BitGene>,
		Comparable<BitChromosome>,
		Serializable { private static byte[] toByteArray(final CharSequence value) { final byte[] bytes = Bits.newArray(value.length()); for (int i = value.length(); --i >= 0;) { final char c = value.charAt(i); if (c == '1') { Bits.set(bytes, i); } else if (c != '0') { throw new IllegalArgumentException(format( "Illegal character '%s' at position %d", c, i )); } } return bytes; } private  BitChromosome(final byte[] bits, final int length, final double p);  BitChromosome(final byte[] bits, final int start, final int end);  BitChromosome(final byte[] bits); private  BitChromosome(final byte[] bits, final int length); }
BitChromosome extends Number implements
		Chromosome<BitGene>,
		Comparable<BitChromosome>,
		Serializable { private static byte[] toByteArray(final CharSequence value) { final byte[] bytes = Bits.newArray(value.length()); for (int i = value.length(); --i >= 0;) { final char c = value.charAt(i); if (c == '1') { Bits.set(bytes, i); } else if (c != '0') { throw new IllegalArgumentException(format( "Illegal character '%s' at position %d", c, i )); } } return bytes; } private  BitChromosome(final byte[] bits, final int length, final double p);  BitChromosome(final byte[] bits, final int start, final int end);  BitChromosome(final byte[] bits); private  BitChromosome(final byte[] bits, final int length); double oneProbability(); @Override BitGene gene(); boolean booleanValue(); @Override BitGene get(final int index); @Override int length(); boolean booleanValue(final int index); int bitCount(); ListIterator<BitGene> listIterator(); @Override int intValue(); @Override long longValue(); @Override float floatValue(); @Override double doubleValue(); @Override boolean isValid(); BigInteger toBigInteger(); int toByteArray(final byte[] bytes); byte[] toByteArray(); BitSet toBitSet(); IntStream ones(); IntStream zeros(); @Override BitChromosome newInstance(final ISeq<BitGene> genes); @Override BitChromosome newInstance(); BitChromosome map(final Function<? super BitSet, ? extends BitSet> f); String toCanonicalString(); @Override int compareTo(final BitChromosome that); BitChromosome invert(); static BitChromosome of(final int length, final double p); static BitChromosome of(final int length); static BitChromosome of(final BitSet bits, final int length); static BitChromosome of(
		final BitSet bits,
		final int length,
		final double p
	); @Deprecated(since = "6.1", forRemoval = true) static BitChromosome of(final BitSet bits); static BitChromosome of(final BigInteger value); static BitChromosome of(final BigInteger value, final double p); static BitChromosome of(final CharSequence value); static BitChromosome of(final CharSequence value, final double p); static BitChromosome of(
		final CharSequence value,
		final int length,
		final double p
	); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); }
BitChromosome extends Number implements
		Chromosome<BitGene>,
		Comparable<BitChromosome>,
		Serializable { private static byte[] toByteArray(final CharSequence value) { final byte[] bytes = Bits.newArray(value.length()); for (int i = value.length(); --i >= 0;) { final char c = value.charAt(i); if (c == '1') { Bits.set(bytes, i); } else if (c != '0') { throw new IllegalArgumentException(format( "Illegal character '%s' at position %d", c, i )); } } return bytes; } private  BitChromosome(final byte[] bits, final int length, final double p);  BitChromosome(final byte[] bits, final int start, final int end);  BitChromosome(final byte[] bits); private  BitChromosome(final byte[] bits, final int length); double oneProbability(); @Override BitGene gene(); boolean booleanValue(); @Override BitGene get(final int index); @Override int length(); boolean booleanValue(final int index); int bitCount(); ListIterator<BitGene> listIterator(); @Override int intValue(); @Override long longValue(); @Override float floatValue(); @Override double doubleValue(); @Override boolean isValid(); BigInteger toBigInteger(); int toByteArray(final byte[] bytes); byte[] toByteArray(); BitSet toBitSet(); IntStream ones(); IntStream zeros(); @Override BitChromosome newInstance(final ISeq<BitGene> genes); @Override BitChromosome newInstance(); BitChromosome map(final Function<? super BitSet, ? extends BitSet> f); String toCanonicalString(); @Override int compareTo(final BitChromosome that); BitChromosome invert(); static BitChromosome of(final int length, final double p); static BitChromosome of(final int length); static BitChromosome of(final BitSet bits, final int length); static BitChromosome of(
		final BitSet bits,
		final int length,
		final double p
	); @Deprecated(since = "6.1", forRemoval = true) static BitChromosome of(final BitSet bits); static BitChromosome of(final BigInteger value); static BitChromosome of(final BigInteger value, final double p); static BitChromosome of(final CharSequence value); static BitChromosome of(final CharSequence value, final double p); static BitChromosome of(
		final CharSequence value,
		final int length,
		final double p
	); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString();  }