Single Pass Cluster Assignment in JAVA