@Override public ZippedFlow<A, B> take(int length) { return create(tupleFlow.take(length)); }
@Override public ZippedFlow<A, B> take(int length) { return create(tupleFlow.take(length)); }
@Test public void take_from_empty_list() { assertSame(F.flow().take(34), F.EMPTY_FLOW); }
@Test public void series() { Flow<Integer> series = F.series(3, 5); assertFlowValues(series.take(5), 3, 8, 13, 18, 23); }
@Test public void iterate() { Mapper<Integer, Integer> times2 = new Mapper<Integer, Integer>() { @Override public Integer map(Integer value) { return 2 * value; } }; assertFlowValues(F.iterate(1, times2).take(5), 1, 2, 4, 8, 16); } }
@Test public void to_array() { Flow<Integer> flow = F.range(1, 10).drop(2).take(3); assertTrue(Arrays.equals(flow.toArray(Integer.class), new Integer[] { 3, 4, 5 })); }
@Test public void filtered_series() { Flow<Integer> series = F.series(1, 1); assertFlowValues(series.filter(evenp).take(4), 2, 4, 6, 8); }
@Test public void take_from_flow() { assertFlowValues(F.series(1, 1).remove(evenp).take(2), 1, 3); }
@Test public void count_of_a_large_flow() { Flow<Integer> flow = F.series(1, 1).take(50000); assertEquals(flow.count(), 50000); }
@Test public void take_and_drop() { // This can go much, much larger but starts taking a while. Don't hold a reference to the // start // of the series or it can run out of memory. int length = 100000; assertFlowValues(F.series(1, 1).filter(evenp).drop(length).take(3), 2 * length + 2, 2 * length + 4, 2 * length + 6); }