public <A, R> EntryStream<K, R> collapseKeys(Collector<? super V, A, R> collector) {
        Supplier<A> supplier = collector.supplier();
        BiConsumer<A, ? super V> accumulator = collector.accumulator();
        BinaryOperator<A> combiner = collector.combiner();
        Function<A, R> finisher = collector.finisher();
        return new StreamEx<>(new CollapseSpliterator<Entry<K, V>, PairBox<K, A>>(equalKeys(), e -> {
            A a = supplier.get();
            accumulator.accept(a, e.getValue());
            return new PairBox<>(e.getKey(), a);
        }, (pb, e) -> {
            accumulator.accept(pb.b, e.getValue());
            return pb;
        }, (pb1, pb2) -> {
            pb1.b = combiner.apply(pb1.b, pb2.b);
            return pb1;
        }, spliterator()), context).mapToEntry(pb -> pb.a, pb -> finisher.apply(pb.b));
    }
public < A , R > EntryStream < K , R > collapseKeys ( Collector < ? super V , A , R > collector ) { Supplier < A > supplier = collector . supplier ( ) ; BiConsumer < A , ? super V > accumulator = collector . accumulator ( ) ; BinaryOperator < A > combiner = collector . combiner ( ) ; Function < A , R > finisher = collector . finisher ( ) ; return new StreamEx < > ( new CollapseSpliterator < Entry < K , V > , PairBox < K , A > > ( equalKeys ( ) , e -> { A a = supplier . get ( ) ; accumulator . accept ( a , e . getValue ( ) ) ; return new PairBox < > ( e . getKey ( ) , a ) ; } , ( pb , e ) -> { accumulator . accept ( pb . b , e . getValue ( ) ) ; return pb ; } , ( pb1 , pb2 ) -> { pb1 . b = combiner . apply ( pb1 . b , pb2 . b ) ; return pb1 ; } , spliterator ( ) ) , context ) . mapToEntry ( pb -> pb . a , pb -> finisher . apply ( pb . b ) ) ; }
Merge series of adjacent stream entries with equal keys combining the
corresponding values using the provided {@code Collector}.

<p>
This is a <a href="package-summary.html#StreamOps">quasi-intermediate</a>
partial reduction operation.

<p>
The key of the resulting entry is the key of the first merged entry.

@param <R> the type of the values in the resulting stream
@param <A> the intermediate accumulation type of the {@code Collector}
@param collector a {@code Collector} which is used to combine the values
of the adjacent entries with the equal keys.
@return a new {@code EntryStream} which keys are the keys of the original
stream and the values are values of the adjacent entries with the
same keys, combined using the provided collector.
@see StreamEx#collapse(BiPredicate, Collector)
@since 0.5.5