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.
/*
* Copyright (C) 2017 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.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import com.landawn.abacus.util.Comparators;
import com.landawn.abacus.util.Fn;
import com.landawn.abacus.util.ImmutableIterator;
import com.landawn.abacus.util.LongMultiset;
import com.landawn.abacus.util.Multimap;
import com.landawn.abacus.util.Multiset;
import com.landawn.abacus.util.NullabLe;
import com.landawn.abacus.util.Pair;
import com.landawn.abacus.util.Tuple;
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.Predicate;
import com.landawn.abacus.util.function.Supplier;
/**
*
* @since 0.9
*
* @author Haiyang Li
*/
public final class EntryStream {
@SuppressWarnings("rawtypes")
private static final EntryStream EMPTY = of(new Map.Entry[0]);
private final Stream> s;
EntryStream(final Stream extends Map.Entry> s) {
this.s = (Stream>) s;
}
public static EntryStream empty() {
return EMPTY;
}
public static EntryStream of(final Stream extends Map.Entry> s) {
return new EntryStream(s);
}
public static EntryStream of(final Iterator extends Map.Entry> iterator) {
return new EntryStream(Stream.of(iterator));
}
public static EntryStream of(final Map map) {
return new EntryStream(Stream.of(map));
}
public static EntryStream of(final Collection extends Map.Entry> entries) {
return new EntryStream(Stream.of(entries));
}
@SafeVarargs
public static EntryStream of(final Map.Entry... entries) {
return new EntryStream(Stream.of(entries));
}
public static EntryStream of(final Multiset multiset) {
final Function, Map.Entry> mapper = Fn.identity();
return multiset == null ? EntryStream. empty() : multiset.stream().mapToEntry(mapper);
}
public static EntryStream of(final LongMultiset multiset) {
final Function, Map.Entry> mapper = Fn.identity();
return multiset == null ? EntryStream. empty() : multiset.stream().mapToEntry(mapper);
}
public static > EntryStream of(final Multimap mulitmap) {
final Function, Map.Entry> mapper = Fn.identity();
return mulitmap == null ? EntryStream. empty() : mulitmap.stream().mapToEntry(mapper);
}
public static EntryStream of(final Collection extends T> c, final Function super T, K> keyExtractor) {
final Function valueMapper = Fn.identity();
return Stream.of(c).mapToEntry(keyExtractor, valueMapper);
}
public static EntryStream of(final T[] a, final Function super T, K> keyExtractor) {
final Function valueMapper = Fn.identity();
return Stream.of(a).mapToEntry(keyExtractor, valueMapper);
}
@SafeVarargs
public static EntryStream concat(final Map... maps) {
final Function