Class ListUtilitiesKt
-
- All Implemented Interfaces:
public final class ListUtilitiesKt
-
-
Method Summary
Modifier and Type Method Description final static BooleanendsWith(List<String> $self, String string)Check whether any entry in this list ends with the given string. final static BooleanstartsWith(List<String> $self, String string)Check whether any entry in this list starts with the given string. final static <A extends Any, B extends Any> List<B>parallelMap(List<A> $self, CoroutineContext context, SuspendFunction1<A, B> function)Compute all elements in the list in parallel and continue when every element was computed. final static <T extends Any> UnitaddMultiple(List<T> $self, T entries)Add multiple elements to a list in one go. final static <T extends Any> List<T>concatenate(List<T> lists)Flatten several lists into one, preserving order. -
-
Method Detail
-
endsWith
final static Boolean endsWith(List<String> $self, String string)
Check whether any entry in this list ends with the given string.
- Parameters:
string- The text to check entries with.
-
startsWith
final static Boolean startsWith(List<String> $self, String string)
Check whether any entry in this list starts with the given string.
- Parameters:
string- The text to check entries with.
-
parallelMap
final static <A extends Any, B extends Any> List<B> parallelMap(List<A> $self, CoroutineContext context, SuspendFunction1<A, B> function)
Compute all elements in the list in parallel and continue when every element was computed.
Defaults to Dispatchers.Default, the shared pool sized to the available processors, so elements genuinely run in parallel and no thread outlives the call. Do not default this to
newSingleThreadContext: that factory hands out a dedicated thread its creator has toclose(), which a defaulted parameter can never do, so every invocation stranded one thread for the life of the JVM — and confined the whole list to a single thread besides. Pinned byListUtilitiesTest.parallelMapDoesNotLeakAThreadPerInvocationandListUtilitiesTest.parallelMapRunsElementsOnMoreThanOneThread.
-
addMultiple
final static <T extends Any> Unit addMultiple(List<T> $self, T entries)
Add multiple elements to a list in one go.
-
concatenate
final static <T extends Any> List<T> concatenate(List<T> lists)
Flatten several lists into one, preserving order. Top-level so callers need no utilities instance.
-
-
-
-