ResultSetEnumerator( ResultSet resultSet, Function1<ResultSet, Function0<T>> rowBuilderFactory) { this.resultSet = resultSet; this.rowBuilder = rowBuilderFactory.apply(resultSet); }
public void run() { for (int i = 0; i < repeat; i++) { function.apply(statistician); } statistician.printDurations(); }
public void run() { for (int i = 0; i < repeat; i++) { function.apply(statistician); } statistician.printDurations(); }
ResultSetEnumerator( ResultSet resultSet, Function1<ResultSet, Function0<T>> rowBuilderFactory) { this.resultSet = resultSet; this.rowBuilder = rowBuilderFactory.apply(resultSet); }
/** * Creates child visitor. It is used to traverse nested class declarations. * * @return new {@code Visitor} that is used to optimize class declarations */ protected ClassDeclarationFinder goDeeper() { return childFactory.apply(this); } }
protected E transform(F from) { return func.apply(from); } };
public E get(int index) { return fn.apply(index); } }
public Object[] execute() { return compiledFunction.apply(dataContext); }
public Object[] execute() { return compiledFunction.apply(dataContext); }
public R get(int index) { return f.apply(ts[index]); }
public R get(int index) { return f.apply(list.get(index)); }
public int hashCode(T t) { return t == null ? 0x789d : selector.apply(t).hashCode(); } }
/** * Creates a copy of a list, applying a function to each element. */ public static <T1, R> List<R> apply(final List<T1> list, final Function1<T1, R> f) { final List<R> list2 = new ArrayList<>(list.size()); for (T1 t : list) { list2.add(f.apply(t)); } return list2; }
/** * Creates a {@code Map<TKey, TValue>} from an * {@code Enumerable<TSource>} according to specified key selector and element * selector functions. */ public static <TSource, TKey, TElement> Map<TKey, TElement> toMap( Enumerable<TSource> source, Function1<TSource, TKey> keySelector, Function1<TSource, TElement> elementSelector) { // Use LinkedHashMap because groupJoin requires order of keys to be // preserved. final Map<TKey, TElement> map = new LinkedHashMap<>(); try (Enumerator<TSource> os = source.enumerator()) { while (os.moveNext()) { TSource o = os.current(); map.put(keySelector.apply(o), elementSelector.apply(o)); } } return map; }
static <TSource, TKey, TElement> LookupImpl<TKey, TElement> toLookup_( Map<TKey, List<TElement>> map, Enumerable<TSource> source, Function1<TSource, TKey> keySelector, Function1<TSource, TElement> elementSelector) { try (Enumerator<TSource> os = source.enumerator()) { while (os.moveNext()) { TSource o = os.current(); final TKey key = keySelector.apply(o); List<TElement> list = map.get(key); if (list == null) { // for first entry, use a singleton list to save space list = Collections.singletonList(elementSelector.apply(o)); } else { if (list.size() == 1) { // when we go from 1 to 2 elements, switch to array list TElement element = list.get(0); list = new ArrayList<>(); list.add(element); } list.add(elementSelector.apply(o)); } map.put(key, list); } } return new LookupImpl<>(map); }