/** * Create a new {@link CopyOnWriteSortedMap} where the underlying map * instances are {@link TreeMap}, the sort uses the key's natural order and * the initial values are supplied. * <p> * This map has {@link View.Type.STABLE stable} views. * * @param map to use as the initial values. * @param comparator for ordering. */ public static <K, V> CopyOnWriteSortedMap<K, V> newTreeMap(final @NotNull Map<? extends K, ? extends V> map, final @NotNull Comparator<? super K> comparator) { final Builder<K, V> builder = builder(); notNull("comparator", comparator); notNull("map", map); return builder.ordering(comparator).addAll(map).newTreeMap(); }
/** * Create a new {@link CopyOnWriteSortedMap} where the underlying map * instances are {@link TreeMap}, the sort uses the key's natural order and * the initial values are supplied. * <p> * This map has {@link View.Type.STABLE stable} views. * * @param map the map to use as the initial values. */ public static <K, V> CopyOnWriteSortedMap<K, V> newTreeMap(final @NotNull Map<? extends K, ? extends V> map) { final Builder<K, V> builder = builder(); notNull("map", map); return builder.addAll(map).newTreeMap(); }
/** * Create a new {@link CopyOnWriteSortedMap} where the underlying map * instances are {@link TreeMap}. * <p> * This map has {@link View.Type.STABLE stable} views. * * @param comparator the Comparator to use for ordering the keys. Note, should * be serializable if this map is to be serialized. */ public static <K, V> CopyOnWriteSortedMap<K, V> newTreeMap(final @NotNull Comparator<? super K> comparator) { final Builder<K, V> builder = builder(); notNull("comparator", comparator); return builder.ordering(comparator).newTreeMap(); }
/** * Create a new {@link CopyOnWriteSortedMap} where the underlying map * instances are {@link TreeMap} and the sort uses the key's natural order. * <p> * This map has {@link View.Type.STABLE stable} views. */ public static <K, V> CopyOnWriteSortedMap<K, V> newTreeMap() { final Builder<K, V> builder = builder(); return builder.newTreeMap(); }