<commit_before>package pl.edu.icm.coansys.disambiguation.auxil;

import java.util.Arrays;

/**
 * 
 * @author pdendek
 * @since 2013-08-26
 */
public class RankedUnionFindPathCompressed {
	
	int[] cluster = null;
	int[] rank = null; 
	
	public RankedUnionFindPathCompressed(int elementNumber){
		cluster = new int[elementNumber];
		for(int i=0;i<elementNumber;i++){
			cluster[i]=i;
		}
		rank = new int[elementNumber];
		Arrays.fill(rank, 0);
	}
	
	public void union(int p,int q){
		int k1 = getRoot(p);
		int k2 = getRoot(q);
		
		if(rank[k1]==rank[k2]){
			rank[k1]++;
			cluster[k2]=k1;
		}else if(rank[k1]>rank[k2]){
			cluster[k1]=k2;
		}else{
			cluster[k2]=k1;
		}
	}
	
	protected int getRootWithoutChange(int p){
		while(p!=cluster[p]){
			p = cluster[p]; 
		}
		return p;
	}
	
	protected int getRoot(int p){
		int r = getRootWithoutChange(p);
		int next = -1;
		while(p!=r){
			next=cluster[p];
			cluster[p]=r;
			p=next;
		}
		return p;
	}
	
	protected int getRoot(int p, boolean[] touched){
		int r = getRootWithoutChange(p);
		int next = -1;
		while(p!=r){
			next=cluster[p];
			cluster[p]=r;
			touched[p]=true;
			p=next;
		}
		return p;
	}
	
	public boolean find(int p, int q){
		return find(p,q);
	}

	public int[] getAssignmentArray() {
		return cluster;
	}

	public void finalUnite() {
		boolean[] touched = new boolean[cluster.length];
		Arrays.fill(touched, false);
		for(int i=0;i<cluster.length;i++){
			if(touched[i]) continue;
			getRoot(i,touched);
		}
	}
}
<commit_msg>critical bugfix<commit_after>package pl.edu.icm.coansys.disambiguation.auxil;

import java.util.Arrays;

/**
 * 
 * @author pdendek
 * @since 2013-08-26
 */
public class RankedUnionFindPathCompressed {
	
	int[] cluster = null;
	int[] rank = null; 
	
	public RankedUnionFindPathCompressed(int elementNumber){
		cluster = new int[elementNumber];
		for(int i=0;i<elementNumber;i++){
			cluster[i]=i;
		}
		rank = new int[elementNumber];
		Arrays.fill(rank, 0);
	}
	
	public void union(int p,int q){
		int k1 = getRoot(p);
		int k2 = getRoot(q);
		
		if(rank[k1]==rank[k2]){
			rank[k1]++;
			cluster[k2]=k1;
		}else if(rank[k1]>rank[k2]){
			cluster[k1]=k2;
		}else{
			cluster[k2]=k1;
		}
	}
	
	protected int getRootWithoutChange(int p){
		while(p!=cluster[p]){
			p = cluster[p]; 
		}
		return p;
	}
	
	protected int getRoot(int p){
		int r = getRootWithoutChange(p);
		int next = -1;
		while(p!=r){
			next=cluster[p];
			cluster[p]=r;
			p=next;
		}
		return p;
	}
	
	protected int getRoot(int p, boolean[] touched){
		int r = getRootWithoutChange(p);
		int next = -1;
		while(p!=r){
			next=cluster[p];
			cluster[p]=r;
			touched[p]=true;
			p=next;
		}
		return p;
	}
	
	public boolean find(int p, int q){
		return getRoot(p)==getRoot(q);
	}

	public int[] getAssignmentArray() {
		return cluster;
	}

	public void finalUnite() {
		boolean[] touched = new boolean[cluster.length];
		Arrays.fill(touched, false);
		for(int i=0;i<cluster.length;i++){
			if(touched[i]) continue;
			getRoot(i,touched);
		}
	}
}

{'fraction_non_alphanumeric': 0.16572567253404186, 'fraction_numerical': 0.017270009963467288, 'mean_word_length': 3.6338461538461537, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2410705', 'n_tokens_mistral': 1389, 'n_tokens_neox': 1205, 'n_words': 243}