MCPcopy Create free account
hub / github.com/crate/crate / map

Method map

libs/shared/src/main/java/io/crate/common/collections/Lists.java:156–165  ·  view source on GitHub ↗

Create a copy of the given list with mapper applied on each item. Opposed to java.util.stream.Stream#map(Function) / Collectors#toList() this minimizes allocations.

(Collection<I> list, Function<? super I, ? extends O> mapper)

Source from the content-addressed store, hash-verified

154 * Opposed to {@link java.util.stream.Stream#map(Function)} / {@link Collectors#toList()} this minimizes allocations.
155 */
156 public static <I, O> List<O> map(Collection<I> list, Function<? super I, ? extends O> mapper) {
157 if (list.isEmpty()) {
158 return List.of();
159 }
160 ArrayList<O> copy = new ArrayList<>(list.size());
161 for (I item : list) {
162 copy.add(mapper.apply(item));
163 }
164 return copy;
165 }
166
167 /**
168 * Like `map` but ensures that the same list is returned if no elements changed.

Callers 15

visitCreateTableMethod · 0.95
visitUpdateMethod · 0.95
visitSetGlobalMethod · 0.95
visitSetTransactionMethod · 0.95
visitAddColumnMethod · 0.95
visitDropColumnMethod · 0.95
identsToStringsMethod · 0.95
mapMethod · 0.95
mapMethod · 0.95
mapMethod · 0.95

Calls 5

ofMethod · 0.65
sizeMethod · 0.65
addMethod · 0.65
applyMethod · 0.65
isEmptyMethod · 0.45

Tested by 15

executeAggregationMethod · 0.76
QueryCmdMethod · 0.76
getFunctionMethod · 0.76
indexValuesMethod · 0.76
addTableMethod · 0.76
toMappingMethod · 0.76
isDocKeyMethod · 0.76
evaluateMethod · 0.76
publicationsMetadataMethod · 0.76