<commit_before>// Copyright (c) 2013-present, febit.org. All Rights Reserved.
package org.febit.util;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;

/**
 *
 * @author zqq90
 */
public class ArraysUtil extends jodd.util.ArraysUtil {

    public static Object get(final Object[] array, final int index, final Object defaultValue) {
        if (array != null && index < array.length) {
            return array[index];
        }
        return defaultValue;
    }

    public static String get(final String[] array, final int index, final String defaultValue) {
        if (array != null && index < array.length) {
            return array[index];
        }
        return defaultValue;
    }

    public static <E> int read(Iterator<E> it, E[] array) {
        int i = 0;
        for (; i < array.length && it.hasNext();) {
            E item = it.next();
            if (item != null) {
                array[i++] = item;
            }
        }
        return i;
    }

    @Deprecated
    public static int searchInterval(final int[] intervals, final int number) {
        return findInterval(intervals, number);
    }

    /**
     * Search which interval the number belongs to.
     *
     * <p>
     * [x-1] &gt; number &lt;= [x] => x </p>
     *
     * @param intervals
     * @param number
     * @return from 0 to length
     */
    public static int findInterval(final int[] intervals, final int number) {
        int start = 0;
        int end = intervals.length - 1;
        // <= min
        if (number <= intervals[0]) {
            return 0;
        }
        // > max
        if (number > intervals[end]) {
            return end + 1;
        }

        for (;;) {

            int middle = (start + end) / 2;

            // the last matched interval
            if (middle == start) {
                return end;
            }

            if (number > intervals[middle]) {
                start = middle;
            } else {
                end = middle;
            }
        }
    }

    /**
     * Find which interval the number belongs to.
     *
     * <p>
     * [x-1] &gt; number &lt;= [x] => x </p>
     *
     * @param intervals
     * @param number
     * @return from 0 to length
     */
    public static int findInterval(final long[] intervals, final long number) {
        int start = 0;
        int end = intervals.length - 1;
        // <= min
        if (number <= intervals[0]) {
            return 0;
        }
        // > max
        if (number > intervals[end]) {
            return end + 1;
        }

        for (;;) {

            int middle = (start + end) / 2;

            // the last matched interval
            if (middle == start) {
                return end;
            }<commit_msg>fix java doc<commit_after>// Copyright (c) 2013-present, febit.org. All Rights Reserved.
package org.febit.util;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;

/**
 *
 * @author zqq90
 */
public class ArraysUtil extends jodd.util.ArraysUtil {

    public static Object get(final Object[] array, final int index, final Object defaultValue) {
        if (array != null && index < array.length) {
            return array[index];
        }
        return defaultValue;
    }

    public static String get(final String[] array, final int index, final String defaultValue) {
        if (array != null && index < array.length) {
            return array[index];
        }
        return defaultValue;
    }

    public static <E> int read(Iterator<E> it, E[] array) {
        int i = 0;
        for (; i < array.length && it.hasNext();) {
            E item = it.next();
            if (item != null) {
                array[i++] = item;
            }
        }
        return i;
    }

    @Deprecated
    public static int searchInterval(final int[] intervals, final int number) {
        return findInterval(intervals, number);
    }

    /**
     * Search which interval the number belongs to.
     *
     * <p>
     * [x-1] &gt; number &lt;= [x] => x </p>
     *
     * @param intervals
     * @param number
     * @return from 0 to length
     */
    public static int findInterval(final int[] intervals, final int number) {
        int start = 0;
        int end = intervals.length - 1;
        // <= min
        if (number <= intervals[0]) {
            return 0;
        }
        // > max
        if (number > intervals[end]) {
            return end + 1;
        }

        for (;;) {

            int middle = (start + end) / 2;

            // the last matched interval
            if (middle == start) {
                return end;
            }

            if (number > intervals[middle]) {
                start = middle;
            } else {
                end = middle;
            }
        }
    }

    /**
     * Find which interval the number belongs to.
     *
     * <p>
     * number &lt;= [0] returns 0 </p>
     * <p>
     * [x-1] &lt; number &lt;= [x] returns x </p>
     * <p>
     * [length-1] &lt; number returns length </p>
     *
     * @param intervals
     * @param number
     * @return from 0 to length
     */
    public static int findInterval(final long[] intervals, final long number) {
        int start = 0;
        int end = intervals.length - 1;
        // <= min
        if (number <= intervals[0]) {
            return 0;
        }
        // > max
        if (number > intervals[end]) {
            return end + 1;
        }

        for (;;) {

            int middle = (start + end) / 2;

            // the last matched interval
            if (middle == start) {
                return end;
            }
{'fraction_non_alphanumeric': 0.12073400788886983, 'fraction_numerical': 0.008403361344537815, 'mean_word_length': 1.4965753424657535, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 32, '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': '2880503', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1640, 'n_words': 523}