package cefet.rba.chromossome;

import java.util.Arrays;

public class IntegerArrayChromosome implements Chromosome<Integer> {

	protected Integer[] chromosome;
	
	public IntegerArrayChromosome(Chromosome<Integer> c) {
		chromosome = new Integer[c.size()];
		for (int i = 0, sz = c.size(); i < sz; i++) {
			chromosome[i] = c.getGene(i);
		}
	}
	
	public IntegerArrayChromosome(int size) {
		chromosome = new Integer[size];
	}
	
	@Override
	public Integer getGene(int locus) {
		return chromosome[locus];
	}

	@Override
	public void setGene(int locus, Integer gene) {
		chromosome[locus] = gene;
	}

	@Override
	public int size() {
		return chromosome.length;
	}

	@Override
	public Chromosome<Integer> copy() {
		return new IntegerArrayChromosome(this);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Arrays.hashCode(chromosome);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		IntegerArrayChromosome other = (IntegerArrayChromosome) obj;
		if (!Arrays.equals(chromosome, other.chromosome))
			return false;
		return true;
	}
	
	
}

@@ -1,8 +1,633 @@
+/*%0D%0A * Copyright (C) 2016 Renato Barros Arantes%0D%0A *%0D%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0D%0A * you may not use this file except in compliance with the License.%0D%0A * You may obtain a copy of the License at%0D%0A *%0D%0A *      http://www.apache.org/licenses/LICENSE-2.0%0D%0A *%0D%0A * Unless required by applicable law or agreed to in writing, software%0D%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0D%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0D%0A * See the License for the specific language governing permissions and%0D%0A * limitations under the License.%0D%0A */%0D%0A
 package 

Update IntegerArrayChromosome.java