<commit_before>package com.cafeform.algorithm;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.LinkedBlockingDeque;

/**
 * @author kaizawa
 */
class BreadthFirstSearch extends SearchAlgorithm {

    LinkedBlockingDeque<ArrayList> foundNodeQueue = new LinkedBlockingDeque<>();
    List<ArrayList> goaledPathList = new ArrayList<>();
    Set<Node> foundNodeSet = new HashSet<>(); // Found, but has not children search 

    public BreadthFirstSearch(Node startNode, Node goalNode) {
        this.startNode = startNode;
        this.goalNode = goalNode;
    }

    @Override
    public SearchResult doSearch() {
        // List of Node which represents path.
        ArrayList<Node> currentPath = new ArrayList<>();
        currentPath.add(startNode);
        
        foundNodeQueue.add(currentPath);

        while(false == foundNodeQueue.isEmpty()){
            Node currentNode = currentPath.get(currentPath.size()-1);

            if (currentNode == goalNode) {
                goaledPathList.add(currentPath);
            } else {
                for (Node child : (Set<Node>) currentNode.getChildrenMap().keySet()) {
                    //Check if it has already been found
                    if (foundNodeSet.contains(child)) {
                        // This node has ever been found.
                        continue;
                    }
                    ArrayList childPath = (ArrayList) currentPath.clone();
                    childPath.add(child);

                    // Put child path to the gray queue.
                    foundNodeQueue.add(childPath);
                    foundNodeSet.add(child);
                }
            }
            currentPath = foundNodeQueue.poll();
        } 
        // Return path which found first
        return new SearchResult(goaledPathList.get(0));
    }
}<commit_msg>Mod: return emptyList if no path was found<commit_after>package com.cafeform.algorithm;

import java.util.*;
import java.util.concurrent.LinkedBlockingDeque;

/**
 * @author kaizawa
 */
class BreadthFirstSearch extends SearchAlgorithm {

    LinkedBlockingDeque<ArrayList> foundNodeQueue = new LinkedBlockingDeque<>();
    List<ArrayList> goaledPathList = new ArrayList<>();
    Set<Node> foundNodeSet = new HashSet<>(); // Found, but has not children search 

    public BreadthFirstSearch(Node startNode, Node goalNode) {
        this.startNode = startNode;
        this.goalNode = goalNode;
    }

    @Override
    public SearchResult doSearch() {
        // List of Node which represents path.
        ArrayList<Node> currentPath = new ArrayList<>();
        currentPath.add(startNode);
        
        foundNodeQueue.add(currentPath);

        while(false == foundNodeQueue.isEmpty()){
            Node currentNode = currentPath.get(currentPath.size()-1);

            if (currentNode == goalNode) {
                goaledPathList.add(currentPath);
            } else {
                for (Node child : (Set<Node>) currentNode.getChildrenMap().keySet()) {
                    //Check if it has already been found
                    if (foundNodeSet.contains(child)) {
                        // This node has ever been found.
                        continue;
                    }
                    ArrayList childPath = (ArrayList) currentPath.clone();
                    childPath.add(child);

                    // Put child path to the gray queue.
                    foundNodeQueue.add(childPath);
                    foundNodeSet.add(child);
                }
            }
            currentPath = foundNodeQueue.poll();
        } 
        // Return path which found first        
        List<Node> firstPath = goaledPathList.isEmpty() ? Collections.emptyList() : goaledPathList.get(0);
        return new SearchResult(firstPath);
    }
}
{'fraction_non_alphanumeric': 0.09744119927629878, 'fraction_numerical': 0.001033858878263117, 'mean_word_length': 1.9407294832826747, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, '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': '1784556', 'n_tokens_mistral': 1002, 'n_tokens_neox': 946, 'n_words': 238}