Implemented cluster groups

This commit is contained in:
Lennart Hensler committed 2014-03-10 14:07:08 +01:00
1 parent 8fb3f3e9a9
commit e228e7ed67
3 files changed
+62

No files matched your search

@@ -0,0 +1,28 @@
package com.sap.sse.datamining.impl.data;
import static org.junit.Assert.*;
import java.util.Comparator;
import org.junit.Ignore;
import org.junit.Test;
import com.sap.sse.datamining.data.ClusterGroup;
public class TestFixClusterGroup {
public static final Comparator<Integer> comparator = new ComparableComparator<Integer>();
@Ignore
@Test
public void testClusterGroupWithClosedBoundaries() {
ClusterGroup<Integer> groupWithClosedBoundaries = createGroupWithClosedBoundaries();
fail("Not yet implemented");
}
private ClusterGroup<Integer> createGroupWithClosedBoundaries() {
// TODO Auto-generated method stub
return null;
}
}
@@ -0,0 +1,7 @@
package com.sap.sse.datamining.data;
public interface ClusterGroup<ElementType> {
public Cluster<ElementType> getClusterFor(ElementType value);
}
@@ -0,0 +1,27 @@
package com.sap.sse.datamining.impl.data;
import java.util.Collection;
import java.util.HashSet;
import com.sap.sse.datamining.data.Cluster;
import com.sap.sse.datamining.data.ClusterGroup;
public class FixClusterGroup<ElementType> implements ClusterGroup<ElementType> {
private final Iterable<Cluster<ElementType>> clusters;
public FixClusterGroup(Collection<Cluster<ElementType>> clusters) {
this.clusters = new HashSet<>(clusters);
}
@Override
public Cluster<ElementType> getClusterFor(ElementType value) {
for (Cluster<ElementType> cluster : clusters) {
if (cluster.isInRange(value)) {
return cluster;
}
}
return null;
}
}