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