public Grouping<K, V> current() { final Entry<K, List<V>> keyAndList = enumerator.current(); return new GroupingImpl<>(keyAndList.getKey(), keyAndList.getValue()); }
public T next() { T t = enumerator.current(); hasNext = enumerator.moveNext(); return t; }
public TResult current() { final List<Object> list = cartesians.current(); @SuppressWarnings("unchecked") final TSource left = (TSource) list.get(0); @SuppressWarnings("unchecked") final TInner right = (TInner) list.get(1); return resultSelector.apply(left, right); }
private void fetchNext() { if (wrapped.moveNext()) { next = wrapped.current(); } else { next = null; } }
/** * Returns the first element of a sequence. (Defined * by Enumerable.) */ public static <TSource> TSource first(Enumerable<TSource> enumerable) { try (Enumerator<TSource> os = enumerable.enumerator()) { if (os.moveNext()) { return os.current(); } throw new NoSuchElementException(); } }
/** Default implementation of {@link ExtendedEnumerable#into(Collection)}. */ public static <T, C extends Collection<? super T>> C into( Enumerable<T> source, C sink) { try (Enumerator<T> enumerator = source.enumerator()) { while (enumerator.moveNext()) { T t = enumerator.current(); sink.add(t); } } return sink; }
public boolean moveNext() { if (!done) { if (enumerator.moveNext() && predicate.apply(enumerator.current(), ++n)) { return true; } else { done = true; } } return false; }
@Override public Row receive() { if (enumerator.moveNext()) { return enumerator.current(); } // close the enumerator once we have gone through everything enumerator.close(); return null; }
@Override public Row receive() { if (enumerator.moveNext()) { return enumerator.current(); } // close the enumerator once we have gone through everything enumerator.close(); return null; }
public boolean moveNext() { if (!done) { if (enumerator.moveNext() && predicate.apply(enumerator.current(), ++n)) { return true; } else { done = true; } } return false; }
public Node implement(final InterpreterImplementor implementor) { return () -> { final Sink sink = implementor.relSinks.get(EnumerableBindable.this).get(0); final Enumerable<Object[]> enumerable = bind(implementor.dataContext); final Enumerator<Object[]> enumerator = enumerable.enumerator(); while (enumerator.moveNext()) { sink.send(Row.asCopy(enumerator.current())); } }; }
public <R> R foreach(Function1<T, R> func) { R result = null; try (Enumerator<T> enumerator = enumerator()) { while (enumerator.moveNext()) { T t = enumerator.current(); result = func.apply(t); } return result; } }
public Node implement(final InterpreterImplementor implementor) { return () -> { final Sink sink = implementor.relSinks.get(EnumerableBindable.this).get(0); final Enumerable<Object[]> enumerable = bind(implementor.dataContext); final Enumerator<Object[]> enumerator = enumerable.enumerator(); while (enumerator.moveNext()) { sink.send(Row.asCopy(enumerator.current())); } }; }
private static <TSource, TKey, TResult> Enumerable<TResult> groupBy_( final Set<TKey> map, Enumerable<TSource> enumerable, Function1<TSource, TKey> keySelector, final Function1<TKey, TResult> resultSelector) { try (Enumerator<TSource> os = enumerable.enumerator()) { while (os.moveNext()) { TSource o = os.current(); TKey key = keySelector.apply(o); map.add(key); } } return Linq4j.asEnumerable(map).select(resultSelector); }
public void run() throws InterruptedException { final Enumerator<Object[]> enumerator = enumerable.enumerator(); while (enumerator.moveNext()) { Object[] values = enumerator.current(); sink.send(Row.of(values)); } } }
@SuppressWarnings("deprecation") @Override public void setSourceEnumerable(Enumerable<Row> enumerable) throws InterruptedException { // just copy over the source into the local list final Enumerator<Row> enumerator = enumerable.enumerator(); while (enumerator.moveNext()) { this.send(enumerator.current()); } enumerator.close(); } }
public void run() throws InterruptedException { final Enumerator<Object[]> enumerator = enumerable.enumerator(); while (enumerator.moveNext()) { Object[] values = enumerator.current(); sink.send(Row.of(values)); } } }
@SuppressWarnings("deprecation") @Override public void setSourceEnumerable(Enumerable<Row> enumerable) throws InterruptedException { // just copy over the source into the local list final Enumerator<Row> enumerator = enumerable.enumerator(); while (enumerator.moveNext()) { this.send(enumerator.current()); } enumerator.close(); } }
@SuppressWarnings("deprecation") @Override public void setSourceEnumerable(Enumerable<Row> enumerable) throws InterruptedException { // just copy over the source into the local list final Enumerator<Row> enumerator = enumerable.enumerator(); while (enumerator.moveNext()) { this.send(enumerator.current()); } enumerator.close(); } }
@SuppressWarnings("deprecation") @Override public void setSourceEnumerable(Enumerable<Row> enumerable) throws InterruptedException { // just copy over the source into the local list final Enumerator<Row> enumerator = enumerable.enumerator(); while (enumerator.moveNext()) { this.send(enumerator.current()); } enumerator.close(); } }