Wrap union-find into class.