gov.sandia.cognition.learning.algorithm.clustering.cluster
Class DefaultCluster<ClusterType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.algorithm.clustering.cluster.DefaultCluster<ClusterType>
Type Parameters:
ClusterType - The type of data stored in the cluster.
All Implemented Interfaces:
Cluster<ClusterType>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
CentroidCluster, DirichletProcessMixtureModel.DPMMCluster, GaussianCluster

@CodeReview(reviewer="Kevin R. Dixon",
            date="2008-07-22",
            changesNeeded=false,
            comments="Interface looks fine.")
public class DefaultCluster<ClusterType>
extends AbstractCloneableSerializable
implements Cluster<ClusterType>

The DefaultCluster class implements a default cluster which contains a list of members in an ArrayList along with an index that identifies the cluster.

Since:
1.0
Author:
Justin Basilico, Kevin R. Dixon
See Also:
Serialized Form

Field Summary
static int DEFAULT_INDEX
          The default index is -1.
 
Constructor Summary
DefaultCluster()
          Creates a new instance of CentroidCluster.
DefaultCluster(Collection<? extends ClusterType> members)
          Creates a new instance of CentroidCluster.
DefaultCluster(int index)
          Creates a new instance of CentroidCluster.
DefaultCluster(int index, Collection<? extends ClusterType> members)
          Creates a new instance of CentroidCluster.
 
Method Summary
 DefaultCluster<ClusterType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 int getIndex()
          Gets the cluster index.
 ArrayList<ClusterType> getMembers()
          Gets the members of the cluster.
 void setIndex(int index)
          Sets the index of the cluster.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INDEX

public static final int DEFAULT_INDEX
The default index is -1.

See Also:
Constant Field Values
Constructor Detail

DefaultCluster

public DefaultCluster()
Creates a new instance of CentroidCluster.


DefaultCluster

public DefaultCluster(int index)
Creates a new instance of CentroidCluster.

Parameters:
index - The index of the cluster.

DefaultCluster

public DefaultCluster(Collection<? extends ClusterType> members)
Creates a new instance of CentroidCluster.

Parameters:
members - The members of the cluster.

DefaultCluster

public DefaultCluster(int index,
                      Collection<? extends ClusterType> members)
Creates a new instance of CentroidCluster.

Parameters:
index - The index of the cluster.
members - The members of the cluster.
Method Detail

clone

public DefaultCluster<ClusterType> clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

getIndex

public int getIndex()
Gets the cluster index.

Returns:
The index of the cluster.

getMembers

public ArrayList<ClusterType> getMembers()
Gets the members of the cluster.

Specified by:
getMembers in interface Cluster<ClusterType>
Returns:
The members of the cluster.

setIndex

public void setIndex(int index)
Sets the index of the cluster.

Parameters:
index - The new index.