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

xxl.mathematica.predication.MemberQ Maven / Gradle / Ivy

package xxl.mathematica.predication;


import xxl.mathematica.logic.AnyTrue;

import java.util.List;
import java.util.function.BiPredicate;

/**
 * 成员判定
 */

public class MemberQ {
    /**
     * 用来判断 list 的一个元素是否与 item 匹配,若是,则返回 True,否则返回 False.
     *
     * @param list
     * @param item
     * @param 
     * @return
     */
    public static  boolean memberQ(List list, T item, BiPredicate p) {
        return AnyTrue.anyTrue(list, t -> p.test(item, t));
    }

    /**
     * 使用equals方法比较相等性
     *
     * @param list
     * @param item
     * @param 
     * @return
     */
    public static  boolean memberQ(List list, T item) {
        return memberQ(list, item, Object::equals);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy