Example #1
0
 public <KResult, VResult> MapArray<KResult, VResult> toMapArray(
     BiFunction<K, V, KResult> key, BiFunction<K, V, VResult> value) {
   MapArray<KResult, VResult> result = new MapArray<>();
   for (Pair<K, V> pair : pairs)
     result.add(key.apply(pair.key, pair.value), value.apply(pair.key, pair.value));
   return result;
 }
Example #2
0
 public static <Key, Value> MapArray<Key, Value> toMapArray(Map<Key, Value> map) {
   MapArray<Key, Value> mapArray = new MapArray<>();
   for (Map.Entry<Key, Value> e : map.entrySet()) mapArray.add(e.getKey(), e.getValue());
   return mapArray;
 }
Example #3
0
 public static <T> MapArray<Integer, T> toMapArray(Collection<T> collection) {
   MapArray<Integer, T> mapArray = new MapArray<>();
   int i = 0;
   for (T t : collection) mapArray.add(i++, t);
   return mapArray;
 }
Example #4
0
 public MapArray(MapArray<K, V> mapArray) {
   this();
   addAll(mapArray.stream().collect(toList()));
 }
Example #5
0
 public <VResult> MapArray<K, VResult> toMapArray(Function<V, VResult> value) {
   MapArray<K, VResult> result = new MapArray<>();
   for (Pair<K, V> pair : pairs) result.add(pair.key, value.apply(pair.value));
   return result;
 }