MCPcopy Index your code
hub / github.com/graphql-java/graphql-java / map

Method map

src/main/java/graphql/collect/ImmutableKit.java:53–62  ·  view source on GitHub ↗

This is more efficient than `c.stream().map().collect()` because it does not create the intermediate objects needed for the flexible style. Benchmarking has shown this to outperform `stream()`. @param collection the collection to map @param mapper the mapper function @param for two

(Collection<? extends T> collection, Function<? super T, ? extends R> mapper)

Source from the content-addressed store, hash-verified

51 * @return a map immutable list of results
52 */
53 public static <T, R> ImmutableList<R> map(Collection<? extends T> collection, Function<? super T, ? extends R> mapper) {
54 assertNotNull(collection);
55 assertNotNull(mapper);
56 ImmutableList.Builder<R> builder = ImmutableList.builderWithExpectedSize(collection.size());
57 for (T t : collection) {
58 R r = mapper.apply(t);
59 builder.add(r);
60 }
61 return builder.build();
62 }
63
64 public static <T, R> ImmutableSet<R> mapToSet(Collection<? extends T> collection, Function<? super T, ? extends R> mapper) {
65 assertNotNull(collection);

Callers 15

checkForMissingTypesMethod · 0.95
getTypesMethod · 0.95
getTypesMethod · 0.95
toAppliedDirectivesMethod · 0.95
mainMethod · 0.45
ExecutionBenchmarkClass · 0.45
allOfMethod · 0.45

Calls 5

assertNotNullMethod · 0.80
applyMethod · 0.65
addMethod · 0.65
buildMethod · 0.65
sizeMethod · 0.45

Tested by 8

allOfMethod · 0.36
getDepartmentsForShopMethod · 0.36
parseLiteralMethod · 0.36