All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xxl.mathematica.list.Count Maven / Gradle / Ivy

package xxl.mathematica.list;

import java.util.List;
import java.util.function.Predicate;

/**
 * 计数
 */

public class Count {
    /**
     * 给出 list 中匹配 p 的元素个数.
     *
     * @param list
     * @param p
     * @param 
     * @return
     */
    public static  int count(List list, Predicate p) {
        return io.vavr.collection.List.ofAll(list)
                .count(p);
    }

    /**
     * 计算t的个数
     *
     * @param list
     * @param t
     * @param 
     * @return
     */
    public static  int count(List list, T t) {
        return count(list, (Predicate) cur -> cur.equals(t));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy