diff --git a/libraries/stdlib/common/src/kotlin/CollectionsH.kt b/libraries/stdlib/common/src/kotlin/CollectionsH.kt index 32ca0b50926..017c6951c81 100644 --- a/libraries/stdlib/common/src/kotlin/CollectionsH.kt +++ b/libraries/stdlib/common/src/kotlin/CollectionsH.kt @@ -1,3 +1,19 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package kotlin.collections open header class ArrayList : MutableList { @@ -5,6 +21,9 @@ open header class ArrayList : MutableList { constructor() constructor(c: Collection) + fun trimToSize() + fun ensureCapacity(minCapacity: Int) + // From List override val size: Int override fun isEmpty(): Boolean @@ -34,8 +53,10 @@ open header class ArrayList : MutableList { } open header class HashMap : MutableMap { - constructor(initialCapacity: Int) constructor() + constructor(initialCapacity: Int) + constructor(initialCapacity: Int, loadFactor: Float) + constructor(original: Map) // From Map override val size: Int @@ -55,14 +76,17 @@ open header class HashMap : MutableMap { } open header class LinkedHashMap : HashMap { - constructor(initialCapacity: Int) constructor() - constructor(m: Map) + constructor(initialCapacity: Int) + constructor(initialCapacity: Int, loadFactor: Float) + constructor(original: Map) } open header class HashSet : MutableSet { constructor() constructor(initialCapacity: Int) + constructor(initialCapacity: Int, loadFactor: Float) + constructor(c: Collection) // From Set override val size: Int @@ -81,8 +105,9 @@ open header class HashSet : MutableSet { } open header class LinkedHashSet : HashSet { - constructor(initialCapacity: Int) constructor() + constructor(initialCapacity: Int) + constructor(initialCapacity: Int, loadFactor: Float) constructor(c: Collection) } @@ -122,3 +147,6 @@ header inline fun Collection.toTypedArray(): Array header fun > MutableList.sort(): Unit header fun MutableList.sortWith(comparator: Comparator): Unit + +// from Maps.kt +header operator fun MutableMap.set(key: K, value: V): Unit diff --git a/libraries/stdlib/common/src/kotlin/KotlinH.kt b/libraries/stdlib/common/src/kotlin/KotlinH.kt index 70ca61fd430..004b1bd7473 100644 --- a/libraries/stdlib/common/src/kotlin/KotlinH.kt +++ b/libraries/stdlib/common/src/kotlin/KotlinH.kt @@ -1,12 +1,32 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package kotlin import kotlin.annotation.AnnotationTarget.* open header class Error : Throwable { + constructor() constructor(message: String) } -open header class Exception : Throwable +open header class Exception : Throwable { + constructor() + constructor(message: String) +} open header class IllegalArgumentException : RuntimeException { constructor() @@ -14,10 +34,12 @@ open header class IllegalArgumentException : RuntimeException { } open header class IllegalStateException : RuntimeException { + constructor() constructor(message: String) } open header class IndexOutOfBoundsException : RuntimeException { + constructor() constructor(message: String) } @@ -32,6 +54,7 @@ open header class RuntimeException : Exception { } open header class UnsupportedOperationException : RuntimeException { + constructor() constructor(message: String) } @@ -40,6 +63,7 @@ header interface Comparator { fun compare(a: T, b: T): Int } +header inline fun Comparator(crossinline comparison: (T, T) -> Int): Comparator // From kotlin.kt @@ -57,6 +81,17 @@ internal header object Math { } + +// From numbers.kt + +header fun Double.isNaN(): Boolean +header fun Float.isNaN(): Boolean +header fun Double.isInfinite(): Boolean +header fun Float.isInfinite(): Boolean +header fun Double.isFinite(): Boolean +header fun Float.isFinite(): Boolean + + // From concurrent.kt @Target(PROPERTY, FIELD) @@ -65,3 +100,21 @@ header annotation class Volatile inline header fun synchronized(lock: Any, crossinline block: () -> R): R + + +// from lazy.kt + +public header fun lazy(initializer: () -> T): Lazy + +/** + * Creates a new instance of the [Lazy] that uses the specified initialization function [initializer]. + * + * The [mode] parameter is ignored. */ +public header fun lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy + +/** + * Creates a new instance of the [Lazy] that uses the specified initialization function [initializer]. + * + * The [lock] parameter is ignored. + */ +public header fun lazy(lock: Any?, initializer: () -> T): Lazy diff --git a/libraries/stdlib/common/src/kotlin/TextH.kt b/libraries/stdlib/common/src/kotlin/TextH.kt index 03d82e68b42..f43624318c1 100644 --- a/libraries/stdlib/common/src/kotlin/TextH.kt +++ b/libraries/stdlib/common/src/kotlin/TextH.kt @@ -1,3 +1,19 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package kotlin.text header interface Appendable { @@ -22,39 +38,38 @@ header class Regex { constructor(pattern: String, option: RegexOption) constructor(pattern: String, options: Set) + fun matchEntire(input: CharSequence): MatchResult? fun matches(input: CharSequence): Boolean fun containsMatchIn(input: CharSequence): Boolean fun replace(input: CharSequence, replacement: String): String fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String fun replaceFirst(input: CharSequence, replacement: String): String + + // TODO: requires optional parameters + fun find(input: CharSequence): MatchResult? + fun find(input: CharSequence, startIndex: Int): MatchResult? + fun findAll(input: CharSequence): Sequence + fun findAll(input: CharSequence, startIndex: Int): Sequence + fun split(input: CharSequence): List fun split(input: CharSequence, limit: Int): List + + header companion object { + fun fromLiteral(literal: String): Regex + fun escape(literal: String): String + fun escapeReplacement(literal: String): String + } } -header class MatchGroup - -header enum class RegexOption - -public header interface MatchGroupCollection : Collection { - public operator fun get(index: Int): MatchGroup? +header class MatchGroup { + val value: String } -public header interface MatchNamedGroupCollection : MatchGroupCollection { - public operator fun get(name: String): MatchGroup? +header enum class RegexOption { + IGNORE_CASE, + MULTILINE } -public header interface MatchResult { - public val range: IntRange - public val value: String - public val groups: MatchGroupCollection - public val groupValues: List - //public val destructured: Destructured - - public fun next(): MatchResult? - - -} - // From char.kt header fun Char.isWhitespace(): Boolean @@ -70,6 +85,30 @@ internal header fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int internal header fun String.nativeStartsWith(s: String, position: Int): Boolean internal header fun String.nativeEndsWith(s: String): Boolean + +public header fun String.substring(startIndex: Int): String +public header fun String.substring(startIndex: Int, endIndex: Int): String + + +public header inline fun String.toUpperCase(): String +public header inline fun String.toLowerCase(): String +public header inline fun String.capitalize(): String +public header inline fun String.decapitalize(): String +public header fun CharSequence.repeat(n: Int): String + + +// TOOD: requires optional parameters (and named!) +header fun String.replace(oldChar: Char, newChar: Char): String +header fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean): String +header fun String.replace(oldValue: String, newValue: String): String +header fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean): String +header fun String.replaceFirst(oldChar: Char, newChar: Char): String +header fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean): String +header fun String.replaceFirst(oldValue: String, newValue: String): String +header fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean): String +header fun String?.equals(other: String?): Boolean +header fun String?.equals(other: String?, ignoreCase: Boolean): Boolean + // From stringsCode.kt internal inline header fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int