package multinomad.tools.kmeans;

import java.util.ArrayList;
import java.util.Iterator;

import multinomad.individuals.DoubleIndividual;

public class Centroid extends DoubleIndividual implements Iterable<DoubleIndividual>{
	
	ArrayList<DoubleIndividual> cluster;
	
	//A way to initialize the centroid
	public Centroid(DoubleIndividual ind) {
		super(ind.getChr().asdouble());
		cluster = new ArrayList<DoubleIndividual>();
	}
	
	public boolean isInCluster(DoubleIndividual ind) {
		return cluster.contains(ind);
	}
	
	public boolean addToCluster(DoubleIndividual ind) {
		return cluster.add(ind);
	}
	
	public boolean removeFromCluster (DoubleIndividual ind) {
		return cluster.remove(ind);
	}
	
	public Iterator<DoubleIndividual> iterator() {
		return cluster.iterator();
	}

}
