<commit_before>
package codesample.algorithms.union;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * This is a Union implementation with quick 'connect' operation.
 *
 * connect (node1, node2). Takes up to log(n)
 * areConnected (node1, node2). Takes up to log(n).
 *
 * This implementation watch for tree sizesMap when adding elements making
 * sure that when connectiong 2 trees the bigger one would get connected to smaller one which decrees tree sizesMap and
 * improve overall working time
 *
 * */
public class UnionWithQuickUnionOperationWeighted<T extends Comparable<T>> implements Union<T>{

    private Map<T, T> valuesMap;
    private Map<T, Integer> sizesMap;


    public UnionWithQuickUnionOperationWeighted() {
        valuesMap = new HashMap<>();<commit_msg>Better comments for unions<commit_after>
package codesample.algorithms.union;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * This is a Union implementation with quick 'connect' operation.
 *
 * connect (node1, node2). Takes up to log(n)
 * areConnected (node1, node2). Takes up to log(n).
 *
 * This implementation watch for tree sizesMap when adding elements making
 * sure that when connecting 2 trees the smaller one would get connected to bigger one which decrees overall tree size.
 *
 * The tree size will not get increased unless two trees with the same size are getting connected. If that's the case
 * */
public class UnionWithQuickUnionOperationWeighted<T extends Comparable<T>> implements Union<T>{

    private Map<T, T> valuesMap;
    private Map<T, Integer> sizesMap;


    public UnionWithQuickUnionOperationWeighted() {
        valuesMap = new HashMap<>();
{'fraction_non_alphanumeric': 0.08478382930937675, 'fraction_numerical': 0.005614823133071308, 'mean_word_length': 4.416413373860182, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '6278865', 'n_tokens_mistral': 491, 'n_tokens_neox': 481, 'n_words': 195}