<commit_before>package net.squanchy.support.lang;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public final class Lists {

    public static <T, R> List<R> map(List<T> list, Func1<T, R> function) {
        if (list == null || list.isEmpty()) {
            return Collections.emptyList();
        }

        List<R> result = new ArrayList<>(list.size());
        for (T t : list) {
            result.add(function.call(t));
        }

        return result;
    }

    public static <T> List<T> filter(List<T> list, Predicate<T> predicate) {
        if (list == null || list.isEmpty()) {
            return Collections.emptyList();
        }

        List<T> result = new ArrayList<>(list.size());
        for (T t : list) {
            if (predicate.call(t)) {
                result.add(t);
            }
        }

        return result;
    }

    public static <T> Optional<T> find(List<T> list, Func1<T, Boolean> predicate) {
        for (T t : list) {
            if (predicate.call(t)) {
                return Optional.of(t);
            }
        }

        return Optional.absent();
    }

    public static <T, R> R reduce(R initial, List<T> list, Func2<R, T, R> reducer) {
        R reducedValue = initial;
        for (T t : list) {
            reducedValue = reducer.call(reducedValue, t);
        }

        return reducedValue;
    }
}<commit_msg>add the any utility method for Lists<commit_after>package net.squanchy.support.lang;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public final class Lists {

    public static <T, R> List<R> map(List<T> list, Func1<T, R> function) {
        if (list == null || list.isEmpty()) {
            return Collections.emptyList();
        }

        List<R> result = new ArrayList<>(list.size());
        for (T t : list) {
            result.add(function.call(t));
        }

        return result;
    }

    public static <T> List<T> filter(List<T> list, Predicate<T> predicate) {
        if (list == null || list.isEmpty()) {
            return Collections.emptyList();
        }

        List<T> result = new ArrayList<>(list.size());
        for (T t : list) {
            if (predicate.call(t)) {
                result.add(t);
            }
        }

        return result;
    }

    public static <T> Optional<T> find(List<T> list, Func1<T, Boolean> predicate) {
        for (T t : list) {
            if (predicate.call(t)) {
                return Optional.of(t);
            }
        }

        return Optional.absent();
    }

    public static <T, R> R reduce(R initial, List<T> list, Func2<R, T, R> reducer) {
        R reducedValue = initial;
        for (T t : list) {
            reducedValue = reducer.call(reducedValue, t);
        }

        return reducedValue;
    }

    public static <T> boolean any(List<T> list, Predicate<T> predicate) {
        if (list == null) {
            return false;
        }
        for (T t : list) {
            if (predicate.call(t)) {
                return true;
            }
        }

        return false;
    }
}
{'fraction_non_alphanumeric': 0.13311897106109324, 'fraction_numerical': 0.0019292604501607716, 'mean_word_length': 1.7506631299734747, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 44, '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': '1212800', 'n_tokens_mistral': 978, 'n_tokens_neox': 944, 'n_words': 249}