public int find ( int cur ) { assert ( cur >= 0 && cur < parent . length ) ; int p = parent [ cur ] , tmp ; while ( cur != p ) { tmp = p ; p = parent [ cur ] = parent [ p ] ; // Perform simple path compression. cur = tmp ; } return cur ; }
Find the parent of an object .