public Map<K, V> valueFilter($.Function<V, Boolean> predicate) { java.util.Map<K, V> map = new HashMap<>(); for (java.util.Map.Entry<K, V> entry : entrySet()) { V v = entry.getValue(); if (predicate.apply(v)) { map.put(entry.getKey(), v); } } Map<K, V> filtered = new Map<>(isReadOnly(), map); return filtered; }
public Map<K, V> filter($.Function<K, Boolean> predicate) { java.util.Map<K, V> map = new HashMap<>(); for (java.util.Map.Entry<K, V> entry : entrySet()) { K k = entry.getKey(); if (predicate.apply(k)) { map.put(k, entry.getValue()); } } Map<K, V> filtered = new Map<>(isReadOnly(), map); return filtered; }
public Map<K, V> filter($.Function<K, Boolean> predicate) { java.util.Map<K, V> map = new HashMap<>(); for (java.util.Map.Entry<K, V> entry : entrySet()) { K k = entry.getKey(); if (predicate.apply(k)) { map.put(k, entry.getValue()); } } Map<K, V> filtered = new Map<>(isReadOnly(), map); return filtered; }
/** * Create an new {@link Map} from an array of elements. * <p>Example</p> * <pre> * Map<String, Integer> scores = C.newMap("Tom", 80, "Peter", 93, ...); * </pre> * <p>The above code will create a Map with the following entries</p> * <ul> * <li>(Tom, 80)</li> * <li>(Peter, 93)</li> * <li>...</li> * </ul> * <p><b>Note</b> the array size must be an even number, otherwise {@link IndexOutOfBoundsException} * will be thrown out</p> * @param args the argument array specifies the entries * @param <K> the key type * @param <V> the value type * @return a map contains of specified entries * @see #Map(Object...) */ @SuppressWarnings("unchecked") public static <K, V> Map<K, V> newMap(Object... args) { return new Map(false, args); }
/** * Create a immutable {@link Map} from elements specified in an array. * <p>Example</p> * <pre> * Map<String, Integer> scores = C.map("Tom", 80, "Peter", 93, ...); * </pre> * <p>The above code will create an immutable Map with the following entries</p> * <ul> * <li>(Tom, 80)</li> * <li>(Peter, 93)</li> * <li>...</li> * </ul> * <p><b>Note</b> the array size must be an even number, otherwise {@link IndexOutOfBoundsException} * will be thrown out</p> * @param args the argument array specifies the entries * @param <K> the key type * @param <V> the value type * @return an immutable map contains of specified entries * @see #newMap(Object...) */ public static <K, V> Map<K, V> Map(Object... args) { if (null == args || args.length == 0) { return Nil.EMPTY_MAP; } return new Map<>(true, args); }
/** * Create an new {@link Map} from an array of elements. * <p>Example</p> * <pre> * Map<String, Integer> scores = C.newMap("Tom", 80, "Peter", 93, ...); * </pre> * <p>The above code will create a Map with the following entries</p> * <ul> * <li>(Tom, 80)</li> * <li>(Peter, 93)</li> * <li>...</li> * </ul> * <p><b>Note</b> the array size must be an even number, otherwise {@link IndexOutOfBoundsException} * will be thrown out</p> * @param args the argument array specifies the entries * @param <K> the key type * @param <V> the value type * @return a map contains of specified entries * @see #Map(Object...) */ @SuppressWarnings("unchecked") public static <K, V> Map<K, V> newMap(Object... args) { return new Map(false, args); }
/** * Create a immutable {@link Map} from elements specified in an array. * <p>Example</p> * <pre> * Map<String, Integer> scores = C.map("Tom", 80, "Peter", 93, ...); * </pre> * <p>The above code will create an immutable Map with the following entries</p> * <ul> * <li>(Tom, 80)</li> * <li>(Peter, 93)</li> * <li>...</li> * </ul> * <p><b>Note</b> the array size must be an even number, otherwise {@link IndexOutOfBoundsException} * will be thrown out</p> * @param args the argument array specifies the entries * @param <K> the key type * @param <V> the value type * @return an immutable map contains of specified entries * @see #newMap(Object...) */ public static <K, V> Map<K, V> Map(Object... args) { if (null == args || args.length == 0) { return Nil.EMPTY_MAP; } return new Map<>(true, args); }
public static <K, V> Map<K, V> Map(boolean readOnly, java.util.Map<K, V> map) { return new Map(readOnly, map); }
public static <K, V> Map<K, V> Map(boolean readOnly, java.util.Map<K, V> map) { return new Map(readOnly, map); }
/** * Create an immutable {@link java.util.Map} from existing {@link java.util.Map} * @param map the map from which entries will be put into the new immutable map * @param <K> the key type * @param <V> the value type * @return an immutable map of the existing map */ public static <K, V> Map<K, V> Map(java.util.Map<? extends K, ? extends V> map) { if (null == map) { return Nil.EMPTY_MAP; } return new Map(true, map); }
/** * Create an new {@link Map} from existing {@link java.util.Map} * @param map the map that contains elements to be put into the new map * @param <K> the key type * @param <V> the value type * @return a map that contains all entries in the existing map */ @SuppressWarnings("unchecked") public static <K, V> Map<K, V> newMap(java.util.Map<? extends K, ? extends V> map) { return new Map(false, map); }
public Map<K, V> valueFilter($.Function<V, Boolean> predicate) { java.util.Map<K, V> map = new HashMap<>(); for (java.util.Map.Entry<K, V> entry : entrySet()) { V v = entry.getValue(); if (predicate.apply(v)) { map.put(entry.getKey(), v); } } Map<K, V> filtered = new Map<>(isReadOnly(), map); return filtered; }
/** * Create an immutable {@link java.util.Map} from existing {@link java.util.Map} * @param map the map from which entries will be put into the new immutable map * @param <K> the key type * @param <V> the value type * @return an immutable map of the existing map */ public static <K, V> Map<K, V> Map(java.util.Map<? extends K, ? extends V> map) { if (null == map) { return Nil.EMPTY_MAP; } return new Map(true, map); }
@SuppressWarnings("unused") public Map<K, V> readOnly(boolean readOnly) { if (ro ^ readOnly) { return new Map<>(readOnly, _m); } else { return this; } }
public static <K, V> Map<K, V> Map(Collection<$.Tuple<K, V>> kvCol) { Map<K, V> map = C.newMap(); for ($.Tuple<K, V> entry : kvCol) { map.put(entry._1, entry._2); } return new Map<>(true, map); }
@SuppressWarnings("unused") public Map<K, V> readOnly(boolean readOnly) { if (ro ^ readOnly) { return new Map<>(readOnly, _m); } else { return this; } }
/** * Create an new {@link Map} from existing {@link java.util.Map} * @param map the map that contains elements to be put into the new map * @param <K> the key type * @param <V> the value type * @return a map that contains all entries in the existing map */ @SuppressWarnings("unchecked") public static <K, V> Map<K, V> newMap(java.util.Map<? extends K, ? extends V> map) { return new Map(false, map); }
public static <K, V> Map<K, V> Map(Collection<$.Tuple<K, V>> kvCol) { Map<K, V> map = C.newMap(); for ($.Tuple<K, V> entry : kvCol) { map.put(entry._1, entry._2); } return new Map<>(true, map); }