Beispiel #1
0
 public static <K, V> HashMap<K, V> fromMap(Equal<K> eq, Hash<K> h, java.util.Map<K, V> map) {
   HashMap<K, V> m = hashMap(eq, h);
   for (Map.Entry<K, V> e : map.entrySet()) {
     m.set(e.getKey(), e.getValue());
   }
   return m;
 }
Beispiel #2
0
 /** Converts the Iterable to a HashMap */
 public static <K, V> HashMap<K, V> iterableHashMap(
     final Equal<K> equal, final Hash<K> hash, final Iterable<P2<K, V>> entries) {
   final HashMap<K, V> map = new HashMap<>(equal, hash);
   for (P2<K, V> entry : entries) {
     map.set(entry._1(), entry._2());
   }
   return map;
 }
Beispiel #3
0
 public <A, B> HashMap<A, B> map(
     F<K, A> keyFunction, F<V, B> valueFunction, Equal<A> equal, Hash<A> hash) {
   final HashMap<A, B> hashMap = new HashMap<>(equal, hash);
   for (K key : keys()) {
     final A newKey = keyFunction.f(key);
     final B newValue = valueFunction.f(get(key).some());
     hashMap.set(newKey, newValue);
   }
   return hashMap;
 }