netflix.algorithms.memorybased.rectree
Class ClusterCollection

java.lang.Object
  extended by netflix.algorithms.memorybased.rectree.ClusterCollection
All Implemented Interfaces:
cern.colt.function.IntIntProcedure

public class ClusterCollection
extends java.lang.Object
implements cern.colt.function.IntIntProcedure

Class to convert a hashtable from uid to cluster to an array of IntArrayLists representing each cluster. We make this a separate class so that it can be used with the forEachPair method in the OpenIntIntHashMap class in the colt package. Cerns code to iterate through a hashtable is almost certainly faster than mine would be.


Constructor Summary
ClusterCollection(java.util.ArrayList<cern.colt.list.IntArrayList> clusters, MemHelper helper)
           
ClusterCollection(int k, MemHelper helper)
           
 
Method Summary
 boolean apply(int first, int second)
          Adds user first to cluster second.
 double getAverage(int cluster)
           
 cern.colt.list.IntArrayList getCluster(int cluster)
           
 java.util.ArrayList<cern.colt.list.IntArrayList> getClusters()
           
 int getClusterSize(int cluster)
           
 void printClusters()
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusterCollection

public ClusterCollection(int k,
                         MemHelper helper)
Parameters:
k - Number of clusters.

ClusterCollection

public ClusterCollection(java.util.ArrayList<cern.colt.list.IntArrayList> clusters,
                         MemHelper helper)
Method Detail

getClusters

public java.util.ArrayList<cern.colt.list.IntArrayList> getClusters()

getCluster

public cern.colt.list.IntArrayList getCluster(int cluster)

getAverage

public double getAverage(int cluster)

size

public int size()

getClusterSize

public int getClusterSize(int cluster)

apply

public boolean apply(int first,
                     int second)
Adds user first to cluster second.

Specified by:
apply in interface cern.colt.function.IntIntProcedure
Returns:
true (not used).

printClusters

public void printClusters()