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

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

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

List.isEmpty介绍

[英]Returns true if this list is empty, false otherwise.
[中]如果此列表为空,则返回true,否则返回false

代码示例

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

private static Optional<ImmutableExpression> createFilterExpression(List<Function> booleanAtoms) {
  if (booleanAtoms.isEmpty())
    return Optional.empty();
  return Optional.of(TERM_FACTORY.getImmutableExpression(DatalogTools.foldBooleanConditions(booleanAtoms)));
}

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

/**
 * Returns the tail of this list if there is one or the given argument if this list is empty.
 *
 * @param as The argument to return if this list is empty.
 * @return The tail of this list if there is one or the given argument if this list is empty.
 */
public final List<A> orTail(final F0<List<A>> as) {
 return isEmpty() ? as.f() : tail();
}

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

/**
 * Returns the head of this list if there is one or the given argument if this list is empty.
 *
 * @param a The argument to return if this list is empty.
 * @return The head of this list if there is one or the given argument if this list is empty.
 */
public final A orHead(final F0<A> a) {
 return isEmpty() ? a.f() : head();
}

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

/**
 * Reutrns the tail of the list, if any.
 * @return The optional tail of the list.
 */
public final Option<List<A>> tailOption() {
  return isEmpty() ? none() : some(tail());
}

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

public boolean hasPath( final RelativePath path )
{
  List<String> paths = path.toList();
  return paths.isEmpty() || find( root, paths ).isRight();
}

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

/**
 * Performs a left-fold reduction across this list. This function runs in constant space.
 */
public final A foldLeft1(final F2<A, A, A> f) {
 A x = head;
 for (List<A> xs = tail; !xs.isEmpty(); xs = xs.tail()) {
  x = f.f(x, xs.head());
 }
 return x;
}

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

/**
 * Returns the head of the list, if any.  Equivalent to {@link #toOption()} .
 *
 * @return The optional head of the list.
 */
public final Option<A> headOption() {
 return isEmpty() ? Option.none() : some(head());
}

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

/**
 * Returns whether or not all elements in the list are equal according to the given equality test.
 *
 * @param eq The equality test.
 * @return Whether or not all elements in the list are equal according to the given equality test.
 */
public final boolean allEqual(final Equal<A> eq) {
 return isEmpty() || tail().isEmpty() || eq.eq(head(), tail().head()) && tail().allEqual(eq);
}

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

/**
 * Returns an either projection of this list; the given argument in <code>Left</code> if empty, or
 * the first element in <code>Right</code>.
 *
 * @param x The value to return in left if this list is empty.
 * @return An either projection of this list.
 */
public final <X> Either<X, A> toEither(final F0<X> x) {
 return isEmpty() ? Either.left(x.f()) : Either.right(head());
}

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

/**
 * Returns a potential non-empty list from the given list. A non-value is returned if the given list is empty.
 *
 * @param as The list to construct a potential non-empty list with.
 * @return A potential non-empty list from the given list.
 */
public static <A> Option<NonEmptyList<A>> fromList(final List<A> as) {
 return as.isEmpty() ?
     Option.none() :
     some(nel(as.head(), as.tail()));
}

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

/**
 * Returns a stream projection of this list.
 *
 * @return A stream projection of this list.
 */
public final Stream<A> toStream() {
 return isEmpty() ? Stream.nil() : Stream.cons(head(), () -> tail().toStream());
}

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

protected AtomClassification(List<Function> atoms, DatalogTools datalogTools)
    throws DatalogProgram2QueryConverterImpl.InvalidDatalogProgramException {
  dataAndCompositeAtoms = datalogTools.filterDataAndCompositeAtoms(atoms);
  List<Function> otherAtoms = datalogTools.filterNonDataAndCompositeAtoms(atoms);
  booleanAtoms = datalogTools.filterBooleanAtoms(otherAtoms);
  if (dataAndCompositeAtoms.isEmpty())
    throw new DatalogProgram2QueryConverterImpl.InvalidDatalogProgramException("No data or composite atom in " + atoms);
  /*
   * May throw a NotSupportedConversionException
   */
  checkNonDataOrCompositeAtomSupport(otherAtoms, booleanAtoms);
}

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

/**
 * Returns the list of final segments of this list, longest first.
 *
 * @return The list of final segments of this list, longest first.
 */
public final List<List<A>> tails() {
 return isEmpty() ? single(List.nil()) : cons(this, tail().tails());
}

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

/**
 * Performs a right-fold reduction across this list in O(1) stack space.
 * @param f The function to apply on each element of the list.
 * @param b The beginning value to start the application from.
 * @return A Trampoline containing the final result after the right-fold reduction.
 */
public final <B> Trampoline<B> foldRightC(final F2<A, B, B> f, final B b) {
 return Trampoline.suspend(() -> isEmpty() ? Trampoline.pure(b) : tail().foldRightC(f, b).map(F2Functions.f(f, head())));
}

代码示例来源: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

/**
 * Removes the first element that equals the given object.
 * To remove all matches, use <code>removeAll(e.eq(a))</code>
 *
 * @param a The element to remove
 * @param e An <code>Equals</code> instance for the element's type.
 * @return A new list whose elements do not match the given predicate.
 */
public final List<A> delete(final A a, final Equal<A> e) {
 final P2<List<A>, List<A>> p = span(compose(not, e.eq(a)));
 return p._2().isEmpty() ? p._1() : p._1().append(p._2().tail());
}

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

public final <B, C, D, $E, $F> Validation<List<E>, $F> accumulate(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, Validation<E, $E> v5, F5<T, B, C, D, $E, $F> f) {
  List<E> list = fails(list(this, v2, v3, v4, v5));
  if (!list.isEmpty()) {
    return fail(list);
  } else {
    return success(f.f(success(), v2.success(), v3.success(), v4.success(), v5.success()));
  }
}

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

/**
 * Sequences through the right side of the either monad with a list of values.
 *
 * @param a The list of values to sequence with the either monad.
 * @return A sequenced value.
 */
public static <B, X> Either<X, List<B>> sequenceRight(final List<Either<X, B>> a) {
 return a.isEmpty() ?
     right(List.nil()) :
     a.head().right().bind(bb -> sequenceRight(a.tail()).right().map(cons_(bb)));
}

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

public final <B, C, D, $E, $F, G, H> Validation<List<E>, H> accumulate(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, Validation<E, $E> v5, Validation<E, $F> v6, Validation<E, G> v7, F7<T, B, C, D, $E, $F, G, H> f) {
  List<E> list = fails(list(this, v2, v3, v4, v5));
  if (!list.isEmpty()) {
    return fail(list);
  } else {
    return success(f.f(success(), v2.success(), v3.success(), v4.success(), v5.success(), v6.success(), v7.success()));
  }
}

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

public final <B, C, D, $E, $F, G, H, I> Validation<List<E>, I> accumulate(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, Validation<E, $E> v5, Validation<E, $F> v6, Validation<E, G> v7, Validation<E, H> v8, F8<T, B, C, D, $E, $F, G, H, I> f) {
  List<E> list = fails(list(this, v2, v3, v4, v5));
  if (!list.isEmpty()) {
    return fail(list);
  } else {
    return success(f.f(success(), v2.success(), v3.success(), v4.success(), v5.success(), v6.success(), v7.success(), v8.success()));
  }
}

相关文章