Fix compilation warnings with redundant inline annotation

This commit is contained in:
Mikhael Bogdanov
2013-11-29 11:43:45 +04:00
parent 16f554b6bf
commit 382b2d4a96
18 changed files with 173 additions and 173 deletions
+11 -11
View File
@@ -1,34 +1,34 @@
package kotlin
/** Returns true if the array is not empty */
public inline fun <T> Array<out T>.isNotEmpty() : Boolean = !this.isEmpty()
public fun <T> Array<out T>.isNotEmpty() : Boolean = !this.isEmpty()
/** Returns true if the array is empty */
public inline fun <T> Array<out T>.isEmpty() : Boolean = this.size == 0
public fun <T> Array<out T>.isEmpty() : Boolean = this.size == 0
public inline val BooleanArray.lastIndex : Int
public val BooleanArray.lastIndex : Int
get() = this.size - 1
public inline val ByteArray.lastIndex : Int
public val ByteArray.lastIndex : Int
get() = this.size - 1
public inline val ShortArray.lastIndex : Int
public val ShortArray.lastIndex : Int
get() = this.size - 1
public inline val IntArray.lastIndex : Int
public val IntArray.lastIndex : Int
get() = this.size - 1
public inline val LongArray.lastIndex : Int
public val LongArray.lastIndex : Int
get() = this.size - 1
public inline val FloatArray.lastIndex : Int
public val FloatArray.lastIndex : Int
get() = this.size - 1
public inline val DoubleArray.lastIndex : Int
public val DoubleArray.lastIndex : Int
get() = this.size - 1
public inline val CharArray.lastIndex : Int
public val CharArray.lastIndex : Int
get() = this.size - 1
public inline val <T: Any?> Array<out T>.lastIndex : Int
public val <T: Any?> Array<out T>.lastIndex : Int
get() = this.size - 1
+60 -60
View File
@@ -6,40 +6,40 @@ import java.util.Arrays
import jet.runtime.Intrinsic
// Array "constructor"
[Intrinsic("kotlin.arrays.array")] public inline fun <reified T> array(vararg t : T) : Array<T> = t
[Intrinsic("kotlin.arrays.array")] public fun <reified T> array(vararg t : T) : Array<T> = t
// "constructors" for primitive types array
[Intrinsic("kotlin.arrays.array")] public inline fun doubleArray(vararg content : Double) : DoubleArray = content
[Intrinsic("kotlin.arrays.array")] public fun doubleArray(vararg content : Double) : DoubleArray = content
[Intrinsic("kotlin.arrays.array")] public inline fun floatArray(vararg content : Float) : FloatArray = content
[Intrinsic("kotlin.arrays.array")] public fun floatArray(vararg content : Float) : FloatArray = content
[Intrinsic("kotlin.arrays.array")] public inline fun longArray(vararg content : Long) : LongArray = content
[Intrinsic("kotlin.arrays.array")] public fun longArray(vararg content : Long) : LongArray = content
[Intrinsic("kotlin.arrays.array")] public inline fun intArray(vararg content : Int) : IntArray = content
[Intrinsic("kotlin.arrays.array")] public fun intArray(vararg content : Int) : IntArray = content
[Intrinsic("kotlin.arrays.array")] public inline fun charArray(vararg content : Char) : CharArray = content
[Intrinsic("kotlin.arrays.array")] public fun charArray(vararg content : Char) : CharArray = content
[Intrinsic("kotlin.arrays.array")] public inline fun shortArray(vararg content : Short) : ShortArray = content
[Intrinsic("kotlin.arrays.array")] public fun shortArray(vararg content : Short) : ShortArray = content
[Intrinsic("kotlin.arrays.array")] public inline fun byteArray(vararg content : Byte) : ByteArray = content
[Intrinsic("kotlin.arrays.array")] public fun byteArray(vararg content : Byte) : ByteArray = content
[Intrinsic("kotlin.arrays.array")] public inline fun booleanArray(vararg content : Boolean) : BooleanArray = content
[Intrinsic("kotlin.arrays.array")] public fun booleanArray(vararg content : Boolean) : BooleanArray = content
public inline fun ByteArray.binarySearch(key: Byte) : Int = Arrays.binarySearch(this, key)
public inline fun ShortArray.binarySearch(key: Short) : Int = Arrays.binarySearch(this, key)
public inline fun IntArray.binarySearch(key: Int) : Int = Arrays.binarySearch(this, key)
public inline fun LongArray.binarySearch(key: Long) : Int = Arrays.binarySearch(this, key)
public inline fun FloatArray.binarySearch(key: Float) : Int = Arrays.binarySearch(this, key)
public inline fun DoubleArray.binarySearch(key: Double) : Int = Arrays.binarySearch(this, key)
public inline fun CharArray.binarySearch(key: Char) : Int = Arrays.binarySearch(this, key)
public fun ByteArray.binarySearch(key: Byte) : Int = Arrays.binarySearch(this, key)
public fun ShortArray.binarySearch(key: Short) : Int = Arrays.binarySearch(this, key)
public fun IntArray.binarySearch(key: Int) : Int = Arrays.binarySearch(this, key)
public fun LongArray.binarySearch(key: Long) : Int = Arrays.binarySearch(this, key)
public fun FloatArray.binarySearch(key: Float) : Int = Arrays.binarySearch(this, key)
public fun DoubleArray.binarySearch(key: Double) : Int = Arrays.binarySearch(this, key)
public fun CharArray.binarySearch(key: Char) : Int = Arrays.binarySearch(this, key)
public inline fun ByteArray.binarySearch(fromIndex: Int, toIndex: Int, key: Byte) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public inline fun ShortArray.binarySearch(fromIndex: Int, toIndex: Int, key: Short) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public inline fun IntArray.binarySearch(fromIndex: Int, toIndex: Int, key: Int) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public inline fun LongArray.binarySearch(fromIndex: Int, toIndex: Int, key: Long) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public inline fun FloatArray.binarySearch(fromIndex: Int, toIndex: Int, key: Float) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public inline fun DoubleArray.binarySearch(fromIndex: Int, toIndex: Int, key: Double) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public inline fun CharArray.binarySearch(fromIndex: Int, toIndex: Int, key: Char) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public fun ByteArray.binarySearch(fromIndex: Int, toIndex: Int, key: Byte) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public fun ShortArray.binarySearch(fromIndex: Int, toIndex: Int, key: Short) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public fun IntArray.binarySearch(fromIndex: Int, toIndex: Int, key: Int) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public fun LongArray.binarySearch(fromIndex: Int, toIndex: Int, key: Long) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public fun FloatArray.binarySearch(fromIndex: Int, toIndex: Int, key: Float) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public fun DoubleArray.binarySearch(fromIndex: Int, toIndex: Int, key: Double) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
public fun CharArray.binarySearch(fromIndex: Int, toIndex: Int, key: Char) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key)
/*
public inline fun <T> Array<T>.binarySearch(key: T, comparator: public fun(T,T):Int) = Arrays.binarySearch(this, key, object: java.util.Comparator<T> {
@@ -48,32 +48,32 @@ public inline fun <T> Array<T>.binarySearch(key: T, comparator: public fun(T,T):
public override fun equals(obj: Any?) = obj.identityEquals(this)
})
*/
public inline fun BooleanArray.fill(value: Boolean) : Unit = Arrays.fill(this, value)
public inline fun ByteArray.fill(value: Byte) : Unit = Arrays.fill(this, value)
public inline fun ShortArray.fill(value: Short) : Unit = Arrays.fill(this, value)
public inline fun IntArray.fill(value: Int) : Unit = Arrays.fill(this, value)
public inline fun LongArray.fill(value: Long) : Unit = Arrays.fill(this, value)
public inline fun FloatArray.fill(value: Float) : Unit = Arrays.fill(this, value)
public inline fun DoubleArray.fill(value: Double) : Unit = Arrays.fill(this, value)
public inline fun CharArray.fill(value: Char) : Unit = Arrays.fill(this, value)
public fun BooleanArray.fill(value: Boolean) : Unit = Arrays.fill(this, value)
public fun ByteArray.fill(value: Byte) : Unit = Arrays.fill(this, value)
public fun ShortArray.fill(value: Short) : Unit = Arrays.fill(this, value)
public fun IntArray.fill(value: Int) : Unit = Arrays.fill(this, value)
public fun LongArray.fill(value: Long) : Unit = Arrays.fill(this, value)
public fun FloatArray.fill(value: Float) : Unit = Arrays.fill(this, value)
public fun DoubleArray.fill(value: Double) : Unit = Arrays.fill(this, value)
public fun CharArray.fill(value: Char) : Unit = Arrays.fill(this, value)
public inline fun <T: Any?> Array<T>.fill(value: T) : Unit = Arrays.fill(this, value)
public fun <T: Any?> Array<T>.fill(value: T) : Unit = Arrays.fill(this, value)
public inline fun ByteArray.sort() : Unit = Arrays.sort(this)
public inline fun ShortArray.sort() : Unit = Arrays.sort(this)
public inline fun IntArray.sort() : Unit = Arrays.sort(this)
public inline fun LongArray.sort() : Unit = Arrays.sort(this)
public inline fun FloatArray.sort() : Unit = Arrays.sort(this)
public inline fun DoubleArray.sort() : Unit = Arrays.sort(this)
public inline fun CharArray.sort() : Unit = Arrays.sort(this)
public fun ByteArray.sort() : Unit = Arrays.sort(this)
public fun ShortArray.sort() : Unit = Arrays.sort(this)
public fun IntArray.sort() : Unit = Arrays.sort(this)
public fun LongArray.sort() : Unit = Arrays.sort(this)
public fun FloatArray.sort() : Unit = Arrays.sort(this)
public fun DoubleArray.sort() : Unit = Arrays.sort(this)
public fun CharArray.sort() : Unit = Arrays.sort(this)
public inline fun ByteArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public inline fun ShortArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public inline fun IntArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public inline fun LongArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public inline fun FloatArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public inline fun DoubleArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public inline fun CharArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public fun ByteArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public fun ShortArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public fun IntArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public fun LongArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public fun FloatArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public fun DoubleArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public fun CharArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
public fun BooleanArray.copyOf(newLength: Int = this.size) : BooleanArray = Arrays.copyOf(this, newLength)
public fun ByteArray.copyOf(newLength: Int = this.size) : ByteArray = Arrays.copyOf(this, newLength)
@@ -87,27 +87,27 @@ public fun CharArray.copyOf(newLength: Int = this.size) : CharArray = Arra
// TODO: resuling array may contain nulls even if T is non-nullable
public fun <T> Array<T>.copyOf(newLength: Int = this.size) : Array<T> = Arrays.copyOf(this, newLength) as Array<T>
public inline fun BooleanArray.copyOfRange(from: Int, to: Int) : BooleanArray = Arrays.copyOfRange(this, from, to)
public inline fun ByteArray.copyOfRange(from: Int, to: Int) : ByteArray = Arrays.copyOfRange(this, from, to)
public inline fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray = Arrays.copyOfRange(this, from, to)
public inline fun IntArray.copyOfRange(from: Int, to: Int) : IntArray = Arrays.copyOfRange(this, from, to)
public inline fun LongArray.copyOfRange(from: Int, to: Int) : LongArray = Arrays.copyOfRange(this, from, to)
public inline fun FloatArray.copyOfRange(from: Int, to: Int) : FloatArray = Arrays.copyOfRange(this, from, to)
public inline fun DoubleArray.copyOfRange(from: Int, to: Int) : DoubleArray = Arrays.copyOfRange(this, from, to)
public inline fun CharArray.copyOfRange(from: Int, to: Int) : CharArray = Arrays.copyOfRange(this, from, to)
public fun BooleanArray.copyOfRange(from: Int, to: Int) : BooleanArray = Arrays.copyOfRange(this, from, to)
public fun ByteArray.copyOfRange(from: Int, to: Int) : ByteArray = Arrays.copyOfRange(this, from, to)
public fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray = Arrays.copyOfRange(this, from, to)
public fun IntArray.copyOfRange(from: Int, to: Int) : IntArray = Arrays.copyOfRange(this, from, to)
public fun LongArray.copyOfRange(from: Int, to: Int) : LongArray = Arrays.copyOfRange(this, from, to)
public fun FloatArray.copyOfRange(from: Int, to: Int) : FloatArray = Arrays.copyOfRange(this, from, to)
public fun DoubleArray.copyOfRange(from: Int, to: Int) : DoubleArray = Arrays.copyOfRange(this, from, to)
public fun CharArray.copyOfRange(from: Int, to: Int) : CharArray = Arrays.copyOfRange(this, from, to)
// TODO: resuling array may contain nulls even if T is non-nullable
public inline fun <T> Array<T>.copyOfRange(from: Int, to: Int) : Array<T> = Arrays.copyOfRange(this, from, to) as Array<T>
public fun <T> Array<T>.copyOfRange(from: Int, to: Int) : Array<T> = Arrays.copyOfRange(this, from, to) as Array<T>
public inline val ByteArray.inputStream : ByteArrayInputStream
public val ByteArray.inputStream : ByteArrayInputStream
get() = ByteArrayInputStream(this)
public inline fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length)
public fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length)
public inline fun ByteArray.toString(encoding: String): String = String(this, encoding)
public inline fun ByteArray.toString(): String = String(this)
public fun ByteArray.toString(encoding: String): String = String(this, encoding)
public fun ByteArray.toString(): String = String(this)
public inline fun ByteArray.toString(encoding: Charset) : String = String(this, encoding)
public fun ByteArray.toString(encoding: Charset) : String = String(this, encoding)
[Intrinsic("kotlin.collections.copyToArray")] public fun <reified T> Collection<T>.copyToArray(): Array<T> =
throw UnsupportedOperationException()
+12 -12
View File
@@ -1,36 +1,36 @@
package kotlin
public inline fun Char.isDefined(): Boolean = Character.isDefined(this)
public fun Char.isDefined(): Boolean = Character.isDefined(this)
public inline fun Char.isDigit(): Boolean = Character.isDigit(this)
public fun Char.isDigit(): Boolean = Character.isDigit(this)
public inline fun Char.isHighSurrogate(): Boolean = Character.isHighSurrogate(this)
public fun Char.isHighSurrogate(): Boolean = Character.isHighSurrogate(this)
public inline fun Char.isIdentifierIgnorable(): Boolean = Character.isIdentifierIgnorable(this)
public fun Char.isIdentifierIgnorable(): Boolean = Character.isIdentifierIgnorable(this)
public inline fun Char.isISOControl(): Boolean = Character.isISOControl(this)
public fun Char.isISOControl(): Boolean = Character.isISOControl(this)
public inline fun Char.isJavaIdentifierPart(): Boolean = Character.isJavaIdentifierPart(this)
public fun Char.isJavaIdentifierPart(): Boolean = Character.isJavaIdentifierPart(this)
public inline fun Char.isJavaIdentifierStart(): Boolean = Character.isJavaIdentifierStart(this)
public fun Char.isJavaIdentifierStart(): Boolean = Character.isJavaIdentifierStart(this)
public inline fun Char.isJavaLetter(): Boolean = Character.isJavaLetter(this)
public fun Char.isJavaLetter(): Boolean = Character.isJavaLetter(this)
public inline fun Char.isJavaLetterOrDigit(): Boolean = Character.isJavaLetterOrDigit(this)
public fun Char.isJavaLetterOrDigit(): Boolean = Character.isJavaLetterOrDigit(this)
/**
* Returns true if the character is whitespace
*
* @includeFunctionBody ../../test/StringTest.kt count
*/
public inline fun Char.isWhitespace(): Boolean = Character.isWhitespace(this)
public fun Char.isWhitespace(): Boolean = Character.isWhitespace(this)
/**
* Returns true if this character is upper case
*/
public inline fun Char.isUpperCase(): Boolean = Character.isUpperCase(this)
public fun Char.isUpperCase(): Boolean = Character.isUpperCase(this)
/**
* Returns true if this character is lower case
*/
public inline fun Char.isLowerCase(): Boolean = Character.isLowerCase(this)
public fun Char.isLowerCase(): Boolean = Character.isLowerCase(this)
@@ -34,7 +34,7 @@ public fun <T> countTo(n: Int): (T) -> Boolean {
*
* Will throw an exception if there are no elements
*/
public inline fun <T> Iterable<T>.first() : T {
public fun <T> Iterable<T>.first() : T {
if (this is List<T>) {
return this.first()
}
@@ -64,13 +64,13 @@ public fun <T> Iterable<T>.containsItem(item : T) : Boolean {
}
public inline fun <T: Comparable<T>> Iterable<T>.sort() : List<T> {
public fun <T: Comparable<T>> Iterable<T>.sort() : List<T> {
val list = toCollection(ArrayList<T>())
java.util.Collections.sort(list)
return list
}
public inline fun <T> Iterable<T>.sort(comparator: java.util.Comparator<T>) : List<T> {
public fun <T> Iterable<T>.sort(comparator: java.util.Comparator<T>) : List<T> {
val list = toCollection(ArrayList<T>())
java.util.Collections.sort(list, comparator)
return list
+1 -1
View File
@@ -21,7 +21,7 @@ public /*inline*/ fun <T: Any> iterate(initialValue: T, nextFunction: (T) -> T?)
/**
* Returns an iterator whose values are pairs composed of values produced by given pair of iterators
*/
public inline fun <T, S> Iterator<T>.zip(iterator: Iterator<S>): Iterator<Pair<T, S>> = PairIterator(this, iterator)
public fun <T, S> Iterator<T>.zip(iterator: Iterator<S>): Iterator<Pair<T, S>> = PairIterator(this, iterator)
/**
* Returns an iterator shifted to right by the given number of elements
+1 -1
View File
@@ -15,7 +15,7 @@ import jet.runtime.Intrinsic
* A helper method for calling hashCode() on Kotlin objects
* TODO remove when Any supports equals() and hashCode()
*/
[Intrinsic("kotlin.hashCode")] public inline fun Any.hashCode(): Int = (this as java.lang.Object).hashCode()
[Intrinsic("kotlin.hashCode")] public fun Any.hashCode(): Int = (this as java.lang.Object).hashCode()
/**
* A helper method for calling toString() on Kotlin primitives
+5 -5
View File
@@ -17,27 +17,27 @@ public val Int.indices: IntRange
get() = 0..this-1
/** Returns true if the collection is not empty */
public inline fun <T> Collection<T>.isNotEmpty() : Boolean = !this.isEmpty()
public fun <T> Collection<T>.isNotEmpty() : Boolean = !this.isEmpty()
/** Returns true if this collection is not empty */
val Collection<*>.notEmpty : Boolean
get() = isNotEmpty()
/** Returns the Collection if its not null otherwise it returns the empty list */
public inline fun <T> Collection<T>?.orEmpty() : Collection<T>
public fun <T> Collection<T>?.orEmpty() : Collection<T>
= if (this != null) this else Collections.emptyList<T>() as Collection<T>
/** TODO these functions don't work when they generate the Array<T> versions when they are in JLIterables */
public inline fun <T: Comparable<T>> Iterable<T>.toSortedList() : List<T> = toCollection(ArrayList<T>()).sort()
public fun <T: Comparable<T>> Iterable<T>.toSortedList() : List<T> = toCollection(ArrayList<T>()).sort()
public inline fun <T: Comparable<T>> Iterable<T>.toSortedList(comparator: java.util.Comparator<T>) : List<T> = toList().sort(comparator)
public fun <T: Comparable<T>> Iterable<T>.toSortedList(comparator: java.util.Comparator<T>) : List<T> = toList().sort(comparator)
// List APIs
/** Returns the List if its not null otherwise returns the empty list */
public inline fun <T> List<T>?.orEmpty() : List<T>
public fun <T> List<T>?.orEmpty() : List<T>
= if (this != null) this else Collections.emptyList<T>() as List<T>
/**
+5 -5
View File
@@ -3,21 +3,21 @@ package kotlin
/**
* Get the first element in the list or throws [[EmptyIterableException]] if list is empty.
*/
public inline fun <T> List<T>.first() : T {
public fun <T> List<T>.first() : T {
return if (size() > 0) get(0) else throw EmptyIterableException(this)
}
/**
* Get the first element in the list or *null* if list is empty.
*/
public inline fun <T:Any> List<T>.firstOrNull() : T? {
public fun <T:Any> List<T>.firstOrNull() : T? {
return if (size() > 0) get(0) else null
}
/**
* Get the last element in the list or throws [[EmptyIterableException]] if list is empty.
*/
public inline fun <T> List<T>.last() : T {
public fun <T> List<T>.last() : T {
val s = size()
return if (s > 0) get(s - 1) else throw EmptyIterableException(this)
}
@@ -25,7 +25,7 @@ public inline fun <T> List<T>.last() : T {
/**
* Get the last element in the list or *null* if list is empty.
*/
public inline fun <T:Any> List<T>.lastOrNull() : T? {
public fun <T:Any> List<T>.lastOrNull() : T? {
val s = size()
return if (s > 0) get(s - 1) else null
}
@@ -71,7 +71,7 @@ public inline fun <T> List<T>.reduceRight(operation: (T, T) -> T) : T {
/**
* Returns a original Iterable containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements
*/
public inline fun <T:Any> List<T?>.requireNoNulls() : List<T> {
public fun <T:Any> List<T?>.requireNoNulls() : List<T> {
for (element in this) {
if (element == null) {
throw IllegalArgumentException("null element found in $this")
+4 -4
View File
@@ -17,7 +17,7 @@ get() = isEmpty()
public fun <K, V> MutableMap<K, V>.set(key : K, value : V) : V? = this.put(key, value)
/** Returns the [[Map]] if its not null otherwise it returns the empty [[Map]] */
public inline fun <K,V> Map<K,V>?.orEmpty() : Map<K,V>
public fun <K,V> Map<K,V>?.orEmpty() : Map<K,V>
= if (this != null) this else Collections.emptyMap<K,V>() as Map<K,V>
@@ -73,7 +73,7 @@ public inline fun <K,V> MutableMap<K,V>.getOrPut(key: K, defaultValue: ()-> V) :
*
* @includeFunctionBody ../../test/MapTest.kt iterateWithProperties
*/
public inline fun <K,V> Map<K,V>.iterator(): Iterator<Map.Entry<K,V>> {
public fun <K,V> Map<K,V>.iterator(): Iterator<Map.Entry<K,V>> {
val entrySet = this.entrySet()
return entrySet.iterator()
}
@@ -102,7 +102,7 @@ public inline fun <K,V,R,C: MutableMap<K,R>> Map<K,V>.mapValuesTo(result: C, tra
/**
* Puts all the entries into this [[MutableMap]] with the first value in the pair being the key and the second the value
*/
public inline fun <K,V> MutableMap<K,V>.putAll(vararg values: Pair<K, V>): Unit {
public fun <K,V> MutableMap<K,V>.putAll(vararg values: Pair<K, V>): Unit {
for (v in values) {
put(v.first, v.second)
}
@@ -111,7 +111,7 @@ public inline fun <K,V> MutableMap<K,V>.putAll(vararg values: Pair<K, V>): Unit
/**
* Copies the entries in this [[Map]] to the given mutable *map*
*/
public inline fun <K,V> Map<K,V>.toMap(map: MutableMap<K,V>): Map<K,V> {
public fun <K,V> Map<K,V>.toMap(map: MutableMap<K,V>): Map<K,V> {
map.putAll(this)
return map
}
+3 -3
View File
@@ -11,14 +11,14 @@ import java.util.Properties
/**
* Converts this [[Map]] to a [[LinkedHashMap]] so future insertion orders are maintained
*/
public inline fun <K,V> Map<K,V>.toLinkedMap(): LinkedHashMap<K,V> = toMap<K,V>(LinkedHashMap(size)) as LinkedHashMap<K,V>
public fun <K,V> Map<K,V>.toLinkedMap(): LinkedHashMap<K,V> = toMap<K,V>(LinkedHashMap(size)) as LinkedHashMap<K,V>
/**
* Converts this [[Map]] to a [[SortedMap]] so iteration order will be in key order
*
* @includeFunctionBody ../../test/MapTest.kt toSortedMap
*/
public inline fun <K,V> Map<K,V>.toSortedMap(): SortedMap<K,V> = toMap<K,V>(TreeMap()) as SortedMap<K,V>
public fun <K,V> Map<K,V>.toSortedMap(): SortedMap<K,V> = toMap<K,V>(TreeMap()) as SortedMap<K,V>
/**
* Converts this [[Map]] to a [[SortedMap]] using the given *comparator* so that iteration order will be in the order
@@ -26,7 +26,7 @@ public inline fun <K,V> Map<K,V>.toSortedMap(): SortedMap<K,V> = toMap<K,V>(Tree
*
* @includeFunctionBody ../../test/MapTest.kt toSortedMapWithComparator
*/
public inline fun <K,V> Map<K,V>.toSortedMap(comparator: Comparator<K>): SortedMap<K,V> = toMap<K,V>(TreeMap(comparator)) as SortedMap<K,V>
public fun <K,V> Map<K,V>.toSortedMap(comparator: Comparator<K>): SortedMap<K,V> = toMap<K,V>(TreeMap(comparator)) as SortedMap<K,V>
/**
+2 -2
View File
@@ -6,7 +6,7 @@ import java.util.Comparator
* Helper method for implementing [[Comparable]] methods using a list of functions
* to calculate the values to compare
*/
inline fun <T : Any> compareBy(a: T?, b: T?, vararg functions: T.() -> Comparable<*>?): Int {
fun <T : Any> compareBy(a: T?, b: T?, vararg functions: T.() -> Comparable<*>?): Int {
require(functions.size > 0)
if (a === b) return 0
if (a == null) return - 1
@@ -25,7 +25,7 @@ inline fun <T : Any> compareBy(a: T?, b: T?, vararg functions: T.() -> Comparabl
* they are compared via [[#equals()]] and if they are not the same then
* the [[#hashCode()]] method is used as the difference
*/
public inline fun <T : Comparable<*>> compareValues(a: T?, b: T?): Int {
public fun <T : Comparable<*>> compareValues(a: T?, b: T?): Int {
if (a === b) return 0
if (a == null) return - 1
if (b == null) return 1
+3 -3
View File
@@ -31,12 +31,12 @@ public fun <T,U: Collection<in T>> Iterator<T>.toCollection(container: U) : U {
/**
Add iterated elements to java.util.ArrayList
*/
public inline fun <T> Iterator<T>.toArrayList() : ArrayList<T> = toCollection(ArrayList<T>())
public fun <T> Iterator<T>.toArrayList() : ArrayList<T> = toCollection(ArrayList<T>())
/**
Add iterated elements to java.util.HashSet
*/
public inline fun <T> Iterator<T>.toHashSet() : HashSet<T> = toCollection(HashSet<T>())
public fun <T> Iterator<T>.toHashSet() : HashSet<T> = toCollection(HashSet<T>())
/**
@@ -45,7 +45,7 @@ public inline fun <T> Iterator<T>.toHashSet() : HashSet<T> = toCollection(HashSe
* @includeFunctionBody ../../test/MapTest.kt createUsingTo
*/
public inline fun <A,B> A.to(that: B): Pair<A, B> = Pair(this, that)
public fun <A,B> A.to(that: B): Pair<A, B> = Pair(this, that)
/**
Run function f
+4 -4
View File
@@ -14,18 +14,18 @@ import java.util.concurrent.Callable
/**
* Add iterated elements to a [[LinkedHashSet]] to preserve insertion order
*/
public inline fun <T> Iterator<T>.toLinkedSet() : LinkedHashSet<T> = toCollection(LinkedHashSet<T>())
public fun <T> Iterator<T>.toLinkedSet() : LinkedHashSet<T> = toCollection(LinkedHashSet<T>())
/**
* Add iterated elements to [[SortedSet]] with the given *comparator* to ensure iteration is in the order of the given comparator
*/
public inline fun <T> Iterator<T>.toSortedSet(comparator: Comparator<T>) : SortedSet<T> = toCollection(TreeSet<T>(comparator))
public fun <T> Iterator<T>.toSortedSet(comparator: Comparator<T>) : SortedSet<T> = toCollection(TreeSet<T>(comparator))
/**
* Allows a stack trace to be printed from Kotlin's [[Throwable]]
*/
public inline fun Throwable.printStackTrace(writer: PrintWriter): Unit {
public fun Throwable.printStackTrace(writer: PrintWriter): Unit {
val jlt = this as java.lang.Throwable
jlt.printStackTrace(writer)
}
@@ -33,7 +33,7 @@ public inline fun Throwable.printStackTrace(writer: PrintWriter): Unit {
/**
* Allows a stack trace to be printed from Kotlin's [[Throwable]]
*/
public inline fun Throwable.printStackTrace(stream: PrintStream): Unit {
public fun Throwable.printStackTrace(stream: PrintStream): Unit {
val jlt = this as java.lang.Throwable
jlt.printStackTrace(stream)
}
+6 -6
View File
@@ -6,13 +6,13 @@ import java.util.HashSet
import java.util.LinkedList
/** Returns the string with leading and trailing text matching the given string removed */
public inline fun String.trim(text: String) : String = trimLeading(text).trimTrailing(text)
public fun String.trim(text: String) : String = trimLeading(text).trimTrailing(text)
/** Returns the string with the prefix and postfix text trimmed */
public inline fun String.trim(prefix: String, postfix: String) : String = trimLeading(prefix).trimTrailing(postfix)
public fun String.trim(prefix: String, postfix: String) : String = trimLeading(prefix).trimTrailing(postfix)
/** Returns the string with the leading prefix of this string removed */
public inline fun String.trimLeading(prefix: String): String {
public fun String.trimLeading(prefix: String): String {
var answer = this
if (answer.startsWith(prefix)) {
answer = answer.substring(prefix.length())
@@ -21,7 +21,7 @@ public inline fun String.trimLeading(prefix: String): String {
}
/** Returns the string with the trailing postfix of this string removed */
public inline fun String.trimTrailing(postfix: String): String {
public fun String.trimTrailing(postfix: String): String {
var answer = this
if (answer.endsWith(postfix)) {
answer = answer.substring(0, length() - postfix.length())
@@ -30,7 +30,7 @@ public inline fun String.trimTrailing(postfix: String): String {
}
/** Returns true if the string is not null and not empty */
public inline fun String?.isNotEmpty() : Boolean = this != null && this.length() > 0
public fun String?.isNotEmpty() : Boolean = this != null && this.length() > 0
/**
Iterator for characters of given CharSequence
@@ -44,7 +44,7 @@ public fun CharSequence.iterator() : CharIterator = object: jet.CharIterator() {
}
/** Returns the string if it is not null or the empty string if its null */
public inline fun String?.orEmpty(): String = this ?: ""
public fun String?.orEmpty(): String = this ?: ""
// "Extension functions" for CharSequence
+16 -16
View File
@@ -35,7 +35,7 @@ public inline fun String.getBytes() : ByteArray = (this as java.lang.String).get
public inline fun String.toCharArray() : CharArray = (this as java.lang.String).toCharArray()
public inline fun String.toCharList(): List<Char> = toCharArray().toList()
public fun String.toCharList(): List<Char> = toCharArray().toList()
public inline fun String.format(vararg args : Any?) : String = java.lang.String.format(this, *args)
@@ -136,11 +136,11 @@ public inline fun String.toUpperCase(locale : java.util.Locale) : String = (this
public inline fun CharSequence.charAt(index : Int) : Char = (this as java.lang.CharSequence).charAt(index)
public inline fun CharSequence.get(index : Int) : Char = charAt(index)
public fun CharSequence.get(index : Int) : Char = charAt(index)
public inline fun CharSequence.subSequence(start : Int, end : Int) : CharSequence? = (this as java.lang.CharSequence).subSequence(start, end)
public inline fun CharSequence.get(start : Int, end : Int) : CharSequence? = subSequence(start, end)
public fun CharSequence.get(start : Int, end : Int) : CharSequence? = subSequence(start, end)
public inline fun CharSequence.toString() : String? = (this as java.lang.CharSequence).toString()
@@ -178,7 +178,7 @@ get() = length()
*
* @includeFunctionBody ../../test/StringTest.kt capitalize
*/
public inline fun String.capitalize(): String {
public fun String.capitalize(): String {
return if (isNotEmpty() && charAt(0).isLowerCase()) substring(0, 1).toUpperCase() + substring(1) else this
}
@@ -187,7 +187,7 @@ public inline fun String.capitalize(): String {
*
* @includeFunctionBody ../../test/StringTest.kt decapitalize
*/
public inline fun String.decapitalize(): String {
public fun String.decapitalize(): String {
return if (isNotEmpty() && charAt(0).isUpperCase()) substring(0, 1).toLowerCase() + substring(1) else this
}
@@ -196,7 +196,7 @@ public inline fun String.decapitalize(): String {
* When n < 0, IllegalArgumentException is thrown.
* @includeFunctionBody ../../test/StringTest.kt repeat
*/
public inline fun String.repeat(n: Int): String {
public fun String.repeat(n: Int): String {
require(n >= 0, { "Cannot repeat string $n times" })
var sb = StringBuilder()
@@ -246,7 +246,7 @@ public inline fun <T: Appendable> String.filterNotTo(result: T, predicate: (Char
*
* @includeFunctionBody ../../test/StringTest.kt reverse
*/
public inline fun String.reverse(): String = StringBuilder(this).reverse().toString()
public fun String.reverse(): String = StringBuilder(this).reverse().toString()
/**
* Performs the given *operation* on each character
@@ -477,7 +477,7 @@ public inline fun String.dropWhile(predicate: (Char) -> Boolean): String = dropW
*
* @includeFunctionBody ../../test/StringTest.kt drop
*/
public inline fun String.drop(n: Int): String = dropWhile(countTo(n))
public fun String.drop(n: Int): String = dropWhile(countTo(n))
/**
* Returns an Appendable containing the first characters that satisfy the given *predicate*
@@ -501,28 +501,28 @@ public inline fun String.takeWhile(predicate: (Char) -> Boolean): String = takeW
*
* @includeFunctionBody ../../test/StringTest.kt take
*/
public inline fun String.take(n: Int): String = takeWhile(countTo(n))
public fun String.take(n: Int): String = takeWhile(countTo(n))
/** Copies all characters into the given collection */
public inline fun <C: MutableCollection<in Char>> String.toCollection(result: C): C {
public fun <C: MutableCollection<in Char>> String.toCollection(result: C): C {
for (c in this) result.add(c)
return result
}
/** Copies all characters into a [[LinkedList]] */
public inline fun String.toLinkedList(): LinkedList<Char> = toCollection(LinkedList<Char>())
public fun String.toLinkedList(): LinkedList<Char> = toCollection(LinkedList<Char>())
/** Copies all characters into a [[List]] */
public inline fun String.toList(): List<Char> = toCollection(ArrayList<Char>(this.length()))
public fun String.toList(): List<Char> = toCollection(ArrayList<Char>(this.length()))
/** Copies all characters into a [[Collection] */
public inline fun String.toCollection(): Collection<Char> = toCollection(ArrayList<Char>(this.length()))
public fun String.toCollection(): Collection<Char> = toCollection(ArrayList<Char>(this.length()))
/** Copies all characters into a [[Set]] */
public inline fun String.toSet(): Set<Char> = toCollection(HashSet<Char>())
public fun String.toSet(): Set<Char> = toCollection(HashSet<Char>())
/** Returns a new String containing the everything but the leading whitespace characters */
public inline fun String.trimLeading(): String {
public fun String.trimLeading(): String {
var count = 0
while ((count < this.length) && (this[count] <= ' ')) {
@@ -532,7 +532,7 @@ public inline fun String.trimLeading(): String {
}
/** Returns a new String containing the everything but the trailing whitespace characters */
public inline fun String.trimTrailing(): String {
public fun String.trimTrailing(): String {
var count = this.length
while (count > 0 && this[count - 1] <= ' ') {
+13 -13
View File
@@ -77,17 +77,17 @@ fun Element.hasClass(cssClass: String): Boolean {
/** Returns the children of the element as a list */
inline fun Element?.children(): List<Node> {
fun Element?.children(): List<Node> {
return this?.childNodes.toList()
}
/** Returns the child elements of this element */
inline fun Element?.childElements(): List<Element> {
fun Element?.childElements(): List<Element> {
return children().filter<Node>{ it.nodeType == Node.ELEMENT_NODE }.map { it as Element }
}
/** Returns the child elements of this element with the given name */
inline fun Element?.childElements(name: String): List<Element> {
fun Element?.childElements(name: String): List<Element> {
return children().filter<Node>{ it.nodeType == Node.ELEMENT_NODE && it.nodeName == name }.map { it as Element }
}
@@ -101,26 +101,26 @@ get() = this?.getElementsByTagName("*").toElementList()
/** Returns all the descendant elements given the local element name */
inline fun Element?.elements(localName: String): List<Element> {
fun Element?.elements(localName: String): List<Element> {
return this?.getElementsByTagName(localName).toElementList()
}
/** Returns all the descendant elements given the local element name */
inline fun Document?.elements(localName: String): List<Element> {
fun Document?.elements(localName: String): List<Element> {
return this?.getElementsByTagName(localName).toElementList()
}
/** Returns all the descendant elements given the namespace URI and local element name */
inline fun Element?.elements(namespaceUri: String, localName: String): List<Element> {
fun Element?.elements(namespaceUri: String, localName: String): List<Element> {
return this?.getElementsByTagNameNS(namespaceUri, localName).toElementList()
}
/** Returns all the descendant elements given the namespace URI and local element name */
inline fun Document?.elements(namespaceUri: String, localName: String): List<Element> {
fun Document?.elements(namespaceUri: String, localName: String): List<Element> {
return this?.getElementsByTagNameNS(namespaceUri, localName).toElementList()
}
inline fun NodeList?.toList(): List<Node> {
fun NodeList?.toList(): List<Node> {
return if (this == null) {
// TODO the following is easier to convert to JS
emptyNodeList()
@@ -130,7 +130,7 @@ inline fun NodeList?.toList(): List<Node> {
}
}
inline fun NodeList?.toElementList(): List<Element> {
fun NodeList?.toElementList(): List<Element> {
return if (this == null) {
// TODO the following is easier to convert to JS
//emptyElementList()
@@ -297,7 +297,7 @@ fun Node.isText(): Boolean {
}
/** Returns the attribute value or empty string if its not present */
inline fun Element.attribute(name: String): String {
fun Element.attribute(name: String): String {
return this.getAttribute(name) ?: ""
}
@@ -342,16 +342,16 @@ public fun nodesToXmlString(nodes: Iterable<Node>, xmlDeclaration: Boolean = fal
// Syntax sugar
inline fun Node.plus(child: Node?): Node {
fun Node.plus(child: Node?): Node {
if (child != null) {
this.appendChild(child)
}
return this
}
inline fun Element.plus(text: String?): Element = this.addText(text)
fun Element.plus(text: String?): Element = this.addText(text)
inline fun Element.plusAssign(text: String?): Element = this.addText(text)
fun Element.plusAssign(text: String?): Element = this.addText(text)
// Builder
+1 -1
View File
@@ -84,7 +84,7 @@ public fun File.relativePath(descendant: File): String {
/**
* Creates a new [[FileReader]] for this file
*/
public inline fun File.reader(): FileReader = FileReader(this)
public fun File.reader(): FileReader = FileReader(this)
/**
* Reads the entire content of the file as bytes
+23 -23
View File
@@ -17,88 +17,88 @@ public val defaultCharset: Charset = Charset.forName("UTF-8")!!
/** Prints the given message to [[System.out]] */
public inline fun print(message : Any?) {
public fun print(message : Any?) {
System.out.print(message)
}
/** Prints the given message to [[System.out]] */
public inline fun print(message : Int) {
public fun print(message : Int) {
System.out.print(message)
}
/** Prints the given message to [[System.out]] */
public inline fun print(message : Long) {
public fun print(message : Long) {
System.out.print(message)
}
/** Prints the given message to [[System.out]] */
public inline fun print(message : Byte) {
public fun print(message : Byte) {
System.out.print(message)
}
/** Prints the given message to [[System.out]] */
public inline fun print(message : Short) {
public fun print(message : Short) {
System.out.print(message)
}
/** Prints the given message to [[System.out]] */
public inline fun print(message : Char) {
public fun print(message : Char) {
System.out.print(message)
}
/** Prints the given message to [[System.out]] */
public inline fun print(message : Boolean) {
public fun print(message : Boolean) {
System.out.print(message)
}
/** Prints the given message to [[System.out]] */
public inline fun print(message : Float) {
public fun print(message : Float) {
System.out.print(message)
}
/** Prints the given message to [[System.out]] */
public inline fun print(message : Double) {
public fun print(message : Double) {
System.out.print(message)
}
/** Prints the given message to [[System.out]] */
public inline fun print(message : CharArray) {
public fun print(message : CharArray) {
System.out.print(message)
}
/** Prints the given message and newline to [[System.out]] */
public inline fun println(message : Any?) {
public fun println(message : Any?) {
System.out.println(message)
}
/** Prints the given message and newline to [[System.out]] */
public inline fun println(message : Int) {
public fun println(message : Int) {
System.out.println(message)
}
/** Prints the given message and newline to [[System.out]] */
public inline fun println(message : Long) {
public fun println(message : Long) {
System.out.println(message)
}
/** Prints the given message and newline to [[System.out]] */
public inline fun println(message : Byte) {
public fun println(message : Byte) {
System.out.println(message)
}
/** Prints the given message and newline to [[System.out]] */
public inline fun println(message : Short) {
public fun println(message : Short) {
System.out.println(message)
}
/** Prints the given message and newline to [[System.out]] */
public inline fun println(message : Char) {
public fun println(message : Char) {
System.out.println(message)
}
/** Prints the given message and newline to [[System.out]] */
public inline fun println(message : Boolean) {
public fun println(message : Boolean) {
System.out.println(message)
}
/** Prints the given message and newline to [[System.out]] */
public inline fun println(message : Float) {
public fun println(message : Float) {
System.out.println(message)
}
/** Prints the given message and newline to [[System.out]] */
public inline fun println(message : Double) {
public fun println(message : Double) {
System.out.println(message)
}
/** Prints the given message and newline to [[System.out]] */
public inline fun println(message : CharArray) {
public fun println(message : CharArray) {
System.out.println(message)
}
/** Prints a newline t[[System.out]] */
public inline fun println() {
public fun println() {
System.out.println()
}
@@ -186,9 +186,9 @@ else
public fun InputStream.reader(encoding: Charset = defaultCharset) : InputStreamReader = InputStreamReader(this, encoding)
public inline fun InputStream.reader(encoding: String) : InputStreamReader = InputStreamReader(this, encoding)
public fun InputStream.reader(encoding: String) : InputStreamReader = InputStreamReader(this, encoding)
public inline fun InputStream.reader(encoding: CharsetDecoder) : InputStreamReader = InputStreamReader(this, encoding)
public fun InputStream.reader(encoding: CharsetDecoder) : InputStreamReader = InputStreamReader(this, encoding)
public fun OutputStream.buffered(bufferSize: Int = defaultBufferSize) : BufferedOutputStream