void joinClusters ( int mouth , int food ) { List < Node > listMouth = clusters . get ( mouth ) ; List < Node > listFood = clusters . get ( food ) ; // put all members of food into mouth for ( int i = 0 ; i < listFood . size ( ) ; i ++ ) { listMouth . add ( listFood . get ( i ) ) ; listFood . get ( i ) . cluster = mouth ; } // zero food members listFood . clear ( ) ; }
Moves all the members of food into mouth