<commit_before>package org.hanuna.gitalk.commitgraph.order;

import org.hanuna.gitalk.commitgraph.Node;
import org.hanuna.gitalk.commitmodel.Commit;
import org.hanuna.gitalk.commitmodel.CommitsModel;
import org.hanuna.gitalk.common.ReadOnlyList;
import org.hanuna.gitalk.common.calculatemodel.calculator.AbstractCalculator;
import org.jetbrains.annotations.NotNull;

/**
 * @author erokhins
 */
public class RowOfNodeCalculator extends AbstractCalculator<MutableRowOfNode, RowOfNode> {
    private final CommitsModel commitsModel;

    public RowOfNodeCalculator(CommitsModel commitsModel) {
        this.commitsModel = commitsModel;
    }

    @NotNull
    @Override
    public RowOfNode getFirst() {
        assert commitsModel.size() > 0 : "empty CommitsModel";
        Node firstNode = new Node(commitsModel.get(0), 0);
        MutableRowOfNode firstRow = MutableRowOfNode.getEmpty(0, 0);
        firstRow.addNode(0, firstNode);
        return firstRow;
    }

    @NotNull
    @Override
    protected MutableRowOfNode createMutable(RowOfNode prev) {
        return MutableRowOfNode.create(prev);
    }

    @Override
    protected int size() {
        return commitsModel.size();
    }

    // true, if node was add
    private boolean addNode(MutableRowOfNode row, Node node, int indexAdd) {
        int index = row.getIndexOfCommit(node.getCommit());
        if (index != -1) {
            Node oldNode = row.get(index);
            if (oldNode.getColorIndex() > node.getColorIndex()) {
                row.set(index, node);
            }
            return false;
        } else {
            row.addNode(indexAdd, node);
            return true;
        }
    }

    @NotNull
    protected MutableRowOfNode oneStep(MutableRowOfNode row) {
        Commit prevCommit = commitsModel.get(row.getRowIndex());
        int prevCommitIndex = row.getIndexOfCommit(prevCommit);
        assert prevCommitIndex != -1 : "bad prev row";
        Node prevNode = row.removeNode(prevCommitIndex);
        ReadOnlyList<Commit> parents = prevCommit.getParents();

        int countNewNode = 0;
        for (int i = 0; i < parents.size(); i++) {<commit_msg>fix color set<commit_after>package org.hanuna.gitalk.commitgraph.order;

import org.hanuna.gitalk.commitgraph.Node;
import org.hanuna.gitalk.commitmodel.Commit;
import org.hanuna.gitalk.commitmodel.CommitsModel;
import org.hanuna.gitalk.common.ReadOnlyList;
import org.hanuna.gitalk.common.calculatemodel.calculator.AbstractCalculator;
import org.jetbrains.annotations.NotNull;

/**
 * @author erokhins
 */
public class RowOfNodeCalculator extends AbstractCalculator<MutableRowOfNode, RowOfNode> {
    private final CommitsModel commitsModel;

    public RowOfNodeCalculator(CommitsModel commitsModel) {
        this.commitsModel = commitsModel;
    }

    @NotNull
    @Override
    public RowOfNode getFirst() {
        assert commitsModel.size() > 0 : "empty CommitsModel";
        Node firstNode = new Node(commitsModel.get(0), 0);
        MutableRowOfNode firstRow = MutableRowOfNode.getEmpty(0, 0);
        firstRow.addNode(0, firstNode);
        return firstRow;
    }

    @NotNull
    @Override
    protected MutableRowOfNode createMutable(RowOfNode prev) {
        return MutableRowOfNode.create(prev);
    }

    @Override
    protected int size() {
        return commitsModel.size();
    }

    // true, if node was add
    private boolean addNode(MutableRowOfNode row, Node node, int indexAdd) {
        int index = row.getIndexOfCommit(node.getCommit());
        if (index != -1) {
            return false;
        } else {
            row.addNode(indexAdd, node);
            return true;
        }
    }

    @NotNull
    protected MutableRowOfNode oneStep(MutableRowOfNode row) {
        Commit prevCommit = commitsModel.get(row.getRowIndex());
        int prevCommitIndex = row.getIndexOfCommit(prevCommit);
        assert prevCommitIndex != -1 : "bad prev row";
        Node prevNode = row.removeNode(prevCommitIndex);
        ReadOnlyList<Commit> parents = prevCommit.getParents();

        int countNewNode = 0;
        for (int i = 0; i < parents.size(); i++) {
{'fraction_non_alphanumeric': 0.09900750423626241, 'fraction_numerical': 0.004841442749939482, 'mean_word_length': 2.9389895138226882, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, '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': '4263842', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1226, 'n_words': 264}