diff --git a/libraries/stdlib/common/src/generated/_Arrays.kt b/libraries/stdlib/common/src/generated/_Arrays.kt index 100851f95b6..469d07ca02b 100644 --- a/libraries/stdlib/common/src/generated/_Arrays.kt +++ b/libraries/stdlib/common/src/generated/_Arrays.kt @@ -12531,6 +12531,10 @@ public infix fun CharArray.union(other: Iterable): Set { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun Array.all(predicate: (T) -> Boolean): Boolean { @@ -12541,6 +12545,10 @@ public inline fun Array.all(predicate: (T) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun ByteArray.all(predicate: (Byte) -> Boolean): Boolean { @@ -12551,6 +12559,10 @@ public inline fun ByteArray.all(predicate: (Byte) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun ShortArray.all(predicate: (Short) -> Boolean): Boolean { @@ -12561,6 +12573,10 @@ public inline fun ShortArray.all(predicate: (Short) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun IntArray.all(predicate: (Int) -> Boolean): Boolean { @@ -12571,6 +12587,10 @@ public inline fun IntArray.all(predicate: (Int) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun LongArray.all(predicate: (Long) -> Boolean): Boolean { @@ -12581,6 +12601,10 @@ public inline fun LongArray.all(predicate: (Long) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun FloatArray.all(predicate: (Float) -> Boolean): Boolean { @@ -12591,6 +12615,10 @@ public inline fun FloatArray.all(predicate: (Float) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun DoubleArray.all(predicate: (Double) -> Boolean): Boolean { @@ -12601,6 +12629,10 @@ public inline fun DoubleArray.all(predicate: (Double) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun BooleanArray.all(predicate: (Boolean) -> Boolean): Boolean { @@ -12611,6 +12643,10 @@ public inline fun BooleanArray.all(predicate: (Boolean) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun CharArray.all(predicate: (Char) -> Boolean): Boolean { diff --git a/libraries/stdlib/common/src/generated/_Collections.kt b/libraries/stdlib/common/src/generated/_Collections.kt index debb11a6521..e2dd983ef02 100644 --- a/libraries/stdlib/common/src/generated/_Collections.kt +++ b/libraries/stdlib/common/src/generated/_Collections.kt @@ -1716,6 +1716,10 @@ public infix fun Iterable.union(other: Iterable): Set { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the collection contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun Iterable.all(predicate: (T) -> Boolean): Boolean { diff --git a/libraries/stdlib/common/src/generated/_Maps.kt b/libraries/stdlib/common/src/generated/_Maps.kt index a11c6219779..03770acfa81 100644 --- a/libraries/stdlib/common/src/generated/_Maps.kt +++ b/libraries/stdlib/common/src/generated/_Maps.kt @@ -157,6 +157,10 @@ public inline fun > Map.mapTo(des /** * Returns `true` if all entries match the given [predicate]. * + * Note that if the map contains no entries, the function returns `true` + * because there are no entries in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun Map.all(predicate: (Map.Entry) -> Boolean): Boolean { diff --git a/libraries/stdlib/common/src/generated/_Sequences.kt b/libraries/stdlib/common/src/generated/_Sequences.kt index f3789d14db1..76c6b6747e9 100644 --- a/libraries/stdlib/common/src/generated/_Sequences.kt +++ b/libraries/stdlib/common/src/generated/_Sequences.kt @@ -1193,6 +1193,10 @@ public fun Sequence.toMutableSet(): MutableSet { /** * Returns `true` if all elements match the given [predicate]. + * + * Note that if the sequence contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. * * The operation is _terminal_. * diff --git a/libraries/stdlib/common/src/generated/_Strings.kt b/libraries/stdlib/common/src/generated/_Strings.kt index 4febfcf2cec..5fc090c5ab5 100644 --- a/libraries/stdlib/common/src/generated/_Strings.kt +++ b/libraries/stdlib/common/src/generated/_Strings.kt @@ -1054,6 +1054,10 @@ public fun CharSequence.withIndex(): Iterable> { /** * Returns `true` if all characters match the given [predicate]. * + * Note that if the char sequence contains no characters, the function returns `true` + * because there are no characters in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ public inline fun CharSequence.all(predicate: (Char) -> Boolean): Boolean { diff --git a/libraries/stdlib/common/src/generated/_UArrays.kt b/libraries/stdlib/common/src/generated/_UArrays.kt index 4e5f7a527d0..8fcaabec1e6 100644 --- a/libraries/stdlib/common/src/generated/_UArrays.kt +++ b/libraries/stdlib/common/src/generated/_UArrays.kt @@ -5345,6 +5345,10 @@ public fun UShortArray.withIndex(): Iterable> { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ @SinceKotlin("1.3") @@ -5358,6 +5362,10 @@ public inline fun UIntArray.all(predicate: (UInt) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ @SinceKotlin("1.3") @@ -5371,6 +5379,10 @@ public inline fun ULongArray.all(predicate: (ULong) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ @SinceKotlin("1.3") @@ -5384,6 +5396,10 @@ public inline fun UByteArray.all(predicate: (UByte) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. * + * Note that if the array contains no elements, the function returns `true` + * because there are no elements in it that _do not_ match the predicate. + * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. + * * @sample samples.collections.Collections.Aggregates.all */ @SinceKotlin("1.3") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt index 3155ca6b677..255df8372bc 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -36,6 +36,10 @@ object Aggregates : TemplateGroupBase() { doc { """ Returns `true` if all ${f.element.pluralize()} match the given [predicate]. + + Note that if the ${f.collection} contains no ${f.element.pluralize()}, the function returns `true` + because there are no ${f.element.pluralize()} in it that _do not_ match the predicate. + See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. """ } sample("samples.collections.Collections.Aggregates.all")