More standard library documentation.

This commit is contained in:
Dmitry Jemerov
2015-03-05 19:07:02 +01:00
parent cb27797845
commit 32072d0a4f
44 changed files with 1702 additions and 136 deletions
+245
View File
@@ -6,198 +6,443 @@ package kotlin
//
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Byte.downTo(to: Byte): ByteProgression {
return ByteProgression(this, to, -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Byte.downTo(to: Char): CharProgression {
return CharProgression(this.toChar(), to, -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Byte.downTo(to: Short): ShortProgression {
return ShortProgression(this.toShort(), to, -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Byte.downTo(to: Int): IntProgression {
return IntProgression(this.toInt(), to, -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Byte.downTo(to: Long): LongProgression {
return LongProgression(this.toLong(), to, -1.toLong())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Byte.downTo(to: Float): FloatProgression {
return FloatProgression(this.toFloat(), to, -1.toFloat())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Byte.downTo(to: Double): DoubleProgression {
return DoubleProgression(this.toDouble(), to, -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Char.downTo(to: Byte): CharProgression {
return CharProgression(this, to.toChar(), -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Char.downTo(to: Char): CharProgression {
return CharProgression(this, to, -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Char.downTo(to: Short): ShortProgression {
return ShortProgression(this.toShort(), to, -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Char.downTo(to: Int): IntProgression {
return IntProgression(this.toInt(), to, -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Char.downTo(to: Long): LongProgression {
return LongProgression(this.toLong(), to, -1.toLong())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Char.downTo(to: Float): FloatProgression {
return FloatProgression(this.toFloat(), to, -1.toFloat())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Char.downTo(to: Double): DoubleProgression {
return DoubleProgression(this.toDouble(), to, -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Short.downTo(to: Byte): ShortProgression {
return ShortProgression(this, to.toShort(), -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Short.downTo(to: Char): ShortProgression {
return ShortProgression(this, to.toShort(), -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Short.downTo(to: Short): ShortProgression {
return ShortProgression(this, to, -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Short.downTo(to: Int): IntProgression {
return IntProgression(this.toInt(), to, -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Short.downTo(to: Long): LongProgression {
return LongProgression(this.toLong(), to, -1.toLong())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Short.downTo(to: Float): FloatProgression {
return FloatProgression(this.toFloat(), to, -1.toFloat())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Short.downTo(to: Double): DoubleProgression {
return DoubleProgression(this.toDouble(), to, -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Int.downTo(to: Byte): IntProgression {
return IntProgression(this, to.toInt(), -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Int.downTo(to: Char): IntProgression {
return IntProgression(this, to.toInt(), -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Int.downTo(to: Short): IntProgression {
return IntProgression(this, to.toInt(), -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Int.downTo(to: Int): IntProgression {
return IntProgression(this, to, -1)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Int.downTo(to: Long): LongProgression {
return LongProgression(this.toLong(), to, -1.toLong())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Int.downTo(to: Float): FloatProgression {
return FloatProgression(this.toFloat(), to, -1.toFloat())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Int.downTo(to: Double): DoubleProgression {
return DoubleProgression(this.toDouble(), to, -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Long.downTo(to: Byte): LongProgression {
return LongProgression(this, to.toLong(), -1.toLong())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Long.downTo(to: Char): LongProgression {
return LongProgression(this, to.toLong(), -1.toLong())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Long.downTo(to: Short): LongProgression {
return LongProgression(this, to.toLong(), -1.toLong())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Long.downTo(to: Int): LongProgression {
return LongProgression(this, to.toLong(), -1.toLong())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Long.downTo(to: Long): LongProgression {
return LongProgression(this, to, -1.toLong())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Long.downTo(to: Float): FloatProgression {
return FloatProgression(this.toFloat(), to, -1.toFloat())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Long.downTo(to: Double): DoubleProgression {
return DoubleProgression(this.toDouble(), to, -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Float.downTo(to: Byte): FloatProgression {
return FloatProgression(this, to.toFloat(), -1.toFloat())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Float.downTo(to: Char): FloatProgression {
return FloatProgression(this, to.toFloat(), -1.toFloat())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Float.downTo(to: Short): FloatProgression {
return FloatProgression(this, to.toFloat(), -1.toFloat())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Float.downTo(to: Int): FloatProgression {
return FloatProgression(this, to.toFloat(), -1.toFloat())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Float.downTo(to: Long): FloatProgression {
return FloatProgression(this, to.toFloat(), -1.toFloat())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Float.downTo(to: Float): FloatProgression {
return FloatProgression(this, to, -1.toFloat())
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Float.downTo(to: Double): DoubleProgression {
return DoubleProgression(this.toDouble(), to, -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Double.downTo(to: Byte): DoubleProgression {
return DoubleProgression(this, to.toDouble(), -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Double.downTo(to: Char): DoubleProgression {
return DoubleProgression(this, to.toDouble(), -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Double.downTo(to: Short): DoubleProgression {
return DoubleProgression(this, to.toDouble(), -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Double.downTo(to: Int): DoubleProgression {
return DoubleProgression(this, to.toDouble(), -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Double.downTo(to: Long): DoubleProgression {
return DoubleProgression(this, to.toDouble(), -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Double.downTo(to: Float): DoubleProgression {
return DoubleProgression(this, to.toDouble(), -1.0)
}
/**
* Returns a progression from this value down to the specified [to] value.
*
* The [to] value has to be less than this value.
*/
public fun Double.downTo(to: Double): DoubleProgression {
return DoubleProgression(this, to, -1.0)
}
+23 -23
View File
@@ -700,7 +700,7 @@ public fun String.first(): Char {
}
/**
* "Returns the first element matching the given [predicate].
* Returns the first element matching the given [predicate].
* @throws NoSuchElementException if no such element is found.
*/
public inline fun <T> Array<out T>.first(predicate: (T) -> Boolean): T {
@@ -709,7 +709,7 @@ public inline fun <T> Array<out T>.first(predicate: (T) -> Boolean): T {
}
/**
* "Returns the first element matching the given [predicate].
* Returns the first element matching the given [predicate].
* @throws NoSuchElementException if no such element is found.
*/
public inline fun BooleanArray.first(predicate: (Boolean) -> Boolean): Boolean {
@@ -718,7 +718,7 @@ public inline fun BooleanArray.first(predicate: (Boolean) -> Boolean): Boolean {
}
/**
* "Returns the first element matching the given [predicate].
* Returns the first element matching the given [predicate].
* @throws NoSuchElementException if no such element is found.
*/
public inline fun ByteArray.first(predicate: (Byte) -> Boolean): Byte {
@@ -727,7 +727,7 @@ public inline fun ByteArray.first(predicate: (Byte) -> Boolean): Byte {
}
/**
* "Returns the first element matching the given [predicate].
* Returns the first element matching the given [predicate].
* @throws NoSuchElementException if no such element is found.
*/
public inline fun CharArray.first(predicate: (Char) -> Boolean): Char {
@@ -736,7 +736,7 @@ public inline fun CharArray.first(predicate: (Char) -> Boolean): Char {
}
/**
* "Returns the first element matching the given [predicate].
* Returns the first element matching the given [predicate].
* @throws NoSuchElementException if no such element is found.
*/
public inline fun DoubleArray.first(predicate: (Double) -> Boolean): Double {
@@ -745,7 +745,7 @@ public inline fun DoubleArray.first(predicate: (Double) -> Boolean): Double {
}
/**
* "Returns the first element matching the given [predicate].
* Returns the first element matching the given [predicate].
* @throws NoSuchElementException if no such element is found.
*/
public inline fun FloatArray.first(predicate: (Float) -> Boolean): Float {
@@ -754,7 +754,7 @@ public inline fun FloatArray.first(predicate: (Float) -> Boolean): Float {
}
/**
* "Returns the first element matching the given [predicate].
* Returns the first element matching the given [predicate].
* @throws NoSuchElementException if no such element is found.
*/
public inline fun IntArray.first(predicate: (Int) -> Boolean): Int {
@@ -763,7 +763,7 @@ public inline fun IntArray.first(predicate: (Int) -> Boolean): Int {
}
/**
* "Returns the first element matching the given [predicate].
* Returns the first element matching the given [predicate].
* @throws NoSuchElementException if no such element is found.
*/
public inline fun LongArray.first(predicate: (Long) -> Boolean): Long {
@@ -772,7 +772,7 @@ public inline fun LongArray.first(predicate: (Long) -> Boolean): Long {
}
/**
* "Returns the first element matching the given [predicate].
* Returns the first element matching the given [predicate].
* @throws NoSuchElementException if no such element is found.
*/
public inline fun ShortArray.first(predicate: (Short) -> Boolean): Short {
@@ -781,7 +781,7 @@ public inline fun ShortArray.first(predicate: (Short) -> Boolean): Short {
}
/**
* "Returns the first element matching the given [predicate].
* Returns the first element matching the given [predicate].
* @throws NoSuchElementException if no such element is found.
*/
public inline fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T {
@@ -790,7 +790,7 @@ public inline fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T {
}
/**
* "Returns the first element matching the given [predicate].
* Returns the first element matching the given [predicate].
* @throws NoSuchElementException if no such element is found.
*/
public inline fun <T> Stream<T>.first(predicate: (T) -> Boolean): T {
@@ -925,7 +925,7 @@ public fun String.firstOrNull(): Char? {
}
/**
* Returns first element matching the given [predicate], or `null` if element was not found
* Returns the first element matching the given [predicate], or `null` if element was not found
*/
public inline fun <T> Array<out T>.firstOrNull(predicate: (T) -> Boolean): T? {
for (element in this) if (predicate(element)) return element
@@ -933,7 +933,7 @@ public inline fun <T> Array<out T>.firstOrNull(predicate: (T) -> Boolean): T? {
}
/**
* Returns first element matching the given [predicate], or `null` if element was not found
* Returns the first element matching the given [predicate], or `null` if element was not found
*/
public inline fun BooleanArray.firstOrNull(predicate: (Boolean) -> Boolean): Boolean? {
for (element in this) if (predicate(element)) return element
@@ -941,7 +941,7 @@ public inline fun BooleanArray.firstOrNull(predicate: (Boolean) -> Boolean): Boo
}
/**
* Returns first element matching the given [predicate], or `null` if element was not found
* Returns the first element matching the given [predicate], or `null` if element was not found
*/
public inline fun ByteArray.firstOrNull(predicate: (Byte) -> Boolean): Byte? {
for (element in this) if (predicate(element)) return element
@@ -949,7 +949,7 @@ public inline fun ByteArray.firstOrNull(predicate: (Byte) -> Boolean): Byte? {
}
/**
* Returns first element matching the given [predicate], or `null` if element was not found
* Returns the first element matching the given [predicate], or `null` if element was not found
*/
public inline fun CharArray.firstOrNull(predicate: (Char) -> Boolean): Char? {
for (element in this) if (predicate(element)) return element
@@ -957,7 +957,7 @@ public inline fun CharArray.firstOrNull(predicate: (Char) -> Boolean): Char? {
}
/**
* Returns first element matching the given [predicate], or `null` if element was not found
* Returns the first element matching the given [predicate], or `null` if element was not found
*/
public inline fun DoubleArray.firstOrNull(predicate: (Double) -> Boolean): Double? {
for (element in this) if (predicate(element)) return element
@@ -965,7 +965,7 @@ public inline fun DoubleArray.firstOrNull(predicate: (Double) -> Boolean): Doubl
}
/**
* Returns first element matching the given [predicate], or `null` if element was not found
* Returns the first element matching the given [predicate], or `null` if element was not found
*/
public inline fun FloatArray.firstOrNull(predicate: (Float) -> Boolean): Float? {
for (element in this) if (predicate(element)) return element
@@ -973,7 +973,7 @@ public inline fun FloatArray.firstOrNull(predicate: (Float) -> Boolean): Float?
}
/**
* Returns first element matching the given [predicate], or `null` if element was not found
* Returns the first element matching the given [predicate], or `null` if element was not found
*/
public inline fun IntArray.firstOrNull(predicate: (Int) -> Boolean): Int? {
for (element in this) if (predicate(element)) return element
@@ -981,7 +981,7 @@ public inline fun IntArray.firstOrNull(predicate: (Int) -> Boolean): Int? {
}
/**
* Returns first element matching the given [predicate], or `null` if element was not found
* Returns the first element matching the given [predicate], or `null` if element was not found
*/
public inline fun LongArray.firstOrNull(predicate: (Long) -> Boolean): Long? {
for (element in this) if (predicate(element)) return element
@@ -989,7 +989,7 @@ public inline fun LongArray.firstOrNull(predicate: (Long) -> Boolean): Long? {
}
/**
* Returns first element matching the given [predicate], or `null` if element was not found
* Returns the first element matching the given [predicate], or `null` if element was not found
*/
public inline fun ShortArray.firstOrNull(predicate: (Short) -> Boolean): Short? {
for (element in this) if (predicate(element)) return element
@@ -997,7 +997,7 @@ public inline fun ShortArray.firstOrNull(predicate: (Short) -> Boolean): Short?
}
/**
* Returns first element matching the given [predicate], or `null` if element was not found
* Returns the first element matching the given [predicate], or `null` if element was not found
*/
public inline fun <T> Iterable<T>.firstOrNull(predicate: (T) -> Boolean): T? {
for (element in this) if (predicate(element)) return element
@@ -1005,7 +1005,7 @@ public inline fun <T> Iterable<T>.firstOrNull(predicate: (T) -> Boolean): T? {
}
/**
* Returns first element matching the given [predicate], or `null` if element was not found
* Returns the first element matching the given [predicate], or `null` if element was not found
*/
public inline fun <T> Stream<T>.firstOrNull(predicate: (T) -> Boolean): T? {
for (element in this) if (predicate(element)) return element
@@ -1013,7 +1013,7 @@ public inline fun <T> Stream<T>.firstOrNull(predicate: (T) -> Boolean): T? {
}
/**
* Returns first character matching the given [predicate], or `null` if character was not found
* Returns the first character matching the given [predicate], or `null` if character was not found
*/
public inline fun String.firstOrNull(predicate: (Char) -> Boolean): Char? {
for (element in this) if (predicate(element)) return element