/** * Creates a TreeMultimap of the given key-value pair. * * @param key A singleton map key. * @param value A singleton map value. * @param <K> The key type * @param <V2> The value type * @return A new Multimap containing the given entries */ public <K extends Comparable<? super K>, V2 extends V> TreeMultimap<K, V2> of(K key, V2 value) { return of(Comparators.naturalComparator(), key, value); }
@SuppressWarnings("varargs") @SafeVarargs public static <T extends Comparable<? super T>> TreeSet<T> of(T... values) { return TreeSet.<T> of(Comparators.naturalComparator(), values); }
/** * Returns the empty TreeMultimap. The underlying key comparator is the natural comparator of K. * * @param <K> The key type * @param <V2> The value type * @return A new empty TreeMultimap. */ public <K extends Comparable<? super K>, V2 extends V> TreeMultimap<K, V2> empty() { return empty(Comparators.naturalComparator()); }
/** * Creates a TreeMultimap of the given list of key-value pairs. * * @param <K> The key type * @param <V2> The value type * @param entry The key-value pair used to form a new TreeMultimap. * @return A new Multimap containing the given entry */ public <K extends Comparable<? super K>, V2 extends V> TreeMultimap<K, V2> of(Tuple2<? extends K, ? extends V2> entry) { return of(Comparators.naturalComparator(), entry); }
/** * Returns the empty PriorityQueue. * * @param <T> Component type * @return The empty PriorityQueue. */ public static <T extends Comparable<? super T>> PriorityQueue<T> empty() { return empty(Comparators.naturalComparator()); }
/** * Creates a {@code TreeMultimap} of the given entries. * The underlying key comparator is the natural comparator of K. * * @param <K> The key type * @param <V2> The value type * @param entries Multimap entries * @return A new TreeMultimap containing the given entries. */ public <K extends Comparable<? super K>, V2 extends V> TreeMultimap<K, V2> ofEntries(Iterable<? extends Tuple2<? extends K, ? extends V2>> entries) { return ofEntries(Comparators.naturalComparator(), entries); }
/** * Returns a {@link java.util.stream.Collector} which may be used in conjunction with * {@link java.util.stream.Stream#collect(java.util.stream.Collector)} to obtain a {@link TreeSet}. * <p> * The natural comparator is used to compare TreeSet elements. * * @param <T> Component type of the List. * @return A io.vavr.collection.List Collector. */ public static <T extends Comparable<? super T>> Collector<T, ArrayList<T>, TreeSet<T>> collector() { return collector(Comparators.naturalComparator()); }
@Override public <T1, T2, T3> Tuple3<? extends PriorityQueue<T1>, ? extends PriorityQueue<T2>, ? extends PriorityQueue<T3>> unzip3(Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) { Objects.requireNonNull(unzipper, "unzipper is null"); final Tuple3<io.vavr.collection.Iterator<T1>, io.vavr.collection.Iterator<T2>, io.vavr.collection.Iterator<T3>> unzip3 = iterator().unzip3(unzipper); return Tuple.of(ofAll(Comparators.naturalComparator(), unzip3._1), ofAll(Comparators.naturalComparator(), unzip3._2), ofAll(Comparators.naturalComparator(), unzip3._3)); }
@Override public <T1, T2, T3> Tuple3<TreeSet<T1>, TreeSet<T2>, TreeSet<T3>> unzip3( Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) { Objects.requireNonNull(unzipper, "unzipper is null"); return iterator().unzip3(unzipper).map( i1 -> TreeSet.ofAll(Comparators.naturalComparator(), i1), i2 -> TreeSet.ofAll(Comparators.naturalComparator(), i2), i3 -> TreeSet.ofAll(Comparators.naturalComparator(), i3)); }
@Override default <U, R> TreeSet<R> zipWith(Iterable<? extends U> that, BiFunction<? super T, ? super U, ? extends R> mapper) { Objects.requireNonNull(that, "that is null"); Objects.requireNonNull(mapper, "mapper is null"); return TreeSet.ofAll(Comparators.naturalComparator(), iterator().zipWith(that, mapper)); }
@Override public <K2> TreeMap<K2, V> mapKeys(Function<? super K, ? extends K2> keyMapper, BiFunction<? super V, ? super V, ? extends V> valueMerge) { final Comparator<K2> comparator = Comparators.naturalComparator(); return Collections.mapKeys(this, TreeMap.<K2, V> empty(comparator), keyMapper, valueMerge); }
@Override public <U, R> TreeSet<R> zipWith(Iterable<? extends U> that, BiFunction<? super T, ? super U, ? extends R> mapper) { Objects.requireNonNull(that, "that is null"); Objects.requireNonNull(mapper, "mapper is null"); return TreeSet.ofAll(Comparators.naturalComparator(), iterator().zipWith(that, mapper)); }
@Override public <U, R> PriorityQueue<R> zipWith(Iterable<? extends U> that, BiFunction<? super T, ? super U, ? extends R> mapper) { Objects.requireNonNull(that, "that is null"); Objects.requireNonNull(mapper, "mapper is null"); return ofAll(Comparators.naturalComparator(), iterator().zipWith(that, mapper)); }
@Override default <T1, T2> Tuple2<TreeSet<T1>, TreeSet<T2>> unzip( Function<? super T, Tuple2<? extends T1, ? extends T2>> unzipper) { Objects.requireNonNull(unzipper, "unzipper is null"); return iterator().unzip(unzipper).map(i1 -> TreeSet.ofAll(Comparators.naturalComparator(), i1), i2 -> TreeSet.ofAll(Comparators.naturalComparator(), i2)); }
@Override default <R> SortedSet<R> collect(PartialFunction<? super T, ? extends R> partialFunction) { Objects.requireNonNull(partialFunction, "partialFunction is null"); return TreeSet.ofAll(Comparators.naturalComparator(), iterator().collect(partialFunction)); }
@Override public <U> PriorityQueue<U> zipWithIndex(BiFunction<? super T, ? super Integer, ? extends U> mapper) { Objects.requireNonNull(mapper, "mapper is null"); return ofAll(Comparators.naturalComparator(), iterator().zipWithIndex(mapper)); }
@Override default <U> TreeSet<U> zipWithIndex(BiFunction<? super T, ? super Integer, ? extends U> mapper) { Objects.requireNonNull(mapper, "mapper is null"); return TreeSet.ofAll(Comparators.naturalComparator(), iterator().zipWithIndex(mapper)); } }
@Override public <U> Set<U> scanLeft(U zero, BiFunction<? super U, ? super T, ? extends U> operation) { if (zero instanceof Comparable) { final Comparator<U> comparator = Comparators.naturalComparator(); return Collections.scanLeft(this, zero, operation, iter -> TreeSet.ofAll(comparator, iter)); } else { return Collections.scanLeft(this, zero, operation, HashSet::ofAll); } }
@Override default <U> TreeSet<Tuple2<T, U>> zipAll(Iterable<? extends U> that, T thisElem, U thatElem) { Objects.requireNonNull(that, "that is null"); final Comparator<Tuple2<T, U>> tuple2Comparator = Tuple2.comparator(comparator(), Comparators.naturalComparator()); return TreeSet.ofAll(tuple2Comparator, iterator().zipAll(that, thisElem, thatElem)); }
@Override default <U> TreeSet<Tuple2<T, U>> zip(Iterable<? extends U> that) { Objects.requireNonNull(that, "that is null"); final Comparator<Tuple2<T, U>> tuple2Comparator = Tuple2.comparator(comparator(), Comparators.naturalComparator()); return TreeSet.ofAll(tuple2Comparator, iterator().zip(that)); }