Class GvmSimpleKeyer<K>

  • Type Parameters:
    K - the key type
    All Implemented Interfaces:
    GvmKeyer<K>
    Direct Known Subclasses:
    GvmListKeyer

    public abstract class GvmSimpleKeyer<K>
    extends Object
    implements GvmKeyer<K>
    A convenience class that reduces the task of choosing a key for a cluster to that of choosing-between/combining two non-null keys.
    Author:
    Tom Gibara
    • Constructor Detail

      • GvmSimpleKeyer

        public GvmSimpleKeyer()
    • Method Detail

      • mergeKeys

        public K mergeKeys​(GvmCluster<?,​K> c1,
                           GvmCluster<?,​K> c2)
        Description copied from interface: GvmKeyer
        Called when two clusters are being merged. One key needs to be chosen/synthesized from those of the clusters being merged.
        Specified by:
        mergeKeys in interface GvmKeyer<K>
        Parameters:
        c1 - the cluster with the greater mass
        c2 - the cluster with the lesser mass
        Returns:
        a key for the cluster that combines those of c1 and c2, may be null
      • addKey

        public K addKey​(GvmCluster<?,​K> cluster,
                        K k2)
        Description copied from interface: GvmKeyer
        Called when a key is being added to a cluster.
        Specified by:
        addKey in interface GvmKeyer<K>
        Parameters:
        cluster - a cluster
        k2 - the key for a newly clustered coordinate
        Returns:
        the key to be assigned to the new cluster, may be null
      • combineKeys

        protected abstract K combineKeys​(K k1,
                                         K k2)
        Combines two keys. Combining two keys may totally discard information from one, both or none of the supplied keys.
        Parameters:
        k1 - a key, not null
        k2 - a key, not null
        Returns:
        a combined key