Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #4
0
 public MapArray(MapArray<K, V> mapArray) {
   this();
   addAll(mapArray.stream().collect(toList()));
 }
Beispiel #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;
 }