/** * Returns a singleton {@code TreeMap}, i.e. a {@code TreeMap} of one entry. * The underlying key comparator is the natural comparator of K. * * @param <K> The key type * @param <V> The value type * @param entry A map entry. * @return A new TreeMap containing the given entry. */ public static <K extends Comparable<? super K>, V> TreeMap<K, V> of(Tuple2<? extends K, ? extends V> entry) { Objects.requireNonNull(entry, "entry is null"); return createFromTuple(EntryComparator.natural(), entry); }
/** * Returns a singleton {@code TreeMap}, i.e. a {@code TreeMap} of one entry using a specific key comparator. * * @param <K> The key type * @param <V> The value type * @param keyComparator The comparator used to sort the entries by their key. * @param entry A map entry. * @return A new TreeMap containing the given entry. */ public static <K, V> TreeMap<K, V> of(Comparator<? super K> keyComparator, Tuple2<? extends K, ? extends V> entry) { Objects.requireNonNull(entry, "entry is null"); return createFromTuple(EntryComparator.of(keyComparator), entry); }
/** * Returns a singleton {@code TreeMap}, i.e. a {@code TreeMap} of one entry using a specific key comparator. * * @param <K> The key type * @param <V> The value type * @param keyComparator The comparator used to sort the entries by their key. * @param entry A map entry. * @return A new TreeMap containing the given entry. */ public static <K, V> TreeMap<K, V> of(Comparator<? super K> keyComparator, Tuple2<? extends K, ? extends V> entry) { Objects.requireNonNull(entry, "entry is null"); return createFromTuple(EntryComparator.of(keyComparator), entry); }
/** * Returns a singleton {@code TreeMap}, i.e. a {@code TreeMap} of one entry. * The underlying key comparator is the natural comparator of K. * * @param <K> The key type * @param <V> The value type * @param entry A map entry. * @return A new TreeMap containing the given entry. */ public static <K extends Comparable<? super K>, V> TreeMap<K, V> of(Tuple2<? extends K, ? extends V> entry) { Objects.requireNonNull(entry, "entry is null"); return createFromTuple(EntryComparator.natural(), entry); }