fj.data.List.find()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(77)

本文整理了Java中fj.data.List.find()方法的一些代码示例,展示了List.find()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.find()方法的具体详情如下:
包路径:fj.data.List
类名称:List
方法名:find

List.find介绍

[英]Finds the first occurrence of an element that matches the given predicate or no value if no elements match.
[中]查找与给定谓词匹配的元素的第一个匹配项,如果没有匹配的元素,则查找无值。

代码示例

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns <code>true</code> if the predicate holds for at least one of the elements of this list,
 * <code>false</code> otherwise (<code>false</code> for the empty list).
 *
 * @param f The predicate function to test on the elements of this list.
 * @return <code>true</code> if the predicate holds for at least one of the elements of this
 *         list.
 */
public final boolean exists(final F<A, Boolean> f) {
 return find(f).isSome();
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns an associated value with the given key in the list of pairs.
 *
 * @param e The test for equality on keys.
 * @param x The list of pairs to search.
 * @param a The key value to find the associated value of.
 * @return An associated value with the given key in the list of pairs.
 */
public static <A, B> Option<B> lookup(final Equal<A> e, final List<P2<A, B>> x, final A a) {
 return x.find(p -> e.eq(p._1(), a)).map(P2.__2());
}

代码示例来源:origin: com.stratio.mojo.unix/unix-rpm

public Option<String> f( List<String> tags )
  {
    if ( tags.find( curry( equals, "config" ) ).isSome() )
    {
      return some( "%config " );
    }
    if ( tags.find( curry( equals, "rpm:noreplace" ) ).isSome() )
    {
      return some( "%config(noreplace) " );
    }
    if ( tags.find( curry( equals, "rpm:missingok" ) ).isSome() )
    {
      return some( "%config(missingok) " );
    }
    if ( tags.find( curry( equals, "doc" ) ).isSome() )
    {
      return some( "%doc " );
    }
    if ( tags.find( curry( equals, "rpm:ghost" ) ).isSome() )
    {
      return some( "%ghost " );
    }
    return none();
  }
};

代码示例来源:origin: no.arktekk.unix/unix-rpm

public Option<String> f( List<String> tags )
  {
    if ( tags.find( curry( equals, "config" ) ).isSome() )
    {
      return some( "%config " );
    }
    if ( tags.find( curry( equals, "rpm:noreplace" ) ).isSome() )
    {
      return some( "%config(noreplace) " );
    }
    if ( tags.find( curry( equals, "rpm:missingok" ) ).isSome() )
    {
      return some( "%config(missingok) " );
    }
    if ( tags.find( curry( equals, "doc" ) ).isSome() )
    {
      return some( "%doc " );
    }
    if ( tags.find( curry( equals, "rpm:ghost" ) ).isSome() )
    {
      return some( "%ghost " );
    }
    return none();
  }
};

相关文章