Reformat stdlib: jvm part

#KT-5558
This commit is contained in:
Ilya Gorbunov
2018-04-20 23:33:11 +03:00
parent c53a2d57c3
commit e3883d8d6d
36 changed files with 337 additions and 271 deletions
@@ -17,6 +17,7 @@
@file:Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmName("CollectionsJDK8Kt")
@file:kotlin.jvm.JvmPackageName("kotlin.collections.jdk8")
package kotlin.collections
/**
@@ -25,8 +26,8 @@ package kotlin.collections
*/
@SinceKotlin("1.2")
@kotlin.internal.InlineOnly
public inline fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.getOrDefault(key: K, defaultValue: V): V
= (this as Map<K, V>).getOrDefault(key, defaultValue)
public inline fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.getOrDefault(key: K, defaultValue: V): V =
(this as Map<K, V>).getOrDefault(key, defaultValue)
/**
@@ -35,5 +36,5 @@ public inline fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.getOrDefa
*/
@SinceKotlin("1.2")
@kotlin.internal.InlineOnly
public inline fun <@kotlin.internal.OnlyInputTypes K, @kotlin.internal.OnlyInputTypes V> MutableMap<out K, out V>.remove(key: K, value: V): Boolean
= (this as MutableMap<K, V>).remove(key, value)
public inline fun <@kotlin.internal.OnlyInputTypes K, @kotlin.internal.OnlyInputTypes V> MutableMap<out K, out V>.remove(key: K, value: V): Boolean =
(this as MutableMap<K, V>).remove(key, value)
@@ -27,7 +27,7 @@ internal open class JDK8PlatformImplementations : JDK7PlatformImplementations()
override fun getMatchResultNamedGroup(matchResult: MatchResult, name: String): MatchGroup? {
val matcher = matchResult as? Matcher ?: throw UnsupportedOperationException("Retrieving groups by name is not supported on this platform.")
val range = matcher.start(name)..matcher.end(name)-1
val range = matcher.start(name)..matcher.end(name) - 1
return if (range.start >= 0)
MatchGroup(matcher.group(name), range)
else
@@ -50,7 +50,8 @@ public fun DoubleStream.asSequence(): Sequence<Double> = Sequence { iterator() }
* Creates a sequential [Stream] instance that produces elements from the original sequence.
*/
@SinceKotlin("1.2")
public fun <T> Sequence<T>.asStream(): Stream<T> = StreamSupport.stream({ Spliterators.spliteratorUnknownSize(iterator(), Spliterator.ORDERED) }, Spliterator.ORDERED, false)
public fun <T> Sequence<T>.asStream(): Stream<T> =
StreamSupport.stream({ Spliterators.spliteratorUnknownSize(iterator(), Spliterator.ORDERED) }, Spliterator.ORDERED, false)
/**
* Returns a [List] containing all elements produced by this stream.
@@ -27,8 +27,8 @@ package kotlin.text
*/
@SinceKotlin("1.2")
public operator fun MatchGroupCollection.get(name: String): MatchGroup? {
val namedGroups = this as? MatchNamedGroupCollection ?:
throw UnsupportedOperationException("Retrieving groups by name is not supported on this platform.")
val namedGroups = this as? MatchNamedGroupCollection
?: throw UnsupportedOperationException("Retrieving groups by name is not supported on this platform.")
return namedGroups[name]
}
@@ -28,10 +28,10 @@ class CollectionTest {
@Test fun stream() {
assertEquals(
data.flatMap { it.asIterable() },
data.stream()
.flatMap { it.chars().boxed().map { it.toChar() } }
.collect(Collectors.toList()))
data.flatMap { it.asIterable() },
data.stream()
.flatMap { it.chars().boxed().map { it.toChar() } }
.collect(Collectors.toList()))
assertEquals(data, data.parallelStream().toList())
}
@@ -39,13 +39,13 @@ class StreamsTest {
fun<T> assertSequenceContent(expected: List<T>, actual: Sequence<T>) {
assertEquals(expected, actual.toList())
assertFailsWith<IllegalStateException> ("Second iteration fails") { actual.toList() }
assertFailsWith<IllegalStateException>("Second iteration fails") { actual.toList() }
}
assertSequenceContent(data.asList(), Stream.of(*data).asSequence())
assertSequenceContent(listOf(1, 2), IntStream.of(1, 2).asSequence())
assertSequenceContent(listOf(1L, 2L), LongStream.of(1L, 2L).asSequence())
assertSequenceContent(data.asList(), Stream.of(*data).asSequence())
assertSequenceContent(listOf(1, 2), IntStream.of(1, 2).asSequence())
assertSequenceContent(listOf(1L, 2L), LongStream.of(1L, 2L).asSequence())
assertSequenceContent(listOf(1.0, 2.0), DoubleStream.of(1.0, 2.0).asSequence())
}