MCPcopy Create free account
hub / github.com/curtcox/JLHTTP / toMap

Method toMap

src/main/java/net/freeutils/httpserver/HTTPServer.java:2384–2393  ·  view source on GitHub ↗

Converts a collection of pairs of objects (arrays of size two, each representing a key and corresponding value) into a Map. Duplicate keys are ignored (only the first occurrence of each key is considered). The map retains the original collection's iteration order. @param pairs a collection of array

(Collection<? extends Object[]> pairs)

Source from the content-addressed store, hash-verified

2382 * @return a map containing the paired keys and values, or an empty map
2383 */
2384 @SuppressWarnings("unchecked")
2385 public static <K, V> Map<K, V> toMap(Collection<? extends Object[]> pairs) {
2386 if (pairs == null || pairs.isEmpty())
2387 return Collections.emptyMap();
2388 Map<K, V> map = new LinkedHashMap<K, V>(pairs.size());
2389 for (Object[] pair : pairs)
2390 if (!map.containsKey(pair[0]))
2391 map.put((K)pair[0], (V)pair[1]);
2392 return map;
2393 }
2394
2395 /**
2396 * Returns the absolute (zero-based) content range value specified

Callers 1

getParamsMethod · 0.80

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected