static protected int countSharedNeighbors ( DBIDs neighbors1 , DBIDs neighbors2 ) { int intersection = 0 ; DBIDIter iter1 = neighbors1 . iter ( ) ; DBIDIter iter2 = neighbors2 . iter ( ) ; while ( iter1 . valid ( ) && iter2 . valid ( ) ) { final int comp = DBIDUtil . compare ( iter1 , iter2 ) ; if ( comp == 0 ) { intersection ++ ; iter1 . advance ( ) ; iter2 . advance ( ) ; } else if ( comp < 0 ) { iter1 . advance ( ) ; } else // iter2 < iter1 { iter2 . advance ( ) ; } } return intersection ; }
Compute the intersection size