cyclops.reactive.ReactiveSeq.foldRight()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(87)

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

ReactiveSeq.foldRight介绍

[英]```
ReactiveSeq.of("a","b","c").foldRight(Reducers.toString(""));

[中]```
ReactiveSeq.of("a","b","c").foldRight(Reducers.toString(""));

代码示例

代码示例来源:origin: aol/cyclops

default  T foldRight(final ReactiveSeq<T> toFold){
  return toFold.foldRight(this);
}
default  T foldRight(final Iterable<T> toFold){

代码示例来源:origin: aol/cyclops

/**
 *
 * Immutable reduction from right to left
 *
 * @param identity  Identity value for the combiner function (leaves the input unchanged)
 * @param accumulator Combining function
 * @return Reduced value
 */
default <U> U foldRight(final U identity, final BiFunction<? super T, ? super U, ? extends U> accumulator) {
  return stream().foldRight(identity, accumulator);
}

代码示例来源:origin: aol/cyclops

default  T foldRight(final Iterable<T> toFold){
  return ReactiveSeq.fromIterable(toFold).foldRight(this);
}
default ReactiveSeq<T> foldRightAsync(final Publisher<T> toReduce) {

代码示例来源:origin: aol/cyclops

/**
 *
 * <pre>
  {@code
  Streamable.of("a","b","c").foldRight(Reducers.toString(""));
  // "cab"
  }
  </pre>
 * @param reducer Use supplied Monoid to reduce values starting via foldRight
 * @return Reduced result
 */
@Override
default T foldRight(final Monoid<T> reducer) {
  return this.stream().foldRight(reducer);
}

代码示例来源:origin: aol/cyclops

/**
 * Immutable reduction from right to left
 * <pre>
 * {@code
 *  assertTrue(Streamable.of("a","b","c").foldRight("", String::concat).equals("cba"));
 * }
 * </pre>
 *
 * @param identity
 * @param accumulator
 * @return
 */
@Override
default T foldRight(final T identity, final BinaryOperator<T> accumulator) {
  return this.stream().foldRight(identity, accumulator);
}

代码示例来源:origin: aol/cyclops

/**
 *
 * <pre>
 *         {@code
 *         ReactiveSeq.of("a","b","c").foldRight(Reducers.toString(""));
 *
 *         // "cab"
 *         }
 * </pre>
 *
 * @param reducer
 *            Use supplied Monoid to reduce values starting via foldRight
 * @return Reduced result
 */
default T foldRight(final Monoid<T> reducer) {
  return stream().foldRight(reducer);
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldRight(){
     Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().foldRight("", String::concat).contains("a"));
    assertTrue(s.get().foldRight("", String::concat).contains("b"));
    assertTrue(s.get().foldRight("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length())
              .foldRight(0, (t, u) -> u + t));
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldRight(){
     Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().foldRight("", String::concat).contains("a"));
    assertTrue(s.get().foldRight("", String::concat).contains("b"));
    assertTrue(s.get().foldRight("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length())
              .foldRight(0, (t, u) -> u + t));
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldRight(){
     Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().foldRight("", String::concat).contains("a"));
    assertTrue(s.get().foldRight("", String::concat).contains("b"));
    assertTrue(s.get().foldRight("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length())
              .foldRight(0, (t, u) -> u + t));
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldRight() {
  Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
  assertTrue(s.get().foldRight("", String::concat).equals("cba"));
  assertTrue(s.get().foldRight("", String::concat).contains("b"));
  assertTrue(s.get().foldRight("", String::concat).contains("c"));
  assertEquals(3, (int) s.get().map(str -> str.length()).foldRight(0, (t, u) -> u + t));
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldRight(){
     Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().foldRight("", String::concat).contains("a"));
    assertTrue(s.get().foldRight("", String::concat).contains("b"));
    assertTrue(s.get().foldRight("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length())
              .foldRight(0, (t, u) -> u + t));
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldRight(){
     Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().foldRight("", String::concat).contains("a"));
    assertTrue(s.get().foldRight("", String::concat).contains("b"));
    assertTrue(s.get().foldRight("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length())
              .foldRight(0, (t, u) -> u + t));
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldRight(){
     Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().foldRight("", String::concat).contains("a"));
    assertTrue(s.get().foldRight("", String::concat).contains("b"));
    assertTrue(s.get().foldRight("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length())
              .foldRight(0, (t, u) -> u + t));
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldLeft() {
  Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
  assertTrue(s.get().foldLeft("", String::concat).contains("a"));
  assertTrue(s.get().foldLeft("", String::concat).contains("b"));
  assertTrue(s.get().foldLeft("", String::concat).contains("c"));
  assertEquals(3, (int) s.get().map(str -> str.length()).foldLeft(0, (u, t) -> u + t));
  assertEquals(3, (int) s.get().map(str -> str.length()).foldRight(0, (t, u) -> u + t));
  assertEquals("-a-b-c", s.get().map(str -> new StringBuilder(str)).foldLeft(new StringBuilder(), (u, t) -> u.append("-").append(t)).toString());
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldLeft() {
  for(int i=0;i<100;i++){
    Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().reduce("", String::concat).contains("a"));
    assertTrue(s.get().reduce("", String::concat).contains("b"));
    assertTrue(s.get().reduce("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length()).foldLeft(0, (u, t) -> u + t));
    assertEquals(3, (int) s.get().map(str->str.length()).foldRight(0, (t, u) -> u + t));
  }
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldLeft() {
  for(int i=0;i<100;i++){
    Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().reduce("", String::concat).contains("a"));
    assertTrue(s.get().reduce("", String::concat).contains("b"));
    assertTrue(s.get().reduce("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length()).foldLeft(0, (u, t) -> u + t));
    assertEquals(3, (int) s.get().map(str->str.length()).foldRight(0, (t, u) -> u + t));
  }
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldLeft() {
  for(int i=0;i<100;i++){
    Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().reduce("", String::concat).contains("a"));
    assertTrue(s.get().reduce("", String::concat).contains("b"));
    assertTrue(s.get().reduce("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length()).foldLeft(0, (u, t) -> u + t));
    assertEquals(3, (int) s.get().map(str->str.length()).foldRight(0, (t, u) -> u + t));
  }
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldLeft() {
  for(int i=0;i<100;i++){
    Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().reduce("", String::concat).contains("a"));
    assertTrue(s.get().reduce("", String::concat).contains("b"));
    assertTrue(s.get().reduce("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length()).foldLeft(0, (u, t) -> u + t));
    assertEquals(3, (int) s.get().map(str->str.length()).foldRight(0, (t, u) -> u + t));
  }
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldLeft() {
  for(int i=0;i<100;i++){
    Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().reduce("", String::concat).contains("a"));
    assertTrue(s.get().reduce("", String::concat).contains("b"));
    assertTrue(s.get().reduce("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length()).foldLeft(0, (u, t) -> u + t));
    assertEquals(3, (int) s.get().map(str->str.length()).foldRight(0, (t, u) -> u + t));
  }
}

代码示例来源:origin: aol/cyclops

@Test
public void testFoldLeft() {
  for(int i=0;i<100;i++){
    Supplier<ReactiveSeq<String>> s = () -> of("a", "b", "c");
    assertTrue(s.get().reduce("", String::concat).contains("a"));
    assertTrue(s.get().reduce("", String::concat).contains("b"));
    assertTrue(s.get().reduce("", String::concat).contains("c"));
    assertEquals(3, (int) s.get().map(str->str.length()).foldLeft(0, (u, t) -> u + t));
    assertEquals(3, (int) s.get().map(str->str.length()).foldRight(0, (t, u) -> u + t));
  }
}

相关文章

微信公众号

最新文章

更多

ReactiveSeq类方法