Mark builtins and stblib functions with 'operator'

This commit is contained in:
Yan Zhulanow
2015-09-18 21:38:35 +03:00
parent ce4bcbba6d
commit 1139a8dd0e
39 changed files with 609 additions and 579 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ public open class Any {
* Note that the `==` operator in Kotlin code is translated into a call to [equals] when objects on both sides of the
* operator are not null.
*/
public open fun equals(other: Any?): Boolean
public open operator fun equals(other: Any?): Boolean
/**
* Returns a hash code value for the object. The general contract of hashCode is:
+3 -3
View File
@@ -31,7 +31,7 @@ public class Array<reified T> private (): Cloneable {
* value = arr[index]
* ```
*/
public fun get(index: Int): T
public operator fun get(index: Int): T
/**
* Sets the array element at the specified [index] to the specified [value]. This method can
@@ -40,7 +40,7 @@ public class Array<reified T> private (): Cloneable {
* arr[index] = value
* ```
*/
public fun set(index: Int, value: T): Unit
public operator fun set(index: Int, value: T): Unit
/**
* Returns the number of elements in the array.
@@ -50,7 +50,7 @@ public class Array<reified T> private (): Cloneable {
/**
* Creates an iterator for iterating over the elements of the array.
*/
public fun iterator(): Iterator<T>
public operator fun iterator(): Iterator<T>
/**
* Creates a shallow copy of the array.
+24 -24
View File
@@ -24,15 +24,15 @@ package kotlin
*/
public class ByteArray(size: Int) : Cloneable {
/** Returns the array element at the given [index]. This method can be called using the index operator. */
public fun get(index: Int): Byte
public operator fun get(index: Int): Byte
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
public fun set(index: Int, value: Byte): Unit
public operator fun set(index: Int, value: Byte): Unit
/** Returns the number of elements in the array. */
public fun size(): Int
/** Creates an iterator over the elements of the array. */
public fun iterator(): ByteIterator
public operator fun iterator(): ByteIterator
public override fun clone(): ByteArray
}
@@ -43,15 +43,15 @@ public class ByteArray(size: Int) : Cloneable {
*/
public class CharArray(size: Int) : Cloneable {
/** Returns the array element at the given [index]. This method can be called using the index operator. */
public fun get(index: Int): Char
public operator fun get(index: Int): Char
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
public fun set(index: Int, value: Char): Unit
public operator fun set(index: Int, value: Char): Unit
/** Returns the number of elements in the array. */
public fun size(): Int
/** Creates an iterator over the elements of the array. */
public fun iterator(): CharIterator
public operator fun iterator(): CharIterator
public override fun clone(): CharArray
}
@@ -62,15 +62,15 @@ public class CharArray(size: Int) : Cloneable {
*/
public class ShortArray(size: Int) : Cloneable {
/** Returns the array element at the given [index]. This method can be called using the index operator. */
public fun get(index: Int): Short
public operator fun get(index: Int): Short
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
public fun set(index: Int, value: Short): Unit
public operator fun set(index: Int, value: Short): Unit
/** Returns the number of elements in the array. */
public fun size(): Int
/** Creates an iterator over the elements of the array. */
public fun iterator(): ShortIterator
public operator fun iterator(): ShortIterator
public override fun clone(): ShortArray
}
@@ -81,15 +81,15 @@ public class ShortArray(size: Int) : Cloneable {
*/
public class IntArray(size: Int) : Cloneable {
/** Returns the array element at the given [index]. This method can be called using the index operator. */
public fun get(index: Int): Int
public operator fun get(index: Int): Int
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
public fun set(index: Int, value: Int): Unit
public operator fun set(index: Int, value: Int): Unit
/** Returns the number of elements in the array. */
public fun size(): Int
/** Creates an iterator over the elements of the array. */
public fun iterator(): IntIterator
public operator fun iterator(): IntIterator
public override fun clone(): IntArray
}
@@ -100,15 +100,15 @@ public class IntArray(size: Int) : Cloneable {
*/
public class LongArray(size: Int) : Cloneable {
/** Returns the array element at the given [index]. This method can be called using the index operator. */
public fun get(index: Int): Long
public operator fun get(index: Int): Long
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
public fun set(index: Int, value: Long): Unit
public operator fun set(index: Int, value: Long): Unit
/** Returns the number of elements in the array. */
public fun size(): Int
/** Creates an iterator over the elements of the array. */
public fun iterator(): LongIterator
public operator fun iterator(): LongIterator
public override fun clone(): LongArray
}
@@ -119,15 +119,15 @@ public class LongArray(size: Int) : Cloneable {
*/
public class FloatArray(size: Int) : Cloneable {
/** Returns the array element at the given [index]. This method can be called using the index operator. */
public fun get(index: Int): Float
public operator fun get(index: Int): Float
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
public fun set(index: Int, value: Float): Unit
public operator fun set(index: Int, value: Float): Unit
/** Returns the number of elements in the array. */
public fun size(): Int
/** Creates an iterator over the elements of the array. */
public fun iterator(): FloatIterator
public operator fun iterator(): FloatIterator
public override fun clone(): FloatArray
}
@@ -138,15 +138,15 @@ public class FloatArray(size: Int) : Cloneable {
*/
public class DoubleArray(size: Int) : Cloneable {
/** Returns the array element at the given [index]. This method can be called using the index operator. */
public fun get(index: Int): Double
public operator fun get(index: Int): Double
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
public fun set(index: Int, value: Double): Unit
public operator fun set(index: Int, value: Double): Unit
/** Returns the number of elements in the array. */
public fun size(): Int
/** Creates an iterator over the elements of the array. */
public fun iterator(): DoubleIterator
public operator fun iterator(): DoubleIterator
public override fun clone(): DoubleArray
}
@@ -157,15 +157,15 @@ public class DoubleArray(size: Int) : Cloneable {
*/
public class BooleanArray(size: Int) : Cloneable {
/** Returns the array element at the given [index]. This method can be called using the index operator. */
public fun get(index: Int): Boolean
public operator fun get(index: Int): Boolean
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
public fun set(index: Int, value: Boolean): Unit
public operator fun set(index: Int, value: Boolean): Unit
/** Returns the number of elements in the array. */
public fun size(): Int
/** Creates an iterator over the elements of the array. */
public fun iterator(): BooleanIterator
public operator fun iterator(): BooleanIterator
public override fun clone(): BooleanArray
}
+1 -1
View File
@@ -24,7 +24,7 @@ public class Boolean private () : Comparable<Boolean> {
/**
* Returns the inverse of this boolean.
*/
public fun not(): Boolean
public operator fun not(): Boolean
/**
* Performs a logical `and` operation between this Boolean and the [other] one.
+6 -6
View File
@@ -31,20 +31,20 @@ public class Char private () : Comparable<Char> {
public override fun compareTo(other: Char): Int
/** Adds the other Int value to this value resulting a Char. */
public fun plus(other: Int): Char
public operator fun plus(other: Int): Char
/** Subtracts the other Char value from this value resulting an Int. */
public fun minus(other: Char): Int
public operator fun minus(other: Char): Int
/** Subtracts the other Int value from this value resulting a Char. */
public fun minus(other: Int): Char
public operator fun minus(other: Int): Char
/** Increments this value. */
public fun inc(): Char
public operator fun inc(): Char
/** Decrements this value. */
public fun dec(): Char
public operator fun dec(): Char
/** Creates a range from this value to the specified [other] value. */
public fun rangeTo(other: Char): CharRange
public operator fun rangeTo(other: Char): CharRange
/** Returns the value of this character as a `Byte`. */
public override fun toByte(): Byte
+5 -5
View File
@@ -25,7 +25,7 @@ public interface Iterable<out T> {
/**
* Returns an iterator over the elements of this object.
*/
public fun iterator(): Iterator<T>
public operator fun iterator(): Iterator<T>
}
/**
@@ -59,7 +59,7 @@ public interface Collection<out E> : Iterable<E> {
/**
* Checks if the specified element is contained in this collection.
*/
public fun contains(o: Any?): Boolean
public operator fun contains(o: Any?): Boolean
override fun iterator(): Iterator<E>
// Bulk Operations
@@ -140,7 +140,7 @@ public interface List<out E> : Collection<E> {
/**
* Returns the element at the specified index in the list.
*/
public fun get(index: Int): E
public operator fun get(index: Int): E
// Search Operations
/**
@@ -202,7 +202,7 @@ public interface MutableList<E> : List<E>, MutableCollection<E> {
*
* @return the element previously at the specified position.
*/
public fun set(index: Int, element: E): E
public operator fun set(index: Int, element: E): E
/**
* Inserts an element into the list at the specified [index].
@@ -294,7 +294,7 @@ public interface Map<K, out V> {
/**
* Returns the value corresponding to the given [key], or `null` if such a key is not present in the map.
*/
public fun get(key: Any?): V?
public operator fun get(key: Any?): V?
// Views
/**
+1 -1
View File
@@ -25,5 +25,5 @@ public interface Comparable<in T> {
* to the specified [other] object, a negative number if it's less than [other], or a positive number
* if it's greater than [other].
*/
public fun compareTo(other: T): Int
public operator fun compareTo(other: T): Int
}
+2 -2
View File
@@ -24,12 +24,12 @@ public interface Iterator<out T> {
/**
* Returns the next element in the iteration.
*/
public fun next(): T
public operator fun next(): T
/**
* Returns `true` if the iteration has more elements.
*/
public fun hasNext(): Boolean
public operator fun hasNext(): Boolean
}
/**
+1 -1
View File
@@ -32,7 +32,7 @@ public fun Any?.toString(): String
* Concatenates this string with the string representation of the given [other] object. If either the receiver
* or the [other] object are null, they are represented as the string "null".
*/
public fun String?.plus(other: Any?): String
public operator fun String?.plus(other: Any?): String
/**
* Returns an array of objects of the given type with the given [size], initialized with null values.
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -26,12 +26,12 @@ public class String : Comparable<String>, CharSequence {
/**
* Returns a string obtained by concatenating this string with the string representation of the given [other] object.
*/
public fun plus(other: Any?): String
public operator fun plus(other: Any?): String
/**
* Returns the character at the specified [index].
*/
public fun get(index: Int): Char
public operator fun get(index: Int): Char
public override fun length(): Int
+1 -1
View File
@@ -34,7 +34,7 @@ public interface Range<T : Comparable<T>> {
/**
* Checks if the specified value belongs to the range.
*/
public fun contains(item: T): Boolean
public operator fun contains(item: T): Boolean
/**
* Checks if the range is empty.
@@ -21,115 +21,115 @@ package kotlin.jvm.functions
/** A function that takes 0 arguments. */
public interface Function0<out R> : Function<R> {
/** Invokes the function. */
public fun invoke(): R
public operator fun invoke(): R
}
/** A function that takes 1 argument. */
public interface Function1<in P1, out R> : Function<R> {
/** Invokes the function with the specified argument. */
public fun invoke(p1: P1): R
public operator fun invoke(p1: P1): R
}
/** A function that takes 2 arguments. */
public interface Function2<in P1, in P2, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2): R
public operator fun invoke(p1: P1, p2: P2): R
}
/** A function that takes 3 arguments. */
public interface Function3<in P1, in P2, in P3, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3): R
public operator fun invoke(p1: P1, p2: P2, p3: P3): R
}
/** A function that takes 4 arguments. */
public interface Function4<in P1, in P2, in P3, in P4, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R
}
/** A function that takes 5 arguments. */
public interface Function5<in P1, in P2, in P3, in P4, in P5, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R
}
/** A function that takes 6 arguments. */
public interface Function6<in P1, in P2, in P3, in P4, in P5, in P6, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R
}
/** A function that takes 7 arguments. */
public interface Function7<in P1, in P2, in P3, in P4, in P5, in P6, in P7, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R
}
/** A function that takes 8 arguments. */
public interface Function8<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R
}
/** A function that takes 9 arguments. */
public interface Function9<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R
}
/** A function that takes 10 arguments. */
public interface Function10<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R
}
/** A function that takes 11 arguments. */
public interface Function11<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R
}
/** A function that takes 12 arguments. */
public interface Function12<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R
}
/** A function that takes 13 arguments. */
public interface Function13<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R
}
/** A function that takes 14 arguments. */
public interface Function14<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R
}
/** A function that takes 15 arguments. */
public interface Function15<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R
}
/** A function that takes 16 arguments. */
public interface Function16<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R
}
/** A function that takes 17 arguments. */
public interface Function17<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R
}
/** A function that takes 18 arguments. */
public interface Function18<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R
}
/** A function that takes 19 arguments. */
public interface Function19<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R
}
/** A function that takes 20 arguments. */
public interface Function20<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R
}
/** A function that takes 21 arguments. */
public interface Function21<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R
}
/** A function that takes 22 arguments. */
public interface Function22<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, in P22, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R
}
@@ -66,11 +66,11 @@ private class ArrayBooleanIterator(private val array: BooleanArray) : BooleanIte
override fun nextBoolean() = array[index++]
}
public fun iterator(array: ByteArray): ByteIterator = ArrayByteIterator(array)
public fun iterator(array: CharArray): CharIterator = ArrayCharIterator(array)
public fun iterator(array: ShortArray): ShortIterator = ArrayShortIterator(array)
public fun iterator(array: IntArray): IntIterator = ArrayIntIterator(array)
public fun iterator(array: LongArray): LongIterator = ArrayLongIterator(array)
public fun iterator(array: FloatArray): FloatIterator = ArrayFloatIterator(array)
public fun iterator(array: DoubleArray): DoubleIterator = ArrayDoubleIterator(array)
public fun iterator(array: BooleanArray): BooleanIterator = ArrayBooleanIterator(array)
public operator fun iterator(array: ByteArray): ByteIterator = ArrayByteIterator(array)
public operator fun iterator(array: CharArray): CharIterator = ArrayCharIterator(array)
public operator fun iterator(array: ShortArray): ShortIterator = ArrayShortIterator(array)
public operator fun iterator(array: IntArray): IntIterator = ArrayIntIterator(array)
public operator fun iterator(array: LongArray): LongIterator = ArrayLongIterator(array)
public operator fun iterator(array: FloatArray): FloatIterator = ArrayFloatIterator(array)
public operator fun iterator(array: DoubleArray): DoubleIterator = ArrayDoubleIterator(array)
public operator fun iterator(array: BooleanArray): BooleanIterator = ArrayBooleanIterator(array)
@@ -35,7 +35,7 @@ class GenerateArrayIterators(out: PrintWriter) : BuiltInsSourceGenerator(out) {
}
for (kind in PrimitiveType.values()) {
val s = kind.capitalized
out.println("public fun iterator(array: ${s}Array): ${s}Iterator = Array${s}Iterator(array)")
out.println("public operator fun iterator(array: ${s}Array): ${s}Iterator = Array${s}Iterator(array)")
}
}
}
@@ -34,15 +34,15 @@ class GenerateArrays(out: PrintWriter) : BuiltInsSourceGenerator(out) {
out.println(" */")
out.println("public class ${s}Array(size: Int) : Cloneable {")
out.println(" /** Returns the array element at the given [index]. This method can be called using the index operator. */")
out.println(" public fun get(index: Int): $s")
out.println(" public operator fun get(index: Int): $s")
out.println(" /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */")
out.println(" public fun set(index: Int, value: $s): Unit")
out.println(" public operator fun set(index: Int, value: $s): Unit")
out.println()
out.println(" /** Returns the number of elements in the array. */")
out.println(" public fun size(): Int")
out.println()
out.println(" /** Creates an iterator over the elements of the array. */")
out.println(" public fun iterator(): ${s}Iterator")
out.println(" public operator fun iterator(): ${s}Iterator")
out.println()
out.println(" public override fun clone(): ${s}Array")
out.println("}")
@@ -77,7 +77,7 @@ class GenerateFunctions(out: PrintWriter) : BuiltInsSourceGenerator(out) {
val suffix = if (i == 1) "" else "s"
out.println(" /** Invokes the function with the specified argument${suffix}. */")
}
out.print(" public fun invoke(")
out.print(" public operator fun invoke(")
for (j in 1..i) {
out.print("p$j: P$j")
if (j < i) {
@@ -98,7 +98,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
out.println(" */")
out.print(" public ")
if (otherKind == thisKind) out.print("override ")
out.println("fun compareTo(other: ${otherKind.capitalized}): Int")
out.println("operator fun compareTo(other: ${otherKind.capitalized}): Int")
}
out.println()
}
@@ -113,7 +113,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
for (otherKind in PrimitiveType.onlyNumeric) {
val returnType = getOperatorReturnType(thisKind, otherKind)
out.println(" /** $doc */")
out.println(" public fun $name(other: ${otherKind.capitalized}): $returnType")
out.println(" public operator fun $name(other: ${otherKind.capitalized}): $returnType")
}
out.println()
}
@@ -122,7 +122,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
for (otherKind in PrimitiveType.onlyNumeric) {
val returnType = if (otherKind.ordinal() > thisKind.ordinal()) otherKind else thisKind
out.println(" /** Creates a range from this value to the specified [other] value. */")
out.println(" public fun rangeTo(other: ${otherKind.capitalized}): ${returnType.capitalized}Range")
out.println(" public operator fun rangeTo(other: ${otherKind.capitalized}): ${returnType.capitalized}Range")
}
out.println()
@@ -133,7 +133,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
val returnType = if (kind in listOf(PrimitiveType.SHORT, PrimitiveType.BYTE, PrimitiveType.CHAR) &&
name in listOf("plus", "minus")) "Int" else kind.capitalized
out.println(" /** $doc */")
out.println(" public fun $name(): $returnType")
out.println(" public operator fun $name(): $returnType")
}
out.println()
}
+61 -61
View File
@@ -14,7 +14,7 @@ import java.util.Collections // TODO: it's temporary while we have java.util.Col
* Returns 1st *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.component1(): T {
public inline operator fun <T> Array<out T>.component1(): T {
return get(0)
}
@@ -22,7 +22,7 @@ public inline fun <T> Array<out T>.component1(): T {
* Returns 1st *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun BooleanArray.component1(): Boolean {
public inline operator fun BooleanArray.component1(): Boolean {
return get(0)
}
@@ -30,7 +30,7 @@ public inline fun BooleanArray.component1(): Boolean {
* Returns 1st *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun ByteArray.component1(): Byte {
public inline operator fun ByteArray.component1(): Byte {
return get(0)
}
@@ -38,7 +38,7 @@ public inline fun ByteArray.component1(): Byte {
* Returns 1st *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun CharArray.component1(): Char {
public inline operator fun CharArray.component1(): Char {
return get(0)
}
@@ -46,7 +46,7 @@ public inline fun CharArray.component1(): Char {
* Returns 1st *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun DoubleArray.component1(): Double {
public inline operator fun DoubleArray.component1(): Double {
return get(0)
}
@@ -54,7 +54,7 @@ public inline fun DoubleArray.component1(): Double {
* Returns 1st *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun FloatArray.component1(): Float {
public inline operator fun FloatArray.component1(): Float {
return get(0)
}
@@ -62,7 +62,7 @@ public inline fun FloatArray.component1(): Float {
* Returns 1st *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun IntArray.component1(): Int {
public inline operator fun IntArray.component1(): Int {
return get(0)
}
@@ -70,7 +70,7 @@ public inline fun IntArray.component1(): Int {
* Returns 1st *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun LongArray.component1(): Long {
public inline operator fun LongArray.component1(): Long {
return get(0)
}
@@ -78,7 +78,7 @@ public inline fun LongArray.component1(): Long {
* Returns 1st *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun ShortArray.component1(): Short {
public inline operator fun ShortArray.component1(): Short {
return get(0)
}
@@ -86,7 +86,7 @@ public inline fun ShortArray.component1(): Short {
* Returns 1st *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> List<T>.component1(): T {
public inline operator fun <T> List<T>.component1(): T {
return get(0)
}
@@ -94,7 +94,7 @@ public inline fun <T> List<T>.component1(): T {
* Returns 2nd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.component2(): T {
public inline operator fun <T> Array<out T>.component2(): T {
return get(1)
}
@@ -102,7 +102,7 @@ public inline fun <T> Array<out T>.component2(): T {
* Returns 2nd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun BooleanArray.component2(): Boolean {
public inline operator fun BooleanArray.component2(): Boolean {
return get(1)
}
@@ -110,7 +110,7 @@ public inline fun BooleanArray.component2(): Boolean {
* Returns 2nd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun ByteArray.component2(): Byte {
public inline operator fun ByteArray.component2(): Byte {
return get(1)
}
@@ -118,7 +118,7 @@ public inline fun ByteArray.component2(): Byte {
* Returns 2nd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun CharArray.component2(): Char {
public inline operator fun CharArray.component2(): Char {
return get(1)
}
@@ -126,7 +126,7 @@ public inline fun CharArray.component2(): Char {
* Returns 2nd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun DoubleArray.component2(): Double {
public inline operator fun DoubleArray.component2(): Double {
return get(1)
}
@@ -134,7 +134,7 @@ public inline fun DoubleArray.component2(): Double {
* Returns 2nd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun FloatArray.component2(): Float {
public inline operator fun FloatArray.component2(): Float {
return get(1)
}
@@ -142,7 +142,7 @@ public inline fun FloatArray.component2(): Float {
* Returns 2nd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun IntArray.component2(): Int {
public inline operator fun IntArray.component2(): Int {
return get(1)
}
@@ -150,7 +150,7 @@ public inline fun IntArray.component2(): Int {
* Returns 2nd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun LongArray.component2(): Long {
public inline operator fun LongArray.component2(): Long {
return get(1)
}
@@ -158,7 +158,7 @@ public inline fun LongArray.component2(): Long {
* Returns 2nd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun ShortArray.component2(): Short {
public inline operator fun ShortArray.component2(): Short {
return get(1)
}
@@ -166,7 +166,7 @@ public inline fun ShortArray.component2(): Short {
* Returns 2nd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> List<T>.component2(): T {
public inline operator fun <T> List<T>.component2(): T {
return get(1)
}
@@ -174,7 +174,7 @@ public inline fun <T> List<T>.component2(): T {
* Returns 3rd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.component3(): T {
public inline operator fun <T> Array<out T>.component3(): T {
return get(2)
}
@@ -182,7 +182,7 @@ public inline fun <T> Array<out T>.component3(): T {
* Returns 3rd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun BooleanArray.component3(): Boolean {
public inline operator fun BooleanArray.component3(): Boolean {
return get(2)
}
@@ -190,7 +190,7 @@ public inline fun BooleanArray.component3(): Boolean {
* Returns 3rd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun ByteArray.component3(): Byte {
public inline operator fun ByteArray.component3(): Byte {
return get(2)
}
@@ -198,7 +198,7 @@ public inline fun ByteArray.component3(): Byte {
* Returns 3rd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun CharArray.component3(): Char {
public inline operator fun CharArray.component3(): Char {
return get(2)
}
@@ -206,7 +206,7 @@ public inline fun CharArray.component3(): Char {
* Returns 3rd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun DoubleArray.component3(): Double {
public inline operator fun DoubleArray.component3(): Double {
return get(2)
}
@@ -214,7 +214,7 @@ public inline fun DoubleArray.component3(): Double {
* Returns 3rd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun FloatArray.component3(): Float {
public inline operator fun FloatArray.component3(): Float {
return get(2)
}
@@ -222,7 +222,7 @@ public inline fun FloatArray.component3(): Float {
* Returns 3rd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun IntArray.component3(): Int {
public inline operator fun IntArray.component3(): Int {
return get(2)
}
@@ -230,7 +230,7 @@ public inline fun IntArray.component3(): Int {
* Returns 3rd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun LongArray.component3(): Long {
public inline operator fun LongArray.component3(): Long {
return get(2)
}
@@ -238,7 +238,7 @@ public inline fun LongArray.component3(): Long {
* Returns 3rd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun ShortArray.component3(): Short {
public inline operator fun ShortArray.component3(): Short {
return get(2)
}
@@ -246,7 +246,7 @@ public inline fun ShortArray.component3(): Short {
* Returns 3rd *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> List<T>.component3(): T {
public inline operator fun <T> List<T>.component3(): T {
return get(2)
}
@@ -254,7 +254,7 @@ public inline fun <T> List<T>.component3(): T {
* Returns 4th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.component4(): T {
public inline operator fun <T> Array<out T>.component4(): T {
return get(3)
}
@@ -262,7 +262,7 @@ public inline fun <T> Array<out T>.component4(): T {
* Returns 4th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun BooleanArray.component4(): Boolean {
public inline operator fun BooleanArray.component4(): Boolean {
return get(3)
}
@@ -270,7 +270,7 @@ public inline fun BooleanArray.component4(): Boolean {
* Returns 4th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun ByteArray.component4(): Byte {
public inline operator fun ByteArray.component4(): Byte {
return get(3)
}
@@ -278,7 +278,7 @@ public inline fun ByteArray.component4(): Byte {
* Returns 4th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun CharArray.component4(): Char {
public inline operator fun CharArray.component4(): Char {
return get(3)
}
@@ -286,7 +286,7 @@ public inline fun CharArray.component4(): Char {
* Returns 4th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun DoubleArray.component4(): Double {
public inline operator fun DoubleArray.component4(): Double {
return get(3)
}
@@ -294,7 +294,7 @@ public inline fun DoubleArray.component4(): Double {
* Returns 4th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun FloatArray.component4(): Float {
public inline operator fun FloatArray.component4(): Float {
return get(3)
}
@@ -302,7 +302,7 @@ public inline fun FloatArray.component4(): Float {
* Returns 4th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun IntArray.component4(): Int {
public inline operator fun IntArray.component4(): Int {
return get(3)
}
@@ -310,7 +310,7 @@ public inline fun IntArray.component4(): Int {
* Returns 4th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun LongArray.component4(): Long {
public inline operator fun LongArray.component4(): Long {
return get(3)
}
@@ -318,7 +318,7 @@ public inline fun LongArray.component4(): Long {
* Returns 4th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun ShortArray.component4(): Short {
public inline operator fun ShortArray.component4(): Short {
return get(3)
}
@@ -326,7 +326,7 @@ public inline fun ShortArray.component4(): Short {
* Returns 4th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> List<T>.component4(): T {
public inline operator fun <T> List<T>.component4(): T {
return get(3)
}
@@ -334,7 +334,7 @@ public inline fun <T> List<T>.component4(): T {
* Returns 5th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.component5(): T {
public inline operator fun <T> Array<out T>.component5(): T {
return get(4)
}
@@ -342,7 +342,7 @@ public inline fun <T> Array<out T>.component5(): T {
* Returns 5th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun BooleanArray.component5(): Boolean {
public inline operator fun BooleanArray.component5(): Boolean {
return get(4)
}
@@ -350,7 +350,7 @@ public inline fun BooleanArray.component5(): Boolean {
* Returns 5th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun ByteArray.component5(): Byte {
public inline operator fun ByteArray.component5(): Byte {
return get(4)
}
@@ -358,7 +358,7 @@ public inline fun ByteArray.component5(): Byte {
* Returns 5th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun CharArray.component5(): Char {
public inline operator fun CharArray.component5(): Char {
return get(4)
}
@@ -366,7 +366,7 @@ public inline fun CharArray.component5(): Char {
* Returns 5th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun DoubleArray.component5(): Double {
public inline operator fun DoubleArray.component5(): Double {
return get(4)
}
@@ -374,7 +374,7 @@ public inline fun DoubleArray.component5(): Double {
* Returns 5th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun FloatArray.component5(): Float {
public inline operator fun FloatArray.component5(): Float {
return get(4)
}
@@ -382,7 +382,7 @@ public inline fun FloatArray.component5(): Float {
* Returns 5th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun IntArray.component5(): Int {
public inline operator fun IntArray.component5(): Int {
return get(4)
}
@@ -390,7 +390,7 @@ public inline fun IntArray.component5(): Int {
* Returns 5th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun LongArray.component5(): Long {
public inline operator fun LongArray.component5(): Long {
return get(4)
}
@@ -398,7 +398,7 @@ public inline fun LongArray.component5(): Long {
* Returns 5th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun ShortArray.component5(): Short {
public inline operator fun ShortArray.component5(): Short {
return get(4)
}
@@ -406,77 +406,77 @@ public inline fun ShortArray.component5(): Short {
* Returns 5th *element* from the collection.
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> List<T>.component5(): T {
public inline operator fun <T> List<T>.component5(): T {
return get(4)
}
/**
* Returns `true` if [element] is found in the collection.
*/
public fun <T> Array<out T>.contains(element: T): Boolean {
public operator fun <T> Array<out T>.contains(element: T): Boolean {
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
public fun BooleanArray.contains(element: Boolean): Boolean {
public operator fun BooleanArray.contains(element: Boolean): Boolean {
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
public fun ByteArray.contains(element: Byte): Boolean {
public operator fun ByteArray.contains(element: Byte): Boolean {
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
public fun CharArray.contains(element: Char): Boolean {
public operator fun CharArray.contains(element: Char): Boolean {
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
public fun DoubleArray.contains(element: Double): Boolean {
public operator fun DoubleArray.contains(element: Double): Boolean {
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
public fun FloatArray.contains(element: Float): Boolean {
public operator fun FloatArray.contains(element: Float): Boolean {
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
public fun IntArray.contains(element: Int): Boolean {
public operator fun IntArray.contains(element: Int): Boolean {
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
public fun LongArray.contains(element: Long): Boolean {
public operator fun LongArray.contains(element: Long): Boolean {
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
public fun ShortArray.contains(element: Short): Boolean {
public operator fun ShortArray.contains(element: Short): Boolean {
return indexOf(element) >= 0
}
/**
* Returns `true` if [element] is found in the collection.
*/
public fun <T> Iterable<T>.contains(element: T): Boolean {
public operator fun <T> Iterable<T>.contains(element: T): Boolean {
if (this is Collection)
return contains(element)
return indexOf(element) >= 0
@@ -485,7 +485,7 @@ public fun <T> Iterable<T>.contains(element: T): Boolean {
/**
* Returns `true` if [element] is found in the collection.
*/
public fun <T> Sequence<T>.contains(element: T): Boolean {
public operator fun <T> Sequence<T>.contains(element: T): Boolean {
return indexOf(element) >= 0
}
+28 -28
View File
@@ -377,7 +377,7 @@ public fun <T, R, V> Sequence<T>.merge(sequence: Sequence<R>, transform: (T, R)
/**
* Returns a list containing all elements of the original collection except the elements contained in the given [array].
*/
public fun <T> Iterable<T>.minus(array: Array<out T>): List<T> {
public operator fun <T> Iterable<T>.minus(array: Array<out T>): List<T> {
if (array.isEmpty()) return this.toList()
val other = array.toHashSet()
return this.filterNot { it in other }
@@ -388,7 +388,7 @@ public fun <T> Iterable<T>.minus(array: Array<out T>): List<T> {
* Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
*/
public fun <T> Sequence<T>.minus(array: Array<out T>): Sequence<T> {
public operator fun <T> Sequence<T>.minus(array: Array<out T>): Sequence<T> {
if (array.isEmpty()) return this
return object: Sequence<T> {
override fun iterator(): Iterator<T> {
@@ -401,7 +401,7 @@ public fun <T> Sequence<T>.minus(array: Array<out T>): Sequence<T> {
/**
* Returns a set containing all elements of the original set except the elements contained in the given [array].
*/
public fun <T> Set<T>.minus(array: Array<out T>): Set<T> {
public operator fun <T> Set<T>.minus(array: Array<out T>): Set<T> {
val result = LinkedHashSet<T>(this)
result.removeAll(array)
return result
@@ -410,7 +410,7 @@ public fun <T> Set<T>.minus(array: Array<out T>): Set<T> {
/**
* Returns a list containing all elements of the original collection except the elements contained in the given [collection].
*/
public fun <T> Iterable<T>.minus(collection: Iterable<T>): List<T> {
public operator fun <T> Iterable<T>.minus(collection: Iterable<T>): List<T> {
val other = collection.convertToSetForSetOperationWith(this)
if (other.isEmpty())
return this.toList()
@@ -422,7 +422,7 @@ public fun <T> Iterable<T>.minus(collection: Iterable<T>): List<T> {
* Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
*/
public fun <T> Sequence<T>.minus(collection: Iterable<T>): Sequence<T> {
public operator fun <T> Sequence<T>.minus(collection: Iterable<T>): Sequence<T> {
return object: Sequence<T> {
override fun iterator(): Iterator<T> {
val other = collection.convertToSetForSetOperation()
@@ -437,7 +437,7 @@ public fun <T> Sequence<T>.minus(collection: Iterable<T>): Sequence<T> {
/**
* Returns a set containing all elements of the original set except the elements contained in the given [collection].
*/
public fun <T> Set<T>.minus(collection: Iterable<T>): Set<T> {
public operator fun <T> Set<T>.minus(collection: Iterable<T>): Set<T> {
val other = collection.convertToSetForSetOperationWith(this)
if (other.isEmpty())
return this.toSet()
@@ -451,7 +451,7 @@ public fun <T> Set<T>.minus(collection: Iterable<T>): Set<T> {
/**
* Returns a list containing all elements of the original collection without the first occurrence of the given [element].
*/
public fun <T> Iterable<T>.minus(element: T): List<T> {
public operator fun <T> Iterable<T>.minus(element: T): List<T> {
val result = ArrayList<T>(collectionSizeOrDefault(10))
var removed = false
return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true }
@@ -460,7 +460,7 @@ public fun <T> Iterable<T>.minus(element: T): List<T> {
/**
* Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element].
*/
public fun <T> Sequence<T>.minus(element: T): Sequence<T> {
public operator fun <T> Sequence<T>.minus(element: T): Sequence<T> {
return object: Sequence<T> {
override fun iterator(): Iterator<T> {
var removed = false
@@ -472,7 +472,7 @@ public fun <T> Sequence<T>.minus(element: T): Sequence<T> {
/**
* Returns a set containing all elements of the original set except the given [element].
*/
public fun <T> Set<T>.minus(element: T): Set<T> {
public operator fun <T> Set<T>.minus(element: T): Set<T> {
val result = LinkedHashSet<T>(mapCapacity(size()))
var removed = false
return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true }
@@ -481,7 +481,7 @@ public fun <T> Set<T>.minus(element: T): Set<T> {
/**
* Returns a list containing all elements of the original collection except the elements contained in the given [sequence].
*/
public fun <T> Iterable<T>.minus(sequence: Sequence<T>): List<T> {
public operator fun <T> Iterable<T>.minus(sequence: Sequence<T>): List<T> {
val other = sequence.toHashSet()
if (other.isEmpty())
return this.toList()
@@ -493,7 +493,7 @@ public fun <T> Iterable<T>.minus(sequence: Sequence<T>): List<T> {
* Note that the source sequence and the sequence being subtracted are iterated only when an `iterator` is requested from
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
*/
public fun <T> Sequence<T>.minus(sequence: Sequence<T>): Sequence<T> {
public operator fun <T> Sequence<T>.minus(sequence: Sequence<T>): Sequence<T> {
return object: Sequence<T> {
override fun iterator(): Iterator<T> {
val other = sequence.toHashSet()
@@ -508,7 +508,7 @@ public fun <T> Sequence<T>.minus(sequence: Sequence<T>): Sequence<T> {
/**
* Returns a set containing all elements of the original set except the elements contained in the given [sequence].
*/
public fun <T> Set<T>.minus(sequence: Sequence<T>): Set<T> {
public operator fun <T> Set<T>.minus(sequence: Sequence<T>): Set<T> {
val result = LinkedHashSet<T>(this)
result.removeAll(sequence)
return result
@@ -733,7 +733,7 @@ public inline fun String.partition(predicate: (Char) -> Boolean): Pair<String, S
/**
* Returns a list containing all elements of the original collection and then all elements of the given [array].
*/
public fun <T> Collection<T>.plus(array: Array<out T>): List<T> {
public operator fun <T> Collection<T>.plus(array: Array<out T>): List<T> {
val result = ArrayList<T>(this.size() + array.size())
result.addAll(this)
result.addAll(array)
@@ -743,7 +743,7 @@ public fun <T> Collection<T>.plus(array: Array<out T>): List<T> {
/**
* Returns a list containing all elements of the original collection and then all elements of the given [array].
*/
public fun <T> Iterable<T>.plus(array: Array<out T>): List<T> {
public operator fun <T> Iterable<T>.plus(array: Array<out T>): List<T> {
if (this is Collection) return this.plus(array)
val result = ArrayList<T>()
result.addAll(this)
@@ -756,14 +756,14 @@ public fun <T> Iterable<T>.plus(array: Array<out T>): List<T> {
* Note that the source sequence and the array being added are iterated only when an `iterator` is requested from
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
*/
public fun <T> Sequence<T>.plus(array: Array<out T>): Sequence<T> {
public operator fun <T> Sequence<T>.plus(array: Array<out T>): Sequence<T> {
return this.plus(array.asList())
}
/**
* Returns a set containing all elements both of the original set and the given [array].
*/
public fun <T> Set<T>.plus(array: Array<out T>): Set<T> {
public operator fun <T> Set<T>.plus(array: Array<out T>): Set<T> {
val result = LinkedHashSet<T>(mapCapacity(this.size() + array.size()))
result.addAll(this)
result.addAll(array)
@@ -773,7 +773,7 @@ public fun <T> Set<T>.plus(array: Array<out T>): Set<T> {
/**
* Returns a list containing all elements of the original collection and then all elements of the given [collection].
*/
public fun <T> Collection<T>.plus(collection: Iterable<T>): List<T> {
public operator fun <T> Collection<T>.plus(collection: Iterable<T>): List<T> {
if (collection is Collection) {
val result = ArrayList<T>(this.size() + collection.size())
result.addAll(this)
@@ -789,7 +789,7 @@ public fun <T> Collection<T>.plus(collection: Iterable<T>): List<T> {
/**
* Returns a list containing all elements of the original collection and then all elements of the given [collection].
*/
public fun <T> Iterable<T>.plus(collection: Iterable<T>): List<T> {
public operator fun <T> Iterable<T>.plus(collection: Iterable<T>): List<T> {
if (this is Collection) return this.plus(collection)
val result = ArrayList<T>()
result.addAll(this)
@@ -802,14 +802,14 @@ public fun <T> Iterable<T>.plus(collection: Iterable<T>): List<T> {
* Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
*/
public fun <T> Sequence<T>.plus(collection: Iterable<T>): Sequence<T> {
public operator fun <T> Sequence<T>.plus(collection: Iterable<T>): Sequence<T> {
return sequenceOf(this, collection.asSequence()).flatten()
}
/**
* Returns a set containing all elements both of the original set and the given [collection].
*/
public fun <T> Set<T>.plus(collection: Iterable<T>): Set<T> {
public operator fun <T> Set<T>.plus(collection: Iterable<T>): Set<T> {
val result = LinkedHashSet<T>(mapCapacity(collection.collectionSizeOrNull()?.let { this.size() + it } ?: this.size() * 2))
result.addAll(this)
result.addAll(collection)
@@ -819,7 +819,7 @@ public fun <T> Set<T>.plus(collection: Iterable<T>): Set<T> {
/**
* Returns a list containing all elements of the original collection and then the given [element].
*/
public fun <T> Collection<T>.plus(element: T): List<T> {
public operator fun <T> Collection<T>.plus(element: T): List<T> {
val result = ArrayList<T>(size() + 1)
result.addAll(this)
result.add(element)
@@ -829,7 +829,7 @@ public fun <T> Collection<T>.plus(element: T): List<T> {
/**
* Returns a list containing all elements of the original collection and then the given [element].
*/
public fun <T> Iterable<T>.plus(element: T): List<T> {
public operator fun <T> Iterable<T>.plus(element: T): List<T> {
if (this is Collection) return this.plus(element)
val result = ArrayList<T>()
result.addAll(this)
@@ -840,14 +840,14 @@ public fun <T> Iterable<T>.plus(element: T): List<T> {
/**
* Returns a sequence containing all elements of the original sequence and then the given [element].
*/
public fun <T> Sequence<T>.plus(element: T): Sequence<T> {
public operator fun <T> Sequence<T>.plus(element: T): Sequence<T> {
return sequenceOf(this, sequenceOf(element)).flatten()
}
/**
* Returns a set containing all elements of the original set and then the given [element].
*/
public fun <T> Set<T>.plus(element: T): Set<T> {
public operator fun <T> Set<T>.plus(element: T): Set<T> {
val result = LinkedHashSet<T>(mapCapacity(size() + 1))
result.addAll(this)
result.add(element)
@@ -857,7 +857,7 @@ public fun <T> Set<T>.plus(element: T): Set<T> {
/**
* Returns a list containing all elements of the original collection and then all elements of the given [sequence].
*/
public fun <T> Collection<T>.plus(sequence: Sequence<T>): List<T> {
public operator fun <T> Collection<T>.plus(sequence: Sequence<T>): List<T> {
val result = ArrayList<T>(this.size() + 10)
result.addAll(this)
result.addAll(sequence)
@@ -867,7 +867,7 @@ public fun <T> Collection<T>.plus(sequence: Sequence<T>): List<T> {
/**
* Returns a list containing all elements of the original collection and then all elements of the given [sequence].
*/
public fun <T> Iterable<T>.plus(sequence: Sequence<T>): List<T> {
public operator fun <T> Iterable<T>.plus(sequence: Sequence<T>): List<T> {
val result = ArrayList<T>()
result.addAll(this)
result.addAll(sequence)
@@ -879,14 +879,14 @@ public fun <T> Iterable<T>.plus(sequence: Sequence<T>): List<T> {
* Note that the source sequence and the sequence being added are iterated only when an `iterator` is requested from
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
*/
public fun <T> Sequence<T>.plus(sequence: Sequence<T>): Sequence<T> {
public operator fun <T> Sequence<T>.plus(sequence: Sequence<T>): Sequence<T> {
return sequenceOf(this, sequence).flatten()
}
/**
* Returns a set containing all elements both of the original set and the given [sequence].
*/
public fun <T> Set<T>.plus(sequence: Sequence<T>): Set<T> {
public operator fun <T> Set<T>.plus(sequence: Sequence<T>): Set<T> {
val result = LinkedHashSet<T>(mapCapacity(this.size() * 2))
result.addAll(this)
result.addAll(sequence)
+42 -42
View File
@@ -14,7 +14,7 @@ import java.util.Collections // TODO: it's temporary while we have java.util.Col
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("intRangeContains")
public fun Range<Int>.contains(item: Byte): Boolean {
public operator fun Range<Int>.contains(item: Byte): Boolean {
return start <= item && item <= end
}
@@ -22,7 +22,7 @@ public fun Range<Int>.contains(item: Byte): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("longRangeContains")
public fun Range<Long>.contains(item: Byte): Boolean {
public operator fun Range<Long>.contains(item: Byte): Boolean {
return start <= item && item <= end
}
@@ -30,7 +30,7 @@ public fun Range<Long>.contains(item: Byte): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("shortRangeContains")
public fun Range<Short>.contains(item: Byte): Boolean {
public operator fun Range<Short>.contains(item: Byte): Boolean {
return start <= item && item <= end
}
@@ -38,7 +38,7 @@ public fun Range<Short>.contains(item: Byte): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("doubleRangeContains")
public fun Range<Double>.contains(item: Byte): Boolean {
public operator fun Range<Double>.contains(item: Byte): Boolean {
return start <= item && item <= end
}
@@ -46,42 +46,42 @@ public fun Range<Double>.contains(item: Byte): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("floatRangeContains")
public fun Range<Float>.contains(item: Byte): Boolean {
public operator fun Range<Float>.contains(item: Byte): Boolean {
return start <= item && item <= end
}
@Deprecated("The 'contains' operation for a range of Char and Byte item is not supported and should not be used.")
public fun CharRange.contains(item: Byte): Nothing {
public operator fun CharRange.contains(item: Byte): Nothing {
throw UnsupportedOperationException()
}
@Deprecated("The 'contains' operation for a range of Int and Char item is not supported and should not be used.")
public fun IntRange.contains(item: Char): Nothing {
public operator fun IntRange.contains(item: Char): Nothing {
throw UnsupportedOperationException()
}
@Deprecated("The 'contains' operation for a range of Long and Char item is not supported and should not be used.")
public fun LongRange.contains(item: Char): Nothing {
public operator fun LongRange.contains(item: Char): Nothing {
throw UnsupportedOperationException()
}
@Deprecated("The 'contains' operation for a range of Byte and Char item is not supported and should not be used.")
public fun ByteRange.contains(item: Char): Nothing {
public operator fun ByteRange.contains(item: Char): Nothing {
throw UnsupportedOperationException()
}
@Deprecated("The 'contains' operation for a range of Short and Char item is not supported and should not be used.")
public fun ShortRange.contains(item: Char): Nothing {
public operator fun ShortRange.contains(item: Char): Nothing {
throw UnsupportedOperationException()
}
@Deprecated("The 'contains' operation for a range of Double and Char item is not supported and should not be used.")
public fun DoubleRange.contains(item: Char): Nothing {
public operator fun DoubleRange.contains(item: Char): Nothing {
throw UnsupportedOperationException()
}
@Deprecated("The 'contains' operation for a range of Float and Char item is not supported and should not be used.")
public fun FloatRange.contains(item: Char): Nothing {
public operator fun FloatRange.contains(item: Char): Nothing {
throw UnsupportedOperationException()
}
@@ -89,7 +89,7 @@ public fun FloatRange.contains(item: Char): Nothing {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("intRangeContains")
public fun Range<Int>.contains(item: Double): Boolean {
public operator fun Range<Int>.contains(item: Double): Boolean {
return start <= item && item <= end
}
@@ -97,7 +97,7 @@ public fun Range<Int>.contains(item: Double): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("longRangeContains")
public fun Range<Long>.contains(item: Double): Boolean {
public operator fun Range<Long>.contains(item: Double): Boolean {
return start <= item && item <= end
}
@@ -105,7 +105,7 @@ public fun Range<Long>.contains(item: Double): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("byteRangeContains")
public fun Range<Byte>.contains(item: Double): Boolean {
public operator fun Range<Byte>.contains(item: Double): Boolean {
return start <= item && item <= end
}
@@ -113,7 +113,7 @@ public fun Range<Byte>.contains(item: Double): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("shortRangeContains")
public fun Range<Short>.contains(item: Double): Boolean {
public operator fun Range<Short>.contains(item: Double): Boolean {
return start <= item && item <= end
}
@@ -121,12 +121,12 @@ public fun Range<Short>.contains(item: Double): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("floatRangeContains")
public fun Range<Float>.contains(item: Double): Boolean {
public operator fun Range<Float>.contains(item: Double): Boolean {
return start <= item && item <= end
}
@Deprecated("The 'contains' operation for a range of Char and Double item is not supported and should not be used.")
public fun CharRange.contains(item: Double): Nothing {
public operator fun CharRange.contains(item: Double): Nothing {
throw UnsupportedOperationException()
}
@@ -134,7 +134,7 @@ public fun CharRange.contains(item: Double): Nothing {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("intRangeContains")
public fun Range<Int>.contains(item: Float): Boolean {
public operator fun Range<Int>.contains(item: Float): Boolean {
return start <= item && item <= end
}
@@ -142,7 +142,7 @@ public fun Range<Int>.contains(item: Float): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("longRangeContains")
public fun Range<Long>.contains(item: Float): Boolean {
public operator fun Range<Long>.contains(item: Float): Boolean {
return start <= item && item <= end
}
@@ -150,7 +150,7 @@ public fun Range<Long>.contains(item: Float): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("byteRangeContains")
public fun Range<Byte>.contains(item: Float): Boolean {
public operator fun Range<Byte>.contains(item: Float): Boolean {
return start <= item && item <= end
}
@@ -158,7 +158,7 @@ public fun Range<Byte>.contains(item: Float): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("shortRangeContains")
public fun Range<Short>.contains(item: Float): Boolean {
public operator fun Range<Short>.contains(item: Float): Boolean {
return start <= item && item <= end
}
@@ -166,12 +166,12 @@ public fun Range<Short>.contains(item: Float): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("doubleRangeContains")
public fun Range<Double>.contains(item: Float): Boolean {
public operator fun Range<Double>.contains(item: Float): Boolean {
return start <= item && item <= end
}
@Deprecated("The 'contains' operation for a range of Char and Float item is not supported and should not be used.")
public fun CharRange.contains(item: Float): Nothing {
public operator fun CharRange.contains(item: Float): Nothing {
throw UnsupportedOperationException()
}
@@ -179,7 +179,7 @@ public fun CharRange.contains(item: Float): Nothing {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("longRangeContains")
public fun Range<Long>.contains(item: Int): Boolean {
public operator fun Range<Long>.contains(item: Int): Boolean {
return start <= item && item <= end
}
@@ -187,7 +187,7 @@ public fun Range<Long>.contains(item: Int): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("byteRangeContains")
public fun Range<Byte>.contains(item: Int): Boolean {
public operator fun Range<Byte>.contains(item: Int): Boolean {
return start <= item && item <= end
}
@@ -195,7 +195,7 @@ public fun Range<Byte>.contains(item: Int): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("shortRangeContains")
public fun Range<Short>.contains(item: Int): Boolean {
public operator fun Range<Short>.contains(item: Int): Boolean {
return start <= item && item <= end
}
@@ -203,7 +203,7 @@ public fun Range<Short>.contains(item: Int): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("doubleRangeContains")
public fun Range<Double>.contains(item: Int): Boolean {
public operator fun Range<Double>.contains(item: Int): Boolean {
return start <= item && item <= end
}
@@ -211,12 +211,12 @@ public fun Range<Double>.contains(item: Int): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("floatRangeContains")
public fun Range<Float>.contains(item: Int): Boolean {
public operator fun Range<Float>.contains(item: Int): Boolean {
return start <= item && item <= end
}
@Deprecated("The 'contains' operation for a range of Char and Int item is not supported and should not be used.")
public fun CharRange.contains(item: Int): Nothing {
public operator fun CharRange.contains(item: Int): Nothing {
throw UnsupportedOperationException()
}
@@ -224,7 +224,7 @@ public fun CharRange.contains(item: Int): Nothing {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("intRangeContains")
public fun Range<Int>.contains(item: Long): Boolean {
public operator fun Range<Int>.contains(item: Long): Boolean {
return start <= item && item <= end
}
@@ -232,7 +232,7 @@ public fun Range<Int>.contains(item: Long): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("byteRangeContains")
public fun Range<Byte>.contains(item: Long): Boolean {
public operator fun Range<Byte>.contains(item: Long): Boolean {
return start <= item && item <= end
}
@@ -240,7 +240,7 @@ public fun Range<Byte>.contains(item: Long): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("shortRangeContains")
public fun Range<Short>.contains(item: Long): Boolean {
public operator fun Range<Short>.contains(item: Long): Boolean {
return start <= item && item <= end
}
@@ -248,7 +248,7 @@ public fun Range<Short>.contains(item: Long): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("doubleRangeContains")
public fun Range<Double>.contains(item: Long): Boolean {
public operator fun Range<Double>.contains(item: Long): Boolean {
return start <= item && item <= end
}
@@ -256,12 +256,12 @@ public fun Range<Double>.contains(item: Long): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("floatRangeContains")
public fun Range<Float>.contains(item: Long): Boolean {
public operator fun Range<Float>.contains(item: Long): Boolean {
return start <= item && item <= end
}
@Deprecated("The 'contains' operation for a range of Char and Long item is not supported and should not be used.")
public fun CharRange.contains(item: Long): Nothing {
public operator fun CharRange.contains(item: Long): Nothing {
throw UnsupportedOperationException()
}
@@ -269,7 +269,7 @@ public fun CharRange.contains(item: Long): Nothing {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("intRangeContains")
public fun Range<Int>.contains(item: Short): Boolean {
public operator fun Range<Int>.contains(item: Short): Boolean {
return start <= item && item <= end
}
@@ -277,7 +277,7 @@ public fun Range<Int>.contains(item: Short): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("longRangeContains")
public fun Range<Long>.contains(item: Short): Boolean {
public operator fun Range<Long>.contains(item: Short): Boolean {
return start <= item && item <= end
}
@@ -285,7 +285,7 @@ public fun Range<Long>.contains(item: Short): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("byteRangeContains")
public fun Range<Byte>.contains(item: Short): Boolean {
public operator fun Range<Byte>.contains(item: Short): Boolean {
return start <= item && item <= end
}
@@ -293,7 +293,7 @@ public fun Range<Byte>.contains(item: Short): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("doubleRangeContains")
public fun Range<Double>.contains(item: Short): Boolean {
public operator fun Range<Double>.contains(item: Short): Boolean {
return start <= item && item <= end
}
@@ -301,12 +301,12 @@ public fun Range<Double>.contains(item: Short): Boolean {
* Checks if the specified [item] belongs to this range.
*/
@kotlin.jvm.JvmName("floatRangeContains")
public fun Range<Float>.contains(item: Short): Boolean {
public operator fun Range<Float>.contains(item: Short): Boolean {
return start <= item && item <= end
}
@Deprecated("The 'contains' operation for a range of Char and Short item is not supported and should not be used.")
public fun CharRange.contains(item: Short): Nothing {
public operator fun CharRange.contains(item: Short): Nothing {
throw UnsupportedOperationException()
}
+27 -27
View File
@@ -569,7 +569,7 @@ public fun <C : MutableCollection<in R>, R> Sequence<*>.filterIsInstanceTo(desti
/**
* Returns an array containing all elements of the original array and then all elements of the given [array].
*/
public fun BooleanArray.plus(array: BooleanArray): BooleanArray {
public operator fun BooleanArray.plus(array: BooleanArray): BooleanArray {
val thisSize = size()
val arraySize = array.size()
val result = Arrays.copyOf(this, thisSize + arraySize)
@@ -580,7 +580,7 @@ public fun BooleanArray.plus(array: BooleanArray): BooleanArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [array].
*/
public fun ByteArray.plus(array: ByteArray): ByteArray {
public operator fun ByteArray.plus(array: ByteArray): ByteArray {
val thisSize = size()
val arraySize = array.size()
val result = Arrays.copyOf(this, thisSize + arraySize)
@@ -591,7 +591,7 @@ public fun ByteArray.plus(array: ByteArray): ByteArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [array].
*/
public fun CharArray.plus(array: CharArray): CharArray {
public operator fun CharArray.plus(array: CharArray): CharArray {
val thisSize = size()
val arraySize = array.size()
val result = Arrays.copyOf(this, thisSize + arraySize)
@@ -602,7 +602,7 @@ public fun CharArray.plus(array: CharArray): CharArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [array].
*/
public fun DoubleArray.plus(array: DoubleArray): DoubleArray {
public operator fun DoubleArray.plus(array: DoubleArray): DoubleArray {
val thisSize = size()
val arraySize = array.size()
val result = Arrays.copyOf(this, thisSize + arraySize)
@@ -613,7 +613,7 @@ public fun DoubleArray.plus(array: DoubleArray): DoubleArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [array].
*/
public fun FloatArray.plus(array: FloatArray): FloatArray {
public operator fun FloatArray.plus(array: FloatArray): FloatArray {
val thisSize = size()
val arraySize = array.size()
val result = Arrays.copyOf(this, thisSize + arraySize)
@@ -624,7 +624,7 @@ public fun FloatArray.plus(array: FloatArray): FloatArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [array].
*/
public fun IntArray.plus(array: IntArray): IntArray {
public operator fun IntArray.plus(array: IntArray): IntArray {
val thisSize = size()
val arraySize = array.size()
val result = Arrays.copyOf(this, thisSize + arraySize)
@@ -635,7 +635,7 @@ public fun IntArray.plus(array: IntArray): IntArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [array].
*/
public fun LongArray.plus(array: LongArray): LongArray {
public operator fun LongArray.plus(array: LongArray): LongArray {
val thisSize = size()
val arraySize = array.size()
val result = Arrays.copyOf(this, thisSize + arraySize)
@@ -646,7 +646,7 @@ public fun LongArray.plus(array: LongArray): LongArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [array].
*/
public fun ShortArray.plus(array: ShortArray): ShortArray {
public operator fun ShortArray.plus(array: ShortArray): ShortArray {
val thisSize = size()
val arraySize = array.size()
val result = Arrays.copyOf(this, thisSize + arraySize)
@@ -657,7 +657,7 @@ public fun ShortArray.plus(array: ShortArray): ShortArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [array].
*/
public fun <T> Array<T>.plus(array: Array<out T>): Array<T> {
public operator fun <T> Array<T>.plus(array: Array<out T>): Array<T> {
val thisSize = size()
val arraySize = array.size()
val result = Arrays.copyOf(this, thisSize + arraySize)
@@ -668,7 +668,7 @@ public fun <T> Array<T>.plus(array: Array<out T>): Array<T> {
/**
* Returns an array containing all elements of the original array and then all elements of the given [collection].
*/
public fun BooleanArray.plus(collection: Collection<Boolean>): BooleanArray {
public operator fun BooleanArray.plus(collection: Collection<Boolean>): BooleanArray {
var index = size()
val result = Arrays.copyOf(this, index + collection.size())
for (element in collection) result[index++] = element
@@ -678,7 +678,7 @@ public fun BooleanArray.plus(collection: Collection<Boolean>): BooleanArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [collection].
*/
public fun ByteArray.plus(collection: Collection<Byte>): ByteArray {
public operator fun ByteArray.plus(collection: Collection<Byte>): ByteArray {
var index = size()
val result = Arrays.copyOf(this, index + collection.size())
for (element in collection) result[index++] = element
@@ -688,7 +688,7 @@ public fun ByteArray.plus(collection: Collection<Byte>): ByteArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [collection].
*/
public fun CharArray.plus(collection: Collection<Char>): CharArray {
public operator fun CharArray.plus(collection: Collection<Char>): CharArray {
var index = size()
val result = Arrays.copyOf(this, index + collection.size())
for (element in collection) result[index++] = element
@@ -698,7 +698,7 @@ public fun CharArray.plus(collection: Collection<Char>): CharArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [collection].
*/
public fun DoubleArray.plus(collection: Collection<Double>): DoubleArray {
public operator fun DoubleArray.plus(collection: Collection<Double>): DoubleArray {
var index = size()
val result = Arrays.copyOf(this, index + collection.size())
for (element in collection) result[index++] = element
@@ -708,7 +708,7 @@ public fun DoubleArray.plus(collection: Collection<Double>): DoubleArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [collection].
*/
public fun FloatArray.plus(collection: Collection<Float>): FloatArray {
public operator fun FloatArray.plus(collection: Collection<Float>): FloatArray {
var index = size()
val result = Arrays.copyOf(this, index + collection.size())
for (element in collection) result[index++] = element
@@ -718,7 +718,7 @@ public fun FloatArray.plus(collection: Collection<Float>): FloatArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [collection].
*/
public fun IntArray.plus(collection: Collection<Int>): IntArray {
public operator fun IntArray.plus(collection: Collection<Int>): IntArray {
var index = size()
val result = Arrays.copyOf(this, index + collection.size())
for (element in collection) result[index++] = element
@@ -728,7 +728,7 @@ public fun IntArray.plus(collection: Collection<Int>): IntArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [collection].
*/
public fun LongArray.plus(collection: Collection<Long>): LongArray {
public operator fun LongArray.plus(collection: Collection<Long>): LongArray {
var index = size()
val result = Arrays.copyOf(this, index + collection.size())
for (element in collection) result[index++] = element
@@ -738,7 +738,7 @@ public fun LongArray.plus(collection: Collection<Long>): LongArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [collection].
*/
public fun ShortArray.plus(collection: Collection<Short>): ShortArray {
public operator fun ShortArray.plus(collection: Collection<Short>): ShortArray {
var index = size()
val result = Arrays.copyOf(this, index + collection.size())
for (element in collection) result[index++] = element
@@ -748,7 +748,7 @@ public fun ShortArray.plus(collection: Collection<Short>): ShortArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [collection].
*/
public fun <T> Array<T>.plus(collection: Collection<T>): Array<T> {
public operator fun <T> Array<T>.plus(collection: Collection<T>): Array<T> {
var index = size()
val result = Arrays.copyOf(this, index + collection.size())
for (element in collection) result[index++] = element
@@ -758,7 +758,7 @@ public fun <T> Array<T>.plus(collection: Collection<T>): Array<T> {
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
public fun BooleanArray.plus(element: Boolean): BooleanArray {
public operator fun BooleanArray.plus(element: Boolean): BooleanArray {
val index = size()
val result = Arrays.copyOf(this, index + 1)
result[index] = element
@@ -768,7 +768,7 @@ public fun BooleanArray.plus(element: Boolean): BooleanArray {
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
public fun ByteArray.plus(element: Byte): ByteArray {
public operator fun ByteArray.plus(element: Byte): ByteArray {
val index = size()
val result = Arrays.copyOf(this, index + 1)
result[index] = element
@@ -778,7 +778,7 @@ public fun ByteArray.plus(element: Byte): ByteArray {
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
public fun CharArray.plus(element: Char): CharArray {
public operator fun CharArray.plus(element: Char): CharArray {
val index = size()
val result = Arrays.copyOf(this, index + 1)
result[index] = element
@@ -788,7 +788,7 @@ public fun CharArray.plus(element: Char): CharArray {
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
public fun DoubleArray.plus(element: Double): DoubleArray {
public operator fun DoubleArray.plus(element: Double): DoubleArray {
val index = size()
val result = Arrays.copyOf(this, index + 1)
result[index] = element
@@ -798,7 +798,7 @@ public fun DoubleArray.plus(element: Double): DoubleArray {
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
public fun FloatArray.plus(element: Float): FloatArray {
public operator fun FloatArray.plus(element: Float): FloatArray {
val index = size()
val result = Arrays.copyOf(this, index + 1)
result[index] = element
@@ -808,7 +808,7 @@ public fun FloatArray.plus(element: Float): FloatArray {
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
public fun IntArray.plus(element: Int): IntArray {
public operator fun IntArray.plus(element: Int): IntArray {
val index = size()
val result = Arrays.copyOf(this, index + 1)
result[index] = element
@@ -818,7 +818,7 @@ public fun IntArray.plus(element: Int): IntArray {
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
public fun LongArray.plus(element: Long): LongArray {
public operator fun LongArray.plus(element: Long): LongArray {
val index = size()
val result = Arrays.copyOf(this, index + 1)
result[index] = element
@@ -828,7 +828,7 @@ public fun LongArray.plus(element: Long): LongArray {
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
public fun ShortArray.plus(element: Short): ShortArray {
public operator fun ShortArray.plus(element: Short): ShortArray {
val index = size()
val result = Arrays.copyOf(this, index + 1)
result[index] = element
@@ -838,7 +838,7 @@ public fun ShortArray.plus(element: Short): ShortArray {
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
public fun <T> Array<T>.plus(element: T): Array<T> {
public operator fun <T> Array<T>.plus(element: T): Array<T> {
val index = size()
val result = Arrays.copyOf(this, index + 1)
result[index] = element
@@ -5,7 +5,7 @@ import java.util.Enumeration
/**
* Creates an [Iterator] for an [Enumeration], allowing to use it in `for` loops.
*/
public fun <T> Enumeration<T>.iterator(): Iterator<T> = object : Iterator<T> {
public operator fun <T> Enumeration<T>.iterator(): Iterator<T> = object : Iterator<T> {
override fun hasNext(): Boolean = hasMoreElements()
public override fun next(): T = nextElement()
@@ -14,7 +14,7 @@ public fun <T> Enumeration<T>.iterator(): Iterator<T> = object : Iterator<T> {
/**
* Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop.
*/
public fun <T> Iterator<T>.iterator(): Iterator<T> = this
public operator fun <T> Iterator<T>.iterator(): Iterator<T> = this
/**
* Performs the given [operation] on each element of this [Iterator].
+22 -22
View File
@@ -91,7 +91,7 @@ public fun <K,V> Map<K,V>?.orEmpty() : Map<K,V> = this ?: emptyMap()
* Checks if the map contains the given key. This method allows to use the `x in map` syntax for checking
* whether an object is contained in the map.
*/
public fun <K,V> Map<K,V>.contains(key : K) : Boolean = containsKey(key)
public operator fun <K,V> Map<K,V>.contains(key : K) : Boolean = containsKey(key)
/**
* Allows to access the key of a map entry as a property. Equivalent to `getKey()`.
@@ -115,7 +115,7 @@ public val <K, V> Map.Entry<K, V>.value: V
* }
* ```
*/
public fun <K, V> Map.Entry<K, V>.component1(): K {
public operator fun <K, V> Map.Entry<K, V>.component1(): K {
return getKey()
}
@@ -128,7 +128,7 @@ public fun <K, V> Map.Entry<K, V>.component1(): K {
* }
* ```
*/
public fun <K, V> Map.Entry<K, V>.component2(): V {
public operator fun <K, V> Map.Entry<K, V>.component2(): V {
return getValue()
}
@@ -175,7 +175,7 @@ public inline fun <K, V> MutableMap<K, V>.getOrPut(key: K, defaultValue: () -> V
*
* @sample test.collections.MapTest.iterateWithProperties
*/
public fun <K, V> Map<K, V>.iterator(): Iterator<Map.Entry<K, V>> {
public operator fun <K, V> Map<K, V>.iterator(): Iterator<Map.Entry<K, V>> {
val entrySet = entrySet()
return entrySet.iterator()
}
@@ -362,7 +362,7 @@ public fun <K, V> Map<K, V>.toLinkedMap(): MutableMap<K, V> = LinkedHashMap(this
/**
* Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair].
*/
public fun <K, V> Map<K, V>.plus(pair: Pair<K, V>): Map<K, V> {
public operator fun <K, V> Map<K, V>.plus(pair: Pair<K, V>): Map<K, V> {
val newMap = this.toLinkedMap()
newMap.put(pair.first, pair.second)
return newMap
@@ -371,7 +371,7 @@ public fun <K, V> Map<K, V>.plus(pair: Pair<K, V>): Map<K, V> {
/**
* Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs].
*/
public fun <K, V> Map<K, V>.plus(pairs: Iterable<Pair<K, V>>): Map<K, V> {
public operator fun <K, V> Map<K, V>.plus(pairs: Iterable<Pair<K, V>>): Map<K, V> {
val newMap = this.toLinkedMap()
newMap.putAll(pairs)
return newMap
@@ -380,7 +380,7 @@ public fun <K, V> Map<K, V>.plus(pairs: Iterable<Pair<K, V>>): Map<K, V> {
/**
* Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs].
*/
public fun <K, V> Map<K, V>.plus(pairs: Array<Pair<K, V>>): Map<K, V> {
public operator fun <K, V> Map<K, V>.plus(pairs: Array<Pair<K, V>>): Map<K, V> {
val newMap = this.toLinkedMap()
newMap.putAll(*pairs)
return newMap
@@ -389,7 +389,7 @@ public fun <K, V> Map<K, V>.plus(pairs: Array<Pair<K, V>>): Map<K, V> {
/**
* Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs].
*/
public fun <K, V> Map<K, V>.plus(pairs: Sequence<Pair<K, V>>): Map<K, V> {
public operator fun <K, V> Map<K, V>.plus(pairs: Sequence<Pair<K, V>>): Map<K, V> {
val newMap = this.toLinkedMap()
newMap.putAll(pairs)
return newMap
@@ -398,7 +398,7 @@ public fun <K, V> Map<K, V>.plus(pairs: Sequence<Pair<K, V>>): Map<K, V> {
/**
* Creates a new read-only map by replacing or adding entries to this map from another [map].
*/
public fun <K, V> Map<K, V>.plus(map: Map<K, V>): Map<K, V> {
public operator fun <K, V> Map<K, V>.plus(map: Map<K, V>): Map<K, V> {
val newMap = this.toLinkedMap()
newMap.putAll(map)
return newMap
@@ -407,42 +407,42 @@ public fun <K, V> Map<K, V>.plus(map: Map<K, V>): Map<K, V> {
/**
* Appends or replaces the given [pair] in this mutable map.
*/
public fun <K, V> MutableMap<K, V>.plusAssign(pair: Pair<K, V>) {
public operator fun <K, V> MutableMap<K, V>.plusAssign(pair: Pair<K, V>) {
put(pair.first, pair.second)
}
/**
* Appends or replaces all pairs from the given collection of [pairs] in this mutable map.
*/
public fun <K, V> MutableMap<K, V>.plusAssign(pairs: Iterable<Pair<K, V>>) {
public operator fun <K, V> MutableMap<K, V>.plusAssign(pairs: Iterable<Pair<K, V>>) {
putAll(pairs)
}
/**
* Appends or replaces all pairs from the given array of [pairs] in this mutable map.
*/
public fun <K, V> MutableMap<K, V>.plusAssign(pairs: Array<Pair<K, V>>) {
public operator fun <K, V> MutableMap<K, V>.plusAssign(pairs: Array<Pair<K, V>>) {
putAll(*pairs)
}
/**
* Appends or replaces all pairs from the given sequence of [pairs] in this mutable map.
*/
public fun <K, V> MutableMap<K, V>.plusAssign(pairs: Sequence<Pair<K, V>>) {
public operator fun <K, V> MutableMap<K, V>.plusAssign(pairs: Sequence<Pair<K, V>>) {
putAll(pairs)
}
/**
* Appends or replaces all entries from the given [map] in this mutable map.
*/
public fun <K, V> MutableMap<K, V>.plusAssign(map: Map<K, V>) {
public operator fun <K, V> MutableMap<K, V>.plusAssign(map: Map<K, V>) {
putAll(map)
}
/**
* Creates a new read-only map by removing a [key] from this map.
*/
public fun <K, V> Map<K, V>.minus(key: K): Map<K, V> {
public operator fun <K, V> Map<K, V>.minus(key: K): Map<K, V> {
val result = LinkedHashMap<K, V>(this)
result.minusAssign(key)
return result
@@ -451,7 +451,7 @@ public fun <K, V> Map<K, V>.minus(key: K): Map<K, V> {
/**
* Creates a new read-only map by removing a collection of [keys] from this map.
*/
public fun <K, V> Map<K, V>.minus(keys: Iterable<K>): Map<K, V> {
public operator fun <K, V> Map<K, V>.minus(keys: Iterable<K>): Map<K, V> {
val result = LinkedHashMap<K, V>(this)
result.minusAssign(keys)
return result
@@ -460,7 +460,7 @@ public fun <K, V> Map<K, V>.minus(keys: Iterable<K>): Map<K, V> {
/**
* Creates a new read-only map by removing a array of [keys] from this map.
*/
public fun <K, V> Map<K, V>.minus(keys: Array<K>): Map<K, V> {
public operator fun <K, V> Map<K, V>.minus(keys: Array<K>): Map<K, V> {
val result = LinkedHashMap<K, V>(this)
result.minusAssign(keys)
return result
@@ -469,7 +469,7 @@ public fun <K, V> Map<K, V>.minus(keys: Array<K>): Map<K, V> {
/**
* Creates a new read-only map by removing a sequence of [keys] from this map.
*/
public fun <K, V> Map<K, V>.minus(keys: Sequence<K>): Map<K, V> {
public operator fun <K, V> Map<K, V>.minus(keys: Sequence<K>): Map<K, V> {
val result = LinkedHashMap<K, V>(this)
result.minusAssign(keys)
return result
@@ -478,27 +478,27 @@ public fun <K, V> Map<K, V>.minus(keys: Sequence<K>): Map<K, V> {
/**
* Removes the given [key] from this mutable map.
*/
public fun <K, V> MutableMap<K, V>.minusAssign(key: K) {
public operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) {
remove(key)
}
/**
* Removes all the given [keys] from this mutable map.
*/
public fun <K, V> MutableMap<K, V>.minusAssign(keys: Iterable<K>) {
public operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Iterable<K>) {
for (key in keys) remove(key)
}
/**
* Removes all the given [keys] from this mutable map.
*/
public fun <K, V> MutableMap<K, V>.minusAssign(keys: Array<K>) {
public operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Array<K>) {
for (key in keys) remove(key)
}
/**
* Removes all the given [keys] from this mutable map.
*/
public fun <K, V> MutableMap<K, V>.minusAssign(keys: Sequence<K>) {
public operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Sequence<K>) {
for (key in keys) remove(key)
}
@@ -11,7 +11,7 @@ import java.util.concurrent.ConcurrentMap
* Allows to use the index operator for storing values in a mutable map.
*/
// this code is JVM-specific, because JS has native set function
public fun <K, V> MutableMap<K, V>.set(key: K, value: V): V? = put(key, value)
public operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): V? = put(key, value)
/**
* getOrPut is not supported on [ConcurrentMap] since it cannot be implemented correctly in terms of concurrency.
@@ -3,56 +3,56 @@ package kotlin
/**
* Adds the specified [element] to this mutable collection.
*/
public fun <T> MutableCollection<in T>.plusAssign(element: T) {
public operator fun <T> MutableCollection<in T>.plusAssign(element: T) {
this.add(element)
}
/**
* Adds all elements of the given [collection] to this mutable collection.
*/
public fun <T> MutableCollection<in T>.plusAssign(collection: Iterable<T>) {
public operator fun <T> MutableCollection<in T>.plusAssign(collection: Iterable<T>) {
this.addAll(collection)
}
/**
* Adds all elements of the given [array] to this mutable collection.
*/
public fun <T> MutableCollection<in T>.plusAssign(array: Array<T>) {
public operator fun <T> MutableCollection<in T>.plusAssign(array: Array<T>) {
this.addAll(array)
}
/**
* Adds all elements of the given [sequence] to this mutable collection.
*/
public fun <T> MutableCollection<in T>.plusAssign(sequence: Sequence<T>) {
public operator fun <T> MutableCollection<in T>.plusAssign(sequence: Sequence<T>) {
this.addAll(sequence)
}
/**
* Removes a single instance of the specified [element] from this mutable collection.
*/
public fun <T> MutableCollection<in T>.minusAssign(element: T) {
public operator fun <T> MutableCollection<in T>.minusAssign(element: T) {
this.remove(element)
}
/**
* Removes all elements contained in the given [collection] from this mutable collection.
*/
public fun <T> MutableCollection<in T>.minusAssign(collection: Iterable<T>) {
public operator fun <T> MutableCollection<in T>.minusAssign(collection: Iterable<T>) {
this.removeAll(collection)
}
/**
* Removes all elements contained in the given [array] from this mutable collection.
*/
public fun <T> MutableCollection<in T>.minusAssign(array: Array<T>) {
public operator fun <T> MutableCollection<in T>.minusAssign(array: Array<T>) {
this.removeAll(array)
}
/**
* Removes all elements contained in the given [sequence] from this mutable collection.
*/
public fun <T> MutableCollection<in T>.minusAssign(sequence: Sequence<T>) {
public operator fun <T> MutableCollection<in T>.minusAssign(sequence: Sequence<T>) {
this.removeAll(sequence)
}
@@ -13,7 +13,7 @@ public interface Sequence<out T> {
/**
* Returns an iterator that returns the values from the sequence.
*/
public fun iterator(): Iterator<T>
public operator fun iterator(): Iterator<T>
}
/**
@@ -109,7 +109,7 @@ public inline fun <T: Any> ThreadLocal<T>.getOrSet(default: () -> T): T {
* execute the given block on the [Executor].
*/
@Deprecated("Use Executor.execute(Runnable) instead.") // do not specify ReplaceWith("execute(action)") due to KT-8597
public fun Executor.invoke(action: () -> Unit) {
public operator fun Executor.invoke(action: () -> Unit) {
execute(action)
}
@@ -118,6 +118,6 @@ public fun Executor.invoke(action: () -> Unit) {
* execute the given block on the [ExecutorService].
*/
@Deprecated("Use ExecutorService.submit(Callable) instead.") // do not specify ReplaceWith("submit(action)") due to KT-8597
public fun <T> ExecutorService.invoke(action: () -> T): Future<T> {
public operator fun <T> ExecutorService.invoke(action: () -> T): Future<T> {
return submit(action)
}
+5 -5
View File
@@ -116,7 +116,7 @@ public fun NodeList?.toElementList(): List<Element> {
}
/** Searches for elements using the element name, an element ID (if prefixed with dot) or element class (if prefixed with #) */
public fun Document?.get(selector: String): List<Element> {
public operator fun Document?.get(selector: String): List<Element> {
val root = this?.documentElement
return if (root != null) {
if (selector == "*") {
@@ -140,7 +140,7 @@ public fun Document?.get(selector: String): List<Element> {
}
/** Searches for elements using the element name, an element ID (if prefixed with dot) or element class (if prefixed with #) */
public fun Element.get(selector: String): List<Element> {
public operator fun Element.get(selector: String): List<Element> {
return if (selector == "*") {
elements
} else if (selector.startsWith(".")) {
@@ -319,16 +319,16 @@ public fun nodesToXmlString(nodes: Iterable<Node>, xmlDeclaration: Boolean = fal
// Syntax sugar
public fun Node.plus(child: Node?): Node {
public operator fun Node.plus(child: Node?): Node {
if (child != null) {
this.appendChild(child)
}
return this
}
public fun Element.plus(text: String?): Element = this.addText(text)
public operator fun Element.plus(text: String?): Element = this.addText(text)
public fun Element.plusAssign(text: String?): Element = this.addText(text)
public operator fun Element.plusAssign(text: String?): Element = this.addText(text)
// Builder
+11 -11
View File
@@ -6,55 +6,55 @@ import java.math.BigInteger
/**
* Enables the use of the `+` operator for [BigInteger] instances.
*/
public fun BigInteger.plus(other: BigInteger) : BigInteger = this.add(other)
public operator fun BigInteger.plus(other: BigInteger) : BigInteger = this.add(other)
/**
* Enables the use of the `-` operator for [BigInteger] instances.
*/
public fun BigInteger.minus(other: BigInteger) : BigInteger = this.subtract(other)
public operator fun BigInteger.minus(other: BigInteger) : BigInteger = this.subtract(other)
/**
* Enables the use of the `*` operator for [BigInteger] instances.
*/
public fun BigInteger.times(other: BigInteger) : BigInteger = this.multiply(other)
public operator fun BigInteger.times(other: BigInteger) : BigInteger = this.multiply(other)
/**
* Enables the use of the `/` operator for [BigInteger] instances.
*/
public fun BigInteger.div(other: BigInteger) : BigInteger = this.divide(other)
public operator fun BigInteger.div(other: BigInteger) : BigInteger = this.divide(other)
/**
* Enables the use of the unary `-` operator for [BigInteger] instances.
*/
public fun BigInteger.minus() : BigInteger = this.negate()
public operator fun BigInteger.minus() : BigInteger = this.negate()
/**
* Enables the use of the `+` operator for [BigDecimal] instances.
*/
public fun BigDecimal.plus(other: BigDecimal) : BigDecimal = this.add(other)
public operator fun BigDecimal.plus(other: BigDecimal) : BigDecimal = this.add(other)
/**
* Enables the use of the `-` operator for [BigDecimal] instances.
*/
public fun BigDecimal.minus(other: BigDecimal) : BigDecimal = this.subtract(other)
public operator fun BigDecimal.minus(other: BigDecimal) : BigDecimal = this.subtract(other)
/**
* Enables the use of the `*` operator for [BigDecimal] instances.
*/
public fun BigDecimal.times(other: BigDecimal) : BigDecimal = this.multiply(other)
public operator fun BigDecimal.times(other: BigDecimal) : BigDecimal = this.multiply(other)
/**
* Enables the use of the `/` operator for [BigDecimal] instances.
*/
public fun BigDecimal.div(other: BigDecimal) : BigDecimal = this.divide(other)
public operator fun BigDecimal.div(other: BigDecimal) : BigDecimal = this.divide(other)
/**
* Enables the use of the `%` operator for [BigDecimal] instances.
*/
public fun BigDecimal.mod(other: BigDecimal) : BigDecimal = this.remainder(other)
public operator fun BigDecimal.mod(other: BigDecimal) : BigDecimal = this.remainder(other)
/**
* Enables the use of the unary `-` operator for [BigDecimal] instances.
*/
public fun BigDecimal.minus() : BigDecimal = this.negate()
public operator fun BigDecimal.minus() : BigDecimal = this.negate()
+1 -1
View File
@@ -19,7 +19,7 @@ package kotlin
/**
* Concatenates this Char and a String.
*/
public fun Char.plus(string: String) : String = this.toString() + string
public operator fun Char.plus(string: String) : String = this.toString() + string
/**
* Returns `true` if this character is equal to the [other] character, optionally ignoring character case.
+3 -3
View File
@@ -215,7 +215,7 @@ public val String.lastIndex: Int
* val c = charSequence[5]
* ```
*/
public fun CharSequence.get(index: Int): Char = this.charAt(index)
public operator fun CharSequence.get(index: Int): Char = this.charAt(index)
/**
* Returns `true` if this CharSequence has Unicode surrogate pair at the specified [index].
@@ -779,7 +779,7 @@ public fun String.lastIndexOf(string: String, startIndex: Int = lastIndex, ignor
*
* @param ignoreCase `true` to ignore character case when comparing strings. By default `false`.
*/
public fun String.contains(seq: CharSequence, ignoreCase: Boolean = false): Boolean =
public operator fun String.contains(seq: CharSequence, ignoreCase: Boolean = false): Boolean =
indexOf(seq.toString(), ignoreCase = ignoreCase) >= 0
@@ -788,7 +788,7 @@ public fun String.contains(seq: CharSequence, ignoreCase: Boolean = false): Bool
*
* @param ignoreCase `true` to ignore character case when comparing characters. By default `false`.
*/
public fun String.contains(char: Char, ignoreCase: Boolean = false): Boolean =
public operator fun String.contains(char: Char, ignoreCase: Boolean = false): Boolean =
indexOf(char, ignoreCase = ignoreCase) >= 0
// rangesDelimitedBy
@@ -411,7 +411,7 @@ public fun String.toCharList(): List<Char> = toCharArray().toList()
* @param start the start index (inclusive).
* @param end the end index (exclusive).
*/
public fun CharSequence.get(start: Int, end: Int): CharSequence = subSequence(start, end)
public operator fun CharSequence.get(start: Int, end: Int): CharSequence = subSequence(start, end)
/**
* Encodes the contents of this string using the specified character set and returns the resulting byte array.
@@ -35,7 +35,7 @@ public interface MatchGroupCollection : Collection<MatchGroup?> {
* Groups are indexed from 1 to the count of groups in the regular expression. A group with the index 0
* corresponds to the entire match.
*/
public fun get(index: Int): MatchGroup?
public operator fun get(index: Int): MatchGroup?
// TODO: Provide get(name: String) on JVM 7+
}
@@ -6,6 +6,8 @@ fun elements(): List<GenericFunction> {
val templates = arrayListOf<GenericFunction>()
templates add f("contains(element: T)") {
operator(true)
doc { "Returns `true` if [element] is found in the collection." }
returns("Boolean")
body {
@@ -761,6 +763,7 @@ fun elements(): List<GenericFunction> {
templates addAll (1..5).map { n ->
f("component$n()") {
operator(true)
inline(true)
annotations("""@Suppress("NOTHING_TO_INLINE")""")
fun getOrdinal(n: Int) = n.toString() + when (n) {
@@ -105,6 +105,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp
val inline = FamilyProperty<Boolean>()
val typeParams = ArrayList<String>()
val returns = FamilyProperty<String>()
val operator = FamilyProperty<Boolean>()
val body = object : FamilyProperty<String>() {
override fun onKeySet(key: Family) = include(key)
}
@@ -335,6 +336,8 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp
builder.append("public ")
if (inline[f] == true)
builder.append("inline ")
if (operator[f] == true)
builder.append("operator ")
builder.append("$keyword ")
@@ -6,6 +6,8 @@ fun generators(): List<GenericFunction> {
val templates = arrayListOf<GenericFunction>()
templates add f("plus(element: T)") {
operator(true)
only(Iterables, Collections, Sets, Sequences)
doc { "Returns a list containing all elements of the original collection and then the given [element]." }
returns("List<T>")
@@ -49,6 +51,8 @@ fun generators(): List<GenericFunction> {
}
templates add f("plus(collection: Iterable<T>)") {
operator(true)
only(Iterables, Collections, Sets, Sequences)
doc { "Returns a list containing all elements of the original collection and then all elements of the given [collection]." }
returns("List<T>")
@@ -104,6 +108,8 @@ fun generators(): List<GenericFunction> {
}
templates add f("plus(array: Array<out T>)") {
operator(true)
only(Iterables, Collections, Sets, Sequences)
doc { "Returns a list containing all elements of the original collection and then all elements of the given [array]." }
returns("List<T>")
@@ -151,6 +157,8 @@ fun generators(): List<GenericFunction> {
templates add f("plus(sequence: Sequence<T>)") {
operator(true)
only(Iterables, Sets, Sequences)
doc { "Returns a list containing all elements of the original collection and then all elements of the given [sequence]." }
returns("List<T>")
@@ -199,6 +207,8 @@ fun generators(): List<GenericFunction> {
}
templates add f("minus(element: T)") {
operator(true)
only(Iterables, Sets, Sequences)
doc { "Returns a list containing all elements of the original collection without the first occurrence of the given [element]." }
returns("List<T>")
@@ -236,6 +246,8 @@ fun generators(): List<GenericFunction> {
templates add f("minus(collection: Iterable<T>)") {
operator(true)
only(Iterables, Sets, Sequences)
doc { "Returns a list containing all elements of the original collection except the elements contained in the given [collection]." }
returns("List<T>")
@@ -289,6 +301,8 @@ fun generators(): List<GenericFunction> {
}
templates add f("minus(array: Array<out T>)") {
operator(true)
only(Iterables, Sets, Sequences)
doc { "Returns a list containing all elements of the original collection except the elements contained in the given [array]." }
returns("List<T>")
@@ -331,6 +345,8 @@ fun generators(): List<GenericFunction> {
}
templates add f("minus(sequence: Sequence<T>)") {
operator(true)
only(Iterables, Sets)
doc { "Returns a list containing all elements of the original collection except the elements contained in the given [sequence]." }
returns("List<T>")
@@ -118,6 +118,8 @@ fun ranges(): List<GenericFunction> {
.map { until(it.first, it.second) }
fun contains(rangeType: PrimitiveType, itemType: PrimitiveType) = f("contains(item: $itemType)") {
operator(true)
val meaningless = (rangeType.isNumeric() != itemType.isNumeric())
if (!meaningless) {
only(Ranges)
@@ -6,6 +6,8 @@ fun specialJVM(): List<GenericFunction> {
val templates = arrayListOf<GenericFunction>()
templates add f("plus(element: T)") {
operator(true)
only(InvariantArraysOfObjects, ArraysOfPrimitives)
returns("SELF")
doc { "Returns an array containing all elements of the original array and then the given [element]." }
@@ -20,6 +22,8 @@ fun specialJVM(): List<GenericFunction> {
}
templates add f("plus(collection: Collection<T>)") {
operator(true)
only(InvariantArraysOfObjects, ArraysOfPrimitives)
returns("SELF")
doc { "Returns an array containing all elements of the original array and then all elements of the given [collection]." }
@@ -34,6 +38,8 @@ fun specialJVM(): List<GenericFunction> {
}
templates add f("plus(array: SELF)") {
operator(true)
only(InvariantArraysOfObjects, ArraysOfPrimitives)
customSignature(InvariantArraysOfObjects) { "plus(array: Array<out T>)" }
doc { "Returns an array containing all elements of the original array and then all elements of the given [array]." }