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

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

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

List.filter介绍

[英]Filters elements from this list by returning only elements which produce true when the given function is applied to them.
[中]通过仅返回在对元素应用给定函数时生成true的元素,筛选此列表中的元素。

代码示例

代码示例来源:origin: ontop/ontop

public List<Function> filterBooleanAtoms(List<Function> atoms) {
  return atoms.filter(IS_BOOLEAN_ATOM_FCT);
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-model

public static List<Function> filterNonDataAndCompositeAtoms(List<Function> atoms) {
  return atoms.filter(IS_NOT_DATA_OR_COMPOSITE_ATOM_FCT);
}

代码示例来源:origin: ontop/ontop

public List<Function> filterNonDataAndCompositeAtoms(List<Function> atoms) {
  return atoms.filter(IS_NOT_DATA_OR_COMPOSITE_ATOM_FCT);
}

代码示例来源:origin: ontop/ontop

public List<Function> filterDataAndCompositeAtoms(List<Function> atoms) {
  return atoms.filter(IS_DATA_OR_LJ_OR_JOIN_ATOM_FCT);
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-model

public static List<Function> filterDataAndCompositeAtoms(List<Function> atoms) {
  return atoms.filter(IS_DATA_OR_LJ_OR_JOIN_ATOM_FCT);
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-model

public static List<Function> filterBooleanAtoms(List<Function> atoms) {
  return atoms.filter(IS_BOOLEAN_ATOM_FCT);
}

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

/**
 * Filters elements from this list by returning only elements which produce <code>false</code> when
 * the given function is applied to them.
 *
 * @param f The predicate function to filter on.
 * @return A new list whose elements do not match the given predicate.
 */
public final List<A> removeAll(final F<A, Boolean> f) {
 return filter(compose(not, f));
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-optimization

/**
 * Only boolean atoms are pushable.
 */
private static P2<List<Function>,List<Function>> splitPushableAtoms(List<Function> atoms) {
  List<Function> nonPushableAtoms = atoms
      .filter(atom -> !isPushable(atom));
  List<Function> pushableAtoms = atoms.filter(PullOutEqualityNormalizerImpl::isPushable);
  return P.p(nonPushableAtoms, pushableAtoms);
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-model

/**
 * Practical criterion for detecting a real join: having more data/composite atoms.
 *
 * May produces some false negatives for crazy abusive nested joins of boolean atoms (using JOIN instead of AND).
 */
public static boolean isRealJoin(List<Function> subAtoms) {
  //TODO: reuse a shared static filter fct object.
  List<Function> dataAndCompositeAtoms = subAtoms.filter(new F<Function, Boolean>() {
    @Override
    public Boolean f(Function atom) {
      return isDataOrLeftJoinOrJoinAtom(atom);
    }
  });
  return dataAndCompositeAtoms.length() > 1;
}

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

public static <A, E> List<A> successes(List<Validation<?, A>> list) {
  return list.filter(Validation::isSuccess).map(v -> v.success());
}

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

public static <A, E> List<E> fails(List<Validation<E, ?>> list) {
  return list.filter(Validation::isFail).map(v -> v.fail());
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-optimization

private static Optional<Function> extractOptionalGroupAtom(List<Function> atoms)
    throws DatalogProgram2QueryConverterImpl.InvalidDatalogProgramException {
  List<Function> groupAtoms = atoms.filter(atom -> atom.getFunctionSymbol().equals(
      DatalogAlgebraOperatorPredicates.SPARQL_GROUP));
  switch(groupAtoms.length()) {
    case 0:
      return Optional.empty();
    case 1:
      return Optional.of(groupAtoms.head());
    default:
      throw new DatalogProgram2QueryConverterImpl.InvalidDatalogProgramException("Multiple GROUP atoms found in the same body! " +
          groupAtoms);
  }
}

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

/**
 * Partitions the list into the list of fails and the list of successes
 */
public static <A, B> P2<List<A>, List<B>> partition(List<Validation<A, B>> list) {
 return p(
     list.filter(Validation::isFail).map(v -> v.fail()),
     list.filter(Validation::isSuccess).map(v -> v.success())
 );
}

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

/**
 * Returns all the values in the given list.
 *
 * @param as The list of potential values to get actual values from.
 * @return All the values in the given list.
 */
public static <A> List<A> somes(final List<Option<A>> as) {
 return as.filter(Option.isSome_()).map(o -> o.some());
}

代码示例来源:origin: org.codehaus.mojo.unix/unix-pkg

public void streamTo( final LineStreamWriter stream )
{
  System.out.println( PackageFileSystemFormatter.<PrototypeEntry>flatFormatter().print( fileSystem ) );
  stream.
    addAllLines( iFiles.reverse() );
  for ( PackageFileSystemObject<PrototypeEntry> object : fileSystem.prettify().toList().filter( filterRoot ) )
  {
    object.getExtension().streamTo( stream );
  }
}

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

/**
 * Removes duplicates according to the given equality. Warning: O(n^2).
 *
 * @param eq Equality over the elements.
 * @return A list without duplicates.
 */
public final List<A> nub(final Equal<A> eq) {
 return isEmpty() ? this : cons(head(), tail().filter(a -> !eq.eq(a, head())).nub(eq));
}

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

/**
 * If the list contains a failure, returns a Validation of the list of
 * fails in the list, otherwise returns a successful Validation with
 * the list of successful values.  Does not accumulate the failures into a
 * single failure using a semigroup.
 */
 public static <A, E> Validation<List<E>, List<A>> sequenceNonCumulative(List<Validation<E, A>> list) {
  if (list.exists(Validation::isFail)) {
   F2<List<E>, Validation<E, A>, List<E>> f = (acc, v) -> acc.cons(v.fail());
   return fail(list.filter(Validation::isFail).foldLeft(f, List.nil()).reverse());
  } else {
   F2<List<A>, Validation<E, A>, List<A>> f = (acc, v) -> acc.cons(v.success());
   return success(list.filter(Validation::isSuccess).foldLeft(f, List.nil()).reverse());
  }
 }

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

/**
 * If list contains a failure, returns a failure of the reduction of
 * all the failures using the semigroup, otherwise returns the successful list.
 */
public static <E, A> Validation<E, List<A>> sequence(final Semigroup<E> s, final List<Validation<E, A>> list) {
 if (list.exists(Validation::isFail)) {
  return Validation.fail(list.filter(Validation::isFail).map(v -> v.fail()).foldLeft1((F2<E, E, E>) s::sum));
 } else {
  return success(list.foldLeft((List<A> acc, Validation<E, A> v) -> acc.cons(v.success()), List.nil()).reverse());
 }
}

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

public Execution createExecution( String id, String format, File scripts, File toDir, Strategy strategy )
{
  F<String, List<String>> expand = curry( modulatePath, id, format );
  F<ScriptFile, List<String>> f = compose( expand, strategy.accessor );
  F<String, File> newScriptsFile = curry( FileF.newFile, scripts );
  List<File> preInstallFiles = f.f( preInstall ).map( newScriptsFile ).filter( canRead );
  List<File> postInstallFiles = f.f( postInstall ).map( newScriptsFile ).filter( canRead );
  List<File> preRemoveFiles = f.f( preRemove ).map( newScriptsFile ).filter( canRead );
  List<File> postRemoveFiles = f.f( postRemove ).map( newScriptsFile ).filter( canRead );
  List<Callable<File>> customFiles = nil();
  for ( String customScript : customScripts )
  {
    F<ScriptFile, List<String>> toFilesCustom = compose( expand, ScriptFile.specificNameF );
    List<File> list = toFilesCustom.f( new ScriptFile( null, customScript ) ).
      map( newScriptsFile ).
      filter( canRead );
    if ( list.isNotEmpty() )
    {
      customFiles = customFiles.cons( curry( copyFiles, new File( toDir, customScript ) ).f( list ) );
    }
  }
  return new Execution(
    iif( List.<File>isNotEmpty_(), preInstallFiles ).map( curry( copyFiles, preInstall.toFile( toDir ) ) ),
    iif( List.<File>isNotEmpty_(), postInstallFiles ).map( curry( copyFiles, postInstall.toFile( toDir ) ) ),
    iif( List.<File>isNotEmpty_(), preRemoveFiles ).map( curry( copyFiles, preRemove.toFile( toDir ) ) ),
    iif( List.<File>isNotEmpty_(), postRemoveFiles ).map( curry( copyFiles, postRemove.toFile( toDir ) ) ), customFiles );
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-optimization

.filter(DatalogTools::isLeftJoinOrJoinAtom)
.map(atom -> normalizeCompositeAtom(atom, variableDispatcher));

相关文章