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

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

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

List.reverse介绍

[英]Reverse this list in constant stack space.
[中]在常量堆栈空间中反转此列表。

代码示例

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

public List<FileInfo> getList()
  {
    return list.reverse();
  }
}

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

public List<FileInfo> getList()
  {
    return list.reverse();
  }
}

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

public List<FileInfo> getList()
  {
    return list.reverse();
  }
}

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

/**
 * Performs a right-fold reduction across this list. This function uses O(length) 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 The final result after the right-fold reduction.
 */
public final <B> B foldRight(final F2<A, B, B> f, final B b) {
 return reverse().foldLeft(flip(f), b);
}

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

/**
 * Reverse this non empty list in constant stack space.
 *
 * @return A new non empty list with the elements in reverse order.
 */
public NonEmptyList<A> reverse() {
 final List<A> list = toList().reverse();
 return nel(list.head(), list.tail());
}

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

/**
 * Splits this list into two lists at the given index. If the index goes out of bounds, then it is
 * normalised so that this function never fails.
 *
 * @param i The index at which to split this list in two parts.
 * @return A pair of lists split at the given index of this list.
 */
public final P2<List<A>, List<A>> splitAt(final int i) {
 int c = 0;
 List<A> first = List.nil();
 List<A> second = nil();
 for (List<A> xs = this; xs.isNotEmpty(); xs = xs.tail()) {
  final A h = xs.head();
  if (c < i) {
    first = first.cons(h);
  } else {
    second = second.cons(h);
  }
  c++;
 }
 return p(first.reverse(), second.reverse());
}

代码示例来源: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: no.arktekk.unix/unix-sysv-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: com.stratio.mojo.unix/unix-sysv-pkg

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

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

/**
 * Evaluate each action in the sequence from left to right, and collect the results.
 */
public static <S, A> State<S, List<A>> sequence(List<State<S, A>> list) {
 return list
   .foldLeft(
     (acc, ts) -> acc.flatMap(as -> ts.map(a -> cons(a, as))),
     State.<S, List<A>>constant(List.nil()))
   .map(as -> as.reverse());
}

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

/**
 * Map each element of a structure to an action, evaluate these actions from left to right
 * and collect the results.
 */
public static <S, A, B> State<S, List<B>> traverse(List<A> list, F<A, State<S, B>> f) {
 return list
   .foldLeft(
     (acc, a) -> acc.flatMap(bs -> f.f(a).map(b -> cons(b, bs))),
     State.<S, List<B>>constant(List.nil()))
   .map(bs -> bs.reverse());
}

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

/**
 * Partitions the list into a tuple where the first element contains the
 * items that satisfy the the predicate f and the second element contains the
 * items that does not.  The relative order of the elements in the returned tuple
 * is the same as the original list.
 *
 * @param f Predicate function.
 */
public final P2<List<A>, List<A>> partition(F<A, Boolean> f) {
 P2<List<A>, List<A>> p2 = foldLeft((acc, a) ->
  f.f(a) ? p(acc._1().cons(a), acc._2()) : p(acc._1(), acc._2().cons(a)),
  p(nil(), nil())
 );
 return p(p2._1().reverse(), p2._2().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-sysv-pkg

public List<String> toList()
{
  F<List<String>, String> folder = List.<String, String>foldLeft().f( joiner.f( " " ) ).f( "" );
  F<List<String>, String> stringF = FunctionF.compose( curry( concat, "CLASSES=" ), trim, folder );
  List<Option<String>> list = List.<Option<String>>single( some( "ARCH=" + arch ) ).
    cons( some( "CATEGORY=" + category ) ).
    cons( some( "NAME=" + name ) ).
    cons( some( "PKG=" + pkg ) ).
    cons( some( "VERSION=" + version ) ).
    cons( pstamp.map( curry( concat, "PSTAMP=" ) ) ).
    cons( desc.map( curry( concat, "DESC=" ) ) ).
    cons( email.map( curry( concat, "EMAIL=" ) ) ).
    cons( iif( List.<String>isNotEmpty_(), classes ).map( stringF ) );
  return Option.somes( list ).reverse();
}

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

public List<String> toList()
{
  F<List<String>, String> folder = List.<String, String>foldLeft().f( joiner.f( " " ) ).f( "" );
  F<List<String>, String> stringF = FunctionF.compose( curry( concat, "CLASSES=" ), trim, folder );
  List<Option<String>> list = List.<Option<String>>single( some( "ARCH=" + arch ) ).
    cons( some( "CATEGORY=" + category ) ).
    cons( some( "NAME=" + name ) ).
    cons( some( "PKG=" + pkg ) ).
    cons( some( "VERSION=" + version ) ).
    cons( pstamp.map( curry( concat, "PSTAMP=" ) ) ).
    cons( desc.map( curry( concat, "DESC=" ) ) ).
    cons( email.map( curry( concat, "EMAIL=" ) ) ).
    cons( size.map( curry( concat, "SIZE=" ) ) ).
    cons( iif( List.<String>isNotEmpty_(), classes ).map( stringF ) );
  return Option.somes( list ).reverse();
}

相关文章