/*
* #%L
* org.gitools.analysis
* %%
* Copyright (C) 2013 - 2014 Universitat Pompeu Fabra - Biomedical Genomics group
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
package org.gitools.analysis.clustering.kmeans;
import java.io.Serializable;
import java.util.List;
/**
* A simple implementation of {@link Clusterable} for points with double coordinates.
*/
public class DoublePoint implements Clusterable, Serializable {
/** Serializable version identifier. */
private static final long serialVersionUID = 3946024775784901369L;
/** Point coordinates. */
private final List<Double> point;
/**
* Build an instance wrapping an double array.
* <p>
* The wrapped array is referenced, it is <em>not</em> copied.
*
* @param point the n-dimensional point in double space
*/
public DoublePoint(final List<Double> point) {
this.point = point;
}
/** {@inheritDoc} */
public Iterable<Double> getPoint() {
return point;
}
@Override
public int size() {
return point.size();
}
/** {@inheritDoc} */
@Override
public boolean equals(final Object other) {
if (!(other instanceof DoublePoint)) {
return false;
}
return point.equals(((DoublePoint) other).point);
}
/** {@inheritDoc} */
@Override
public int hashCode() {
return point.hashCode();
}
/** {@inheritDoc} */
@Override
public String toString() {
return point.toString();
}
}