Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.landawn.abacus.util.stream.AbstractStream Maven / Gradle / Ivy
/*
* Copyright (C) 2016 HaiYang Li
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.landawn.abacus.util.stream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import com.landawn.abacus.DataSet;
import com.landawn.abacus.exception.UncheckedIOException;
import com.landawn.abacus.exception.UncheckedSQLException;
import com.landawn.abacus.util.Array;
import com.landawn.abacus.util.BufferedWriter;
import com.landawn.abacus.util.ByteIterator;
import com.landawn.abacus.util.ByteSummaryStatistics;
import com.landawn.abacus.util.CharIterator;
import com.landawn.abacus.util.CharSummaryStatistics;
import com.landawn.abacus.util.DoubleIterator;
import com.landawn.abacus.util.DoubleSummaryStatistics;
import com.landawn.abacus.util.FloatIterator;
import com.landawn.abacus.util.FloatSummaryStatistics;
import com.landawn.abacus.util.Fn;
import com.landawn.abacus.util.IOUtil;
import com.landawn.abacus.util.Indexed;
import com.landawn.abacus.util.IntIterator;
import com.landawn.abacus.util.IntSummaryStatistics;
import com.landawn.abacus.util.ListMultimap;
import com.landawn.abacus.util.LongIterator;
import com.landawn.abacus.util.LongSummaryStatistics;
import com.landawn.abacus.util.Matrix;
import com.landawn.abacus.util.Multimap;
import com.landawn.abacus.util.Multiset;
import com.landawn.abacus.util.MutableBoolean;
import com.landawn.abacus.util.MutableLong;
import com.landawn.abacus.util.N;
import com.landawn.abacus.util.Nth;
import com.landawn.abacus.util.NullabLe;
import com.landawn.abacus.util.ObjectFactory;
import com.landawn.abacus.util.Optional;
import com.landawn.abacus.util.OptionalDouble;
import com.landawn.abacus.util.Pair;
import com.landawn.abacus.util.Percentage;
import com.landawn.abacus.util.PermutationIterator;
import com.landawn.abacus.util.Seq;
import com.landawn.abacus.util.ShortIterator;
import com.landawn.abacus.util.ShortSummaryStatistics;
import com.landawn.abacus.util.Try;
import com.landawn.abacus.util.function.BiConsumer;
import com.landawn.abacus.util.function.BiFunction;
import com.landawn.abacus.util.function.BiPredicate;
import com.landawn.abacus.util.function.BinaryOperator;
import com.landawn.abacus.util.function.Consumer;
import com.landawn.abacus.util.function.Function;
import com.landawn.abacus.util.function.IntFunction;
import com.landawn.abacus.util.function.Predicate;
import com.landawn.abacus.util.function.Supplier;
import com.landawn.abacus.util.function.ToByteFunction;
import com.landawn.abacus.util.function.ToCharFunction;
import com.landawn.abacus.util.function.ToDoubleFunction;
import com.landawn.abacus.util.function.ToFloatFunction;
import com.landawn.abacus.util.function.ToIntFunction;
import com.landawn.abacus.util.function.ToLongFunction;
import com.landawn.abacus.util.function.ToShortFunction;
import com.landawn.abacus.util.function.TriConsumer;
import com.landawn.abacus.util.function.TriFunction;
/**
* This class is a sequential, stateful and immutable stream implementation.
*
* @param
* @since 0.8
*
* @author Haiyang Li
*/
abstract class AbstractStream extends Stream {
AbstractStream(final Collection closeHandlers, final boolean sorted, final Comparator super T> cmp) {
super(closeHandlers, sorted, cmp);
}
@Override
public Stream filter(final U seed, final BiPredicate super T, ? super U> predicate) {
return filter(new Predicate() {
@Override
public boolean test(T value) {
return predicate.test(value, seed);
}
});
}
@Override
public Stream takeWhile(final U seed, final BiPredicate super T, ? super U> predicate) {
return takeWhile(new Predicate() {
@Override
public boolean test(T value) {
return predicate.test(value, seed);
}
});
}
@Override
public Stream dropWhile(final U seed, final BiPredicate super T, ? super U> predicate) {
return dropWhile(new Predicate() {
@Override
public boolean test(T value) {
return predicate.test(value, seed);
}
});
}
@Override
public Stream remove(final long n, final Consumer super T> action) {
if (n < 0) {
throw new IllegalArgumentException("'n' can't be less than 0");
} else if (n == 0) {
return this;
}
if (this.isParallel()) {
final AtomicLong cnt = new AtomicLong(n);
return removeWhile(new Predicate() {
@Override
public boolean test(T value) {
return cnt.getAndDecrement() > 0;
}
}, action);
} else {
final MutableLong cnt = MutableLong.of(n);
return removeWhile(new Predicate() {
@Override
public boolean test(T value) {
return cnt.getAndDecrement() > 0;
}
}, action);
}
}
@Override
public Stream removeIf(final Predicate super T> predicate) {
N.requireNonNull(predicate);
return filter(new Predicate() {
@Override
public boolean test(T value) {
return predicate.test(value) == false;
}
});
}
@Override
public Stream removeIf(final U seed, final BiPredicate super T, ? super U> predicate) {
N.requireNonNull(predicate);
return filter(new Predicate() {
@Override
public boolean test(T value) {
return predicate.test(value, seed) == false;
}
});
}
@Override
public Stream removeIf(final Predicate super T> predicate, final Consumer super T> action) {
N.requireNonNull(predicate);
N.requireNonNull(action);
return filter(new Predicate() {
@Override
public boolean test(T value) {
if (predicate.test(value)) {
action.accept(value);
return false;
}
return true;
}
});
}
@Override
public Stream removeIf(final U seed, final BiPredicate super T, ? super U> predicate, final Consumer super T> action) {
N.requireNonNull(predicate);
N.requireNonNull(action);
return filter(new Predicate() {
@Override
public boolean test(T value) {
if (predicate.test(value, seed)) {
action.accept(value);
return false;
}
return true;
}
});
}
@Override
public Stream removeWhile(final Predicate super T> predicate, final Consumer super T> action) {
N.requireNonNull(predicate);
N.requireNonNull(action);
return dropWhile(new Predicate() {
@Override
public boolean test(T value) {
if (predicate.test(value)) {
action.accept(value);
return true;
}
return false;
}
});
}
@Override
public Stream removeWhile(final U seed, final BiPredicate super T, ? super U> predicate, final Consumer super T> action) {
N.requireNonNull(predicate);
N.requireNonNull(action);
return dropWhile(new Predicate() {
@Override
public boolean test(T value) {
if (predicate.test(value, seed)) {
action.accept(value);
return true;
}
return false;
}
});
}
@Override
public Stream step(final long step) {
N.checkArgument(step > 0, "'step' can't be 0 or negative: %s", step);
if (step == 1) {
return this;
}
final long skip = step - 1;
final ExIterator iter = exIterator();
final Iterator iterator = new ExIterator() {
@Override
public boolean hasNext() {
return iter.hasNext();
}
@Override
public T next() {
final T next = iter.next();
iter.skip(skip);
return next;
}
};
return newStream(iterator, sorted, cmp);
}
@Override
public Stream map(final U seed, final BiFunction super T, ? super U, ? extends R> mapper) {
return map(new Function() {
@Override
public R apply(T t) {
return mapper.apply(t, seed);
}
});
}
@Override
public Stream biMap(BiFunction super T, ? super T, ? extends R> mapper) {
return biMap(mapper, false);
}
@Override
public Stream triMap(TriFunction super T, ? super T, ? super T, ? extends R> mapper) {
return triMap(mapper, false);
}
@Override
public Stream slidingMap(BiFunction super T, ? super T, R> mapper) {
return slidingMap(mapper, 1);
}
@Override
public Stream slidingMap(TriFunction super T, ? super T, ? super T, R> mapper) {
return slidingMap(mapper, 1);
}
@Override
public Stream rangeMap(final BiPredicate super T, ? super T> sameRange, final BiFunction super T, ? super T, ? extends U> mapper) {
final Iterator iter = iterator();
return newStream(new ExIterator() {
private final T NULL = (T) Stream.NONE;
private T next = NULL;
@Override
public boolean hasNext() {
return next != NULL || iter.hasNext();
}
@Override
public U next() {
final T left = next == NULL ? iter.next() : next;
T right = left;
while (iter.hasNext() && sameRange.test(right, (next = iter.next()))) {
right = next;
}
if (right == next) {
next = NULL;
}
return mapper.apply(left, right);
}
}, false, null);
}
abstract Stream flatMap0(final Function super T, ? extends Iterator extends R>> mapper);
// @Override
// public EntryStream mapToEntry() {
// return null;
// }
@Override
public EntryStream mapToEntry(final Function super T, ? extends Map.Entry> mapper) {
final Function mapper2 = Fn.identity();
if (mapper == mapper2) {
return EntryStream.of((Stream>) this);
}
return EntryStream.of(map(mapper));
}
@Override
public EntryStream mapToEntry(final Function super T, K> keyMapper, final Function super T, V> valueMapper) {
final Function> mapper = new Function>() {
@Override
public Entry apply(T t) {
return new AbstractMap.SimpleImmutableEntry<>(keyMapper.apply(t), valueMapper.apply(t));
}
};
return mapToEntry(mapper);
}
@Override
public Stream flatMap(final Function super T, ? extends Stream extends R>> mapper) {
return flatMap0(new Function>() {
@Override
public Iterator extends R> apply(T t) {
return mapper.apply(t).iterator();
}
});
}
@Override
public Stream flatMap(final U seed, final BiFunction super T, ? super U, ? extends Stream extends R>> mapper) {
return flatMap(new Function>() {
@Override
public Stream extends R> apply(T t) {
return mapper.apply(t, seed);
}
});
}
@Override
public Stream flatCollection(final Function super T, ? extends Collection extends R>> mapper) {
return flatMap0(new Function>() {
@Override
public Iterator extends R> apply(T t) {
return mapper.apply(t).iterator();
}
});
}
@Override
public Stream flatCollection(final U seed, final BiFunction super T, ? super U, ? extends Collection extends R>> mapper) {
return flatCollection(new Function>() {
@Override
public Collection extends R> apply(T t) {
return mapper.apply(t, seed);
}
});
}
@Override
public Stream flatArray(final Function super T, ? extends R[]> mapper) {
return flatMap0(new Function>() {
@Override
public Iterator extends R> apply(T t) {
return ExIterator.of(mapper.apply(t));
}
});
}
@Override
public Stream flatArray(final U seed, final BiFunction super T, ? super U, ? extends R[]> mapper) {
return flatArray(new Function() {
@Override
public R[] apply(T t) {
return mapper.apply(t, seed);
}
});
}
@Override
public CharStream flatMapToChar(final Function super T, ? extends CharStream> mapper) {
return flatMapToChar0(new Function() {
@Override
public CharIterator apply(T t) {
return mapper.apply(t).exIterator();
}
});
}
abstract CharStream flatMapToChar0(Function super T, CharIterator> function);
@Override
public ByteStream flatMapToByte(final Function super T, ? extends ByteStream> mapper) {
return flatMapToByte0(new Function() {
@Override
public ByteIterator apply(T t) {
return mapper.apply(t).exIterator();
}
});
}
abstract ByteStream flatMapToByte0(Function super T, ByteIterator> function);
@Override
public ShortStream flatMapToShort(final Function super T, ? extends ShortStream> mapper) {
return flatMapToShort0(new Function() {
@Override
public ShortIterator apply(T t) {
return mapper.apply(t).exIterator();
}
});
}
abstract ShortStream flatMapToShort0(Function super T, ShortIterator> function);
@Override
public IntStream flatMapToInt(final Function super T, ? extends IntStream> mapper) {
return flatMapToInt0(new Function() {
@Override
public IntIterator apply(T t) {
return mapper.apply(t).exIterator();
}
});
}
abstract IntStream flatMapToInt0(Function super T, IntIterator> function);
@Override
public LongStream flatMapToLong(final Function super T, ? extends LongStream> mapper) {
return flatMapToLong0(new Function() {
@Override
public LongIterator apply(T t) {
return mapper.apply(t).exIterator();
}
});
}
abstract LongStream flatMapToLong0(Function super T, LongIterator> function);
@Override
public FloatStream flatMapToFloat(final Function super T, ? extends FloatStream> mapper) {
return flatMapToFloat0(new Function() {
@Override
public FloatIterator apply(T t) {
return mapper.apply(t).exIterator();
}
});
}
abstract FloatStream flatMapToFloat0(Function super T, FloatIterator> function);
@Override
public DoubleStream flatMapToDouble(final Function super T, ? extends DoubleStream> mapper) {
return flatMapToDouble0(new Function() {
@Override
public DoubleIterator apply(T t) {
return mapper.apply(t).exIterator();
}
});
}
abstract DoubleStream flatMapToDouble0(Function super T, DoubleIterator> function);
@Override
public EntryStream flatMapToEntry(final Function super T, ? extends Stream extends Map.Entry>> mapper) {
return EntryStream.of(flatMap(mapper));
}
@Override
@SuppressWarnings("rawtypes")
public Stream sortedBy(final Function super T, ? extends Comparable> keyExtractor) {
final Comparator super T> comparator = new Comparator() {
@Override
public int compare(T o1, T o2) {
return N.compare(keyExtractor.apply(o1), keyExtractor.apply(o2));
}
};
return sorted(comparator);
}
@Override
public Stream> split(final int size) {
return splitToList(size).map(new Function, Stream>() {
@Override
public Stream apply(List t) {
return new ArrayStream<>(toArray(t), 0, t.size(), null, sorted, cmp);
}
});
}
@Override
public Stream> split(final Predicate super T> predicate) {
return splitToList(predicate).map(new Function, Stream>() {
@Override
public Stream apply(List t) {
return new ArrayStream<>(toArray(t), 0, t.size(), null, sorted, cmp);
}
});
}
@Override
public Stream> splitToList(final Predicate super T> predicate) {
final BiFunction predicate2 = new BiFunction() {
@Override
public Boolean apply(T t, Object u) {
return predicate.test(t);
}
};
return splitToList(null, predicate2, null);
}
@Override
public Stream> split(final U identity, final BiFunction super T, ? super U, Boolean> predicate, final Consumer super U> identityUpdate) {
return splitToList(identity, predicate, identityUpdate).map(new Function, Stream>() {
@Override
public Stream apply(List t) {
return new ArrayStream<>(toArray(t), 0, t.size(), null, sorted, cmp);
}
});
}
@Override
public Stream> sliding(final int windowSize, final int increment) {
return slidingToList(windowSize, increment).map(new Function, Stream>() {
@Override
public Stream apply(List t) {
return new ArrayStream<>(toArray(t), 0, t.size(), null, sorted, cmp);
}
});
}
@Override
public Stream collapse(final BiPredicate super T, ? super T> collapsible, final BiFunction super T, ? super T, T> mergeFunction) {
final ExIterator iter = exIterator();
return this.newStream(new ExIterator() {
private boolean hasNext = false;
private T next = null;
@Override
public boolean hasNext() {
return hasNext || iter.hasNext();
}
@Override
public T next() {
T res = hasNext ? next : (next = iter.next());
while ((hasNext = iter.hasNext())) {
if (collapsible.test(next, (next = iter.next()))) {
res = mergeFunction.apply(res, next);
} else {
break;
}
}
return res;
}
}, false, null);
}
@Override
public Stream collapse(final BiPredicate super T, ? super T> collapsible, final Collector super T, A, R> collector) {
final Supplier supplier = collector.supplier();
final BiConsumer accumulator = collector.accumulator();
final Function finisher = collector.finisher();
final ExIterator iter = exIterator();
return this.newStream(new ExIterator() {
private boolean hasNext = false;
private T next = null;
@Override
public boolean hasNext() {
return hasNext || iter.hasNext();
}
@Override
public R next() {
final A c = supplier.get();
accumulator.accept(c, hasNext ? next : (next = iter.next()));
while ((hasNext = iter.hasNext())) {
if (collapsible.test(next, (next = iter.next()))) {
accumulator.accept(c, next);
} else {
break;
}
}
return finisher.apply(c);
}
}, false, null);
}
@Override
public Stream scan(final BiFunction super T, ? super T, T> accumulator) {
final ExIterator iter = exIterator();
return this.newStream(new ExIterator() {
private T res = null;
private boolean isFirst = true;
@Override
public boolean hasNext() {
return iter.hasNext();
}
@Override
public T next() {
if (isFirst) {
isFirst = false;
return (res = iter.next());
} else {
return (res = accumulator.apply(res, iter.next()));
}
}
}, false, null);
}
@Override
public Stream scan(final R seed, final BiFunction super R, ? super T, R> accumulator) {
final ExIterator iter = exIterator();
return this.newStream(new ExIterator() {
private R res = seed;
@Override
public boolean hasNext() {
return iter.hasNext();
}
@Override
public R next() {
return (res = accumulator.apply(res, iter.next()));
}
}, false, null);
}
@Override
public Stream intersperse(final T delimiter) {
return newStream(new ExIterator() {
private final Iterator iter = iterator();
private boolean toInsert = false;
@Override
public boolean hasNext() {
return iter.hasNext();
}
@Override
public T next() {
if (hasNext() == false) {
throw new NoSuchElementException();
}
if (toInsert) {
toInsert = false;
return delimiter;
} else {
final T res = iter.next();
toInsert = true;
return res;
}
}
}, false, null);
}
@Override
public void forEachPair(final BiConsumer super T, ? super T> action) {
forEachPair(action, 1);
}
@Override
public void forEachTriple(final TriConsumer super T, ? super T, ? super T> action) {
forEachTriple(action, 1);
}
@Override
public Stream>> groupBy(final Function super T, ? extends K> classifier) {
final Map> map = collect(Collectors.groupingBy(classifier));
return newStream(map.entrySet().iterator(), false, null);
}
@Override
public Stream>> groupBy(final Function super T, ? extends K> classifier, Supplier>> mapFactory) {
final Map> map = collect(Collectors.groupingBy(classifier, mapFactory));
return newStream(map.entrySet().iterator(), false, null);
}
@Override
public Stream>> groupBy(Function super T, ? extends K> classifier, Function super T, ? extends U> valueMapper) {
return groupBy(classifier, (Collector>) (Collector, ?, ?>) Collectors.mapping(valueMapper, Collectors.toList()));
}
@Override
@SuppressWarnings("rawtypes")
public Stream>> groupBy(Function super T, ? extends K> classifier, Function super T, ? extends U> valueMapper,
Supplier>> mapFactory) {
final Map> map = collect(
Collectors.groupingBy(classifier, (Collector>) (Collector) Collectors.mapping(valueMapper, Collectors.toList()), mapFactory));
return newStream(map.entrySet().iterator(), false, null);
}
@Override
public Stream> groupBy(final Function super T, ? extends K> classifier, Collector super T, A, D> downstream) {
final Map map = collect(Collectors.groupingBy(classifier, downstream));
return newStream(map.entrySet().iterator(), false, null);
}
@Override
public Stream> groupBy(final Function super T, ? extends K> classifier, Collector super T, A, D> downstream,
Supplier> mapFactory) {
final Map map = collect(Collectors.groupingBy(classifier, downstream, mapFactory));
return newStream(map.entrySet().iterator(), false, null);
}
@Override
public Stream> groupBy(final Function super T, ? extends K> classifier, final Function super T, ? extends U> valueMapper,
BinaryOperator mergeFunction) {
final Map map = collect(Collectors.toMap(classifier, valueMapper, mergeFunction));
return newStream(map.entrySet().iterator(), false, null);
}
@Override
public Stream> groupBy(final Function super T, ? extends K> classifier, final Function super T, ? extends U> valueMapper,
BinaryOperator mergeFunction, Supplier> mapFactory) {
final Map map = collect(Collectors.toMap(classifier, valueMapper, mergeFunction, mapFactory));
return newStream(map.entrySet().iterator(), false, null);
}
@Override
public EntryStream> groupByToEntry(Function super T, ? extends K> classifier) {
final Function>, Map.Entry>> mapper = Fn.identity();
final Function classifier2 = (Function) classifier;
return groupBy(classifier2).mapToEntry(mapper);
}
@Override
public EntryStream> groupByToEntry(Function super T, ? extends K> classifier, Supplier>> mapFactory) {
final Function>, Map.Entry>> mapper = Fn.identity();
return groupBy(classifier, mapFactory).mapToEntry(mapper);
}
@Override
public EntryStream> groupByToEntry(Function super T, ? extends K> classifier, Function super T, ? extends U> valueMapper) {
final Function>, Map.Entry>> mapper = Fn.identity();
final Function classifier2 = (Function) classifier;
final Function valueMapper2 = (Function) valueMapper;
return groupBy(classifier2, valueMapper2).mapToEntry(mapper);
}
@Override
public EntryStream> groupByToEntry(Function super T, ? extends K> classifier, Function super T, ? extends U> valueMapper,
Supplier>> mapFactory) {
final Function>, Map.Entry>> mapper = Fn.identity();
return groupBy(classifier, valueMapper, mapFactory).mapToEntry(mapper);
}
@Override
public EntryStream groupByToEntry(Function super T, ? extends K> classifier, Collector super T, A, D> downstream) {
final Function, Map.Entry> mapper = Fn.identity();
final Function classifier2 = (Function) classifier;
return groupBy(classifier2, downstream).mapToEntry(mapper);
}
@Override
public EntryStream groupByToEntry(Function super T, ? extends K> classifier, Collector super T, A, D> downstream,
Supplier> mapFactory) {
final Function, Map.Entry> mapper = Fn.identity();
return groupBy(classifier, downstream, mapFactory).mapToEntry(mapper);
}
@Override
public EntryStream groupByToEntry(Function super T, ? extends K> classifier, Function super T, ? extends U> valueMapper,
BinaryOperator mergeFunction) {
final Function, Map.Entry> mapper = Fn.identity();
final Function classifier2 = (Function) classifier;
final Function valueMapper2 = (Function) valueMapper;
return groupBy(classifier2, valueMapper2, mergeFunction).mapToEntry(mapper);
}
@Override
public EntryStream groupByToEntry(Function super T, ? extends K> classifier, Function super T, ? extends U> valueMapper,
BinaryOperator mergeFunction, Supplier> mapFactory) {
final Function, Map.Entry> mapper = Fn.identity();
return groupBy(classifier, valueMapper, mergeFunction, mapFactory).mapToEntry(mapper);
}
@Override
public Stream>> partitionBy(Predicate super T> predicate) {
final Map> map = collect(Collectors.partitioningBy(predicate));
return newStream(map.entrySet().iterator(), false, null);
}
@Override
public Stream> partitionBy(Predicate super T> predicate, Collector super T, ?, D> downstream) {
final Map map = collect(Collectors.partitioningBy(predicate, downstream));
return newStream(map.entrySet().iterator(), false, null);
}
@Override
public EntryStream> partitionByToEntry(Predicate super T> predicate) {
final Function>, Map.Entry>> mapper = Fn.identity();
return partitionBy(predicate).mapToEntry(mapper);
}
@Override
public EntryStream partitionByToEntry(Predicate super T> predicate, Collector super T, ?, D> downstream) {
final Function, Map.Entry> mapper = Fn.identity();
return partitionBy(predicate, downstream).mapToEntry(mapper);
}
@Override
public Map toMap(Function super T, ? extends K> keyExtractor, Function super T, ? extends U> valueMapper) {
final Supplier> mapFactory = Fn.Suppliers.ofMap();
return toMap(keyExtractor, valueMapper, mapFactory);
}
@Override
public > M toMap(Function super T, ? extends K> keyExtractor, Function super T, ? extends U> valueMapper,
Supplier mapFactory) {
final BinaryOperator mergeFunction = Fn.throwingMerger();
return toMap(keyExtractor, valueMapper, mergeFunction, mapFactory);
}
@Override
public Map toMap(Function super T, ? extends K> keyExtractor, Function super T, ? extends U> valueMapper,
BinaryOperator mergeFunction) {
final Supplier> mapFactory = Fn.Suppliers.ofMap();
return toMap(keyExtractor, valueMapper, mergeFunction, mapFactory);
}
@Override
public Map toMap(Function super T, ? extends K> classifier, Collector super T, A, D> downstream) {
final Supplier> mapFactory = Fn.Suppliers.ofMap();
return toMap(classifier, downstream, mapFactory);
}
@Override
public Map> groupTo(Function super T, ? extends K> classifier) {
final Supplier>> mapFactory = Fn.Suppliers.ofMap();
return groupTo(classifier, mapFactory);
}
@Override
public >> M groupTo(Function super T, ? extends K> classifier, Supplier mapFactory) {
final Collector super T, ?, List> downstream = Collectors.toList();
return toMap(classifier, downstream, mapFactory);
}
@Override
public Map> groupTo(Function super T, ? extends K> keyExtractor, Function super T, ? extends U> valueMapper) {
return toMap(keyExtractor, (Collector