本文整理了Java中com.jnape.palatable.lambda.functions.builtin.fn2.Zip
类的一些代码示例,展示了Zip
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Zip
类的具体详情如下:
包路径:com.jnape.palatable.lambda.functions.builtin.fn2.Zip
类名称:Zip
[英]Zip together two Iterable
s into a single Iterable
of Tuple2<A, B>
. If the input Iterable
s differ in size, the resulting Iterable
contains only as many pairs as the smallest input Iterable
's elements.
[中]将两个Iterable
压缩成一个Iterable
的Tuple2<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);
}
}
内容来源于网络,如有侵权,请联系作者删除!