com.jnape.palatable.lambda.functions.builtin.fn2.Zip类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(152)

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

Zip介绍

[英]Zip together two Iterables into a single Iterable of Tuple2<A, B>. If the input Iterables differ in size, the resulting Iterable contains only as many pairs as the smallest input Iterable's elements.
[中]将两个Iterable压缩成一个IterableTuple2<A, B>。如果输入Iterable的大小不同,则生成的Iterable只包含与最小输入Iterable元素相同的对。

代码示例

代码示例来源:origin: palatable/lambda

public static <A, B> Iterable<Tuple2<A, B>> zip(Iterable<A> as, Iterable<B> bs) {
    return Zip.<A, B>zip(as).apply(bs);
  }
}

代码示例来源:origin: palatable/lambda

public static <A, B> Fn1<Iterable<B>, Iterable<Tuple2<A, B>>> zip(Iterable<A> as) {
  return Zip.<A, B>zip().apply(as);
}

代码示例来源:origin: palatable/lambda

@TestTraits({Laziness.class, FiniteIteration.class, ImmutableIteration.class})
public Fn1<Iterable<Object>, Iterable<Tuple2<Object, Object>>> createTestSubject() {
  return zip(Arrays.asList(1, 2, 3));
}

代码示例来源:origin: com.jnape.palatable/lambda

public static <A, B> Fn1<Iterable<B>, Iterable<Tuple2<A, B>>> zip(Iterable<A> as) {
  return Zip.<A, B>zip().apply(as);
}

代码示例来源:origin: palatable/lambda

@Override
protected boolean matchesSafely(Iterable<A> xs) {
  xs.forEach(__ -> clock.saveLastInstant());
  Boolean enoughDelay = all(d -> d.toNanos() > delay.toNanos(), map(boundaries -> {
    Iterator<Instant> it = boundaries.iterator();
    Instant first = it.next();
    Instant second = it.next();
    return between(first, second);
  }, slide(2, map(instants -> instants.iterator().next(), inGroupsOf(limit.intValue(), clock.instants())))));
  Boolean sameElements = all(Eq.<A>eq().uncurry(), zip(elements, xs));
  return enoughDelay && sameElements;
}

代码示例来源:origin: palatable/lambda

@Test
  @SuppressWarnings("unchecked")
  public void zipsAsymmetricallySizedIterables() {
    Iterable<String> men = asList("Jack", "Sonny");
    Iterable<String> women = asList("Jill", "Cher", "Madonna");

    Iterable<Tuple2<String, String>> couples = zip(men, women);
    assertThat(couples, iterates(tuple("Jack", "Jill"), tuple("Sonny", "Cher")));
  }
}

代码示例来源:origin: palatable/lambda

@Test
  @SuppressWarnings("unchecked")
  public void zipsTwoIterablesTogether() {
    Iterable<Integer> odds = asList(1, 3, 5);
    Iterable<Integer> evens = asList(2, 4, 6);

    Iterable<Tuple2<Integer, Integer>> numbers = zip(odds, evens);
    assertThat(numbers, iterates(tuple(1, 2), tuple(3, 4), tuple(5, 6)));
  }
}

代码示例来源:origin: com.jnape.palatable/lambda

public static <A, B> Iterable<Tuple2<A, B>> zip(Iterable<A> as, Iterable<B> bs) {
    return Zip.<A, B>zip(as).apply(bs);
  }
}

相关文章

Zip类方法