<commit_before>package com.github.andriell.collection;

import java.util.Arrays;

/**
 * Created by Vika on 07.02.2016
 */
public class HashThree<T> {
    private HashThree[] three;
    private T value;

    public boolean add(T t) {
        return add(t, false);
    }

    public boolean replace(T t) {
        return add(t, true);
    }

    private boolean add(T t, boolean replace) {
        int hash = t.hashCode();
        HashThree position = this;
        while(hash != 0) {
            if (position.three == null) {
                position.three = new HashThree[8];
            }
            int index = hash & 7;
            if (position.three[index] == null) {
                position.three[index] = new HashThree();
            }
            position = position.three[index];
            hash = hash >>> 3;
        }
        if (position.value == null) {
            position.value = t;
            return true;
        } else if (replace) {
            position.value = t;
            return true;
        }
        return false;
    }


    @Override
    public String toString() {
        if (value == null) {
            return Arrays.deepToString(three);
        } else {
            return "Value: " + value;
        }
    }
}
<commit_msg>start<commit_after>package com.github.andriell.collection;

import java.util.Arrays;

/**
 * Created by Vika on 07.02.2016
 */
public class HashThree<T> {
    private HashThree[] three;
    private T value;

    public boolean add(T t) {
        return add(t, false);
    }

    public boolean replace(T t) {
        return add(t, true);
    }

    private boolean add(T t, boolean replace) {
        int hash = t.hashCode();
        HashThree position = this;
        while(hash != 0) {
            if (position.three == null) {
                position.three = new HashThree[8];
            }
            int index = hash & 7;
            hash = hash >>> 3;
            if (position.three[index] == null) {
                position.three[index] = new HashThree();
            }
            position = position.three[index];
        }
        if (position.value == null) {
            position.value = t;
            return true;
        } else if (replace) {
            position.value = t;
            return true;
        }
        return false;
    }

    @Override
    public String toString() {
        if (three == null) {
            return "null";
        }
        StringBuilder builder = new StringBuilder();
        toString(this, builder, "");
        return builder.toString();
    }

    public void toString(HashThree position, StringBuilder builder, String tab) {
        builder.append("\n");
        if (position.three == null) {
            builder.append(tab);
            builder.append("Value: ");
            builder.append(position.value);
            return;
        }
        for(int i = 0; i < 8; i++) {
            if (position.three[i] != null) {
                builder.append(tab);
                builder.append(i);
                builder.append(": ");
                toString(position.three[i], builder, tab + "    ");

            }
        }

    }
}

{'fraction_non_alphanumeric': 0.11904761904761904, 'fraction_numerical': 0.008253968253968255, 'mean_word_length': 1.4889415481832544, 'pattern_counts': {'":': 1, '<': 6, '<?xml version=': 0, '>': 11, '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': '675853', 'n_tokens_mistral': 895, 'n_tokens_neox': 861, 'n_words': 227}