Fix formatting in Engine and templates
This commit is contained in:
committed by
Andrey Breslav
parent
f14ca2cf89
commit
89c1260627
File diff suppressed because it is too large
Load Diff
@@ -10,126 +10,126 @@ import java.util.*
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun <T> Array<out T>.isEmpty() : Boolean {
|
||||
public fun <T> Array<out T>.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun BooleanArray.isEmpty() : Boolean {
|
||||
public fun BooleanArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun ByteArray.isEmpty() : Boolean {
|
||||
public fun ByteArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun CharArray.isEmpty() : Boolean {
|
||||
public fun CharArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun DoubleArray.isEmpty() : Boolean {
|
||||
public fun DoubleArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun FloatArray.isEmpty() : Boolean {
|
||||
public fun FloatArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun IntArray.isEmpty() : Boolean {
|
||||
public fun IntArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun LongArray.isEmpty() : Boolean {
|
||||
public fun LongArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun ShortArray.isEmpty() : Boolean {
|
||||
public fun ShortArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is not empty
|
||||
*/
|
||||
public fun <T> Array<out T>.isNotEmpty() : Boolean {
|
||||
public fun <T> Array<out T>.isNotEmpty(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is not empty
|
||||
*/
|
||||
public fun BooleanArray.isNotEmpty() : Boolean {
|
||||
public fun BooleanArray.isNotEmpty(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is not empty
|
||||
*/
|
||||
public fun ByteArray.isNotEmpty() : Boolean {
|
||||
public fun ByteArray.isNotEmpty(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is not empty
|
||||
*/
|
||||
public fun CharArray.isNotEmpty() : Boolean {
|
||||
public fun CharArray.isNotEmpty(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is not empty
|
||||
*/
|
||||
public fun DoubleArray.isNotEmpty() : Boolean {
|
||||
public fun DoubleArray.isNotEmpty(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is not empty
|
||||
*/
|
||||
public fun FloatArray.isNotEmpty() : Boolean {
|
||||
public fun FloatArray.isNotEmpty(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is not empty
|
||||
*/
|
||||
public fun IntArray.isNotEmpty() : Boolean {
|
||||
public fun IntArray.isNotEmpty(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is not empty
|
||||
*/
|
||||
public fun LongArray.isNotEmpty() : Boolean {
|
||||
public fun LongArray.isNotEmpty(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is not empty
|
||||
*/
|
||||
public fun ShortArray.isNotEmpty() : Boolean {
|
||||
public fun ShortArray.isNotEmpty(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -10,52 +10,48 @@ import java.util.*
|
||||
/**
|
||||
* Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements
|
||||
*/
|
||||
public fun <T:Any> Array<T?>.requireNoNulls() : Array<T> {
|
||||
public fun <T : Any> Array<T?>.requireNoNulls(): Array<T> {
|
||||
for (element in this) {
|
||||
if (element == null) {
|
||||
throw IllegalArgumentException("null element found in $this")
|
||||
}
|
||||
}
|
||||
return this as Array<T>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements
|
||||
*/
|
||||
public fun <T:Any> Iterable<T?>.requireNoNulls() : Iterable<T> {
|
||||
public fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> {
|
||||
for (element in this) {
|
||||
if (element == null) {
|
||||
throw IllegalArgumentException("null element found in $this")
|
||||
}
|
||||
}
|
||||
return this as Iterable<T>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements
|
||||
*/
|
||||
public fun <T:Any> List<T?>.requireNoNulls() : List<T> {
|
||||
public fun <T : Any> List<T?>.requireNoNulls(): List<T> {
|
||||
for (element in this) {
|
||||
if (element == null) {
|
||||
throw IllegalArgumentException("null element found in $this")
|
||||
}
|
||||
}
|
||||
return this as List<T>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements
|
||||
*/
|
||||
public fun <T:Any> Stream<T?>.requireNoNulls() : Stream<T> {
|
||||
public fun <T : Any> Stream<T?>.requireNoNulls(): Stream<T> {
|
||||
return FilteringStream(this) {
|
||||
if (it == null) {
|
||||
throw IllegalArgumentException("null element found in $this")
|
||||
}
|
||||
true
|
||||
} as Stream<T>
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,208 +10,192 @@ import java.util.*
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun Iterable<Int>.sum() : Int {
|
||||
public fun Iterable<Int>.sum(): Int {
|
||||
val iterator = iterator()
|
||||
var sum : Int = 0
|
||||
var sum: Int = 0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun Iterable<Long>.sum() : Long {
|
||||
public fun Iterable<Long>.sum(): Long {
|
||||
val iterator = iterator()
|
||||
var sum : Long = 0
|
||||
var sum: Long = 0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun Iterable<Double>.sum() : Double {
|
||||
public fun Iterable<Double>.sum(): Double {
|
||||
val iterator = iterator()
|
||||
var sum : Double = 0.0
|
||||
var sum: Double = 0.0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun Iterable<Float>.sum() : Float {
|
||||
public fun Iterable<Float>.sum(): Float {
|
||||
val iterator = iterator()
|
||||
var sum : Float = 0.0f
|
||||
var sum: Float = 0.0f
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun Array<out Int>.sum() : Int {
|
||||
public fun Array<out Int>.sum(): Int {
|
||||
val iterator = iterator()
|
||||
var sum : Int = 0
|
||||
var sum: Int = 0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun IntArray.sum() : Int {
|
||||
public fun IntArray.sum(): Int {
|
||||
val iterator = iterator()
|
||||
var sum : Int = 0
|
||||
var sum: Int = 0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun Array<out Long>.sum() : Long {
|
||||
public fun Array<out Long>.sum(): Long {
|
||||
val iterator = iterator()
|
||||
var sum : Long = 0
|
||||
var sum: Long = 0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun LongArray.sum() : Long {
|
||||
public fun LongArray.sum(): Long {
|
||||
val iterator = iterator()
|
||||
var sum : Long = 0
|
||||
var sum: Long = 0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun Array<out Byte>.sum() : Int {
|
||||
public fun Array<out Byte>.sum(): Int {
|
||||
val iterator = iterator()
|
||||
var sum : Int = 0
|
||||
var sum: Int = 0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun ByteArray.sum() : Int {
|
||||
public fun ByteArray.sum(): Int {
|
||||
val iterator = iterator()
|
||||
var sum : Int = 0
|
||||
var sum: Int = 0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun Array<out Short>.sum() : Int {
|
||||
public fun Array<out Short>.sum(): Int {
|
||||
val iterator = iterator()
|
||||
var sum : Int = 0
|
||||
var sum: Int = 0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun ShortArray.sum() : Int {
|
||||
public fun ShortArray.sum(): Int {
|
||||
val iterator = iterator()
|
||||
var sum : Int = 0
|
||||
var sum: Int = 0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun Array<out Double>.sum() : Double {
|
||||
public fun Array<out Double>.sum(): Double {
|
||||
val iterator = iterator()
|
||||
var sum : Double = 0.0
|
||||
var sum: Double = 0.0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun DoubleArray.sum() : Double {
|
||||
public fun DoubleArray.sum(): Double {
|
||||
val iterator = iterator()
|
||||
var sum : Double = 0.0
|
||||
var sum: Double = 0.0
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun Array<out Float>.sum() : Float {
|
||||
public fun Array<out Float>.sum(): Float {
|
||||
val iterator = iterator()
|
||||
var sum : Float = 0.0f
|
||||
var sum: Float = 0.0f
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all elements in the collection
|
||||
*/
|
||||
public fun FloatArray.sum() : Float {
|
||||
public fun FloatArray.sum(): Float {
|
||||
val iterator = iterator()
|
||||
var sum : Float = 0.0f
|
||||
var sum: Float = 0.0f
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,193 +10,174 @@ import java.util.*
|
||||
/**
|
||||
* Returns a list with elements in reversed order
|
||||
*/
|
||||
public fun <T> Array<out T>.reverse() : List<T> {
|
||||
public fun <T> Array<out T>.reverse(): List<T> {
|
||||
val list = toArrayList()
|
||||
Collections.reverse(list)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with elements in reversed order
|
||||
*/
|
||||
public fun BooleanArray.reverse() : List<Boolean> {
|
||||
public fun BooleanArray.reverse(): List<Boolean> {
|
||||
val list = toArrayList()
|
||||
Collections.reverse(list)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with elements in reversed order
|
||||
*/
|
||||
public fun ByteArray.reverse() : List<Byte> {
|
||||
public fun ByteArray.reverse(): List<Byte> {
|
||||
val list = toArrayList()
|
||||
Collections.reverse(list)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with elements in reversed order
|
||||
*/
|
||||
public fun CharArray.reverse() : List<Char> {
|
||||
public fun CharArray.reverse(): List<Char> {
|
||||
val list = toArrayList()
|
||||
Collections.reverse(list)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with elements in reversed order
|
||||
*/
|
||||
public fun DoubleArray.reverse() : List<Double> {
|
||||
public fun DoubleArray.reverse(): List<Double> {
|
||||
val list = toArrayList()
|
||||
Collections.reverse(list)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with elements in reversed order
|
||||
*/
|
||||
public fun FloatArray.reverse() : List<Float> {
|
||||
public fun FloatArray.reverse(): List<Float> {
|
||||
val list = toArrayList()
|
||||
Collections.reverse(list)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with elements in reversed order
|
||||
*/
|
||||
public fun IntArray.reverse() : List<Int> {
|
||||
public fun IntArray.reverse(): List<Int> {
|
||||
val list = toArrayList()
|
||||
Collections.reverse(list)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with elements in reversed order
|
||||
*/
|
||||
public fun LongArray.reverse() : List<Long> {
|
||||
public fun LongArray.reverse(): List<Long> {
|
||||
val list = toArrayList()
|
||||
Collections.reverse(list)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with elements in reversed order
|
||||
*/
|
||||
public fun ShortArray.reverse() : List<Short> {
|
||||
public fun ShortArray.reverse(): List<Short> {
|
||||
val list = toArrayList()
|
||||
Collections.reverse(list)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with elements in reversed order
|
||||
*/
|
||||
public fun <T> Iterable<T>.reverse() : List<T> {
|
||||
public fun <T> Iterable<T>.reverse(): List<T> {
|
||||
val list = toArrayList()
|
||||
Collections.reverse(list)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string with characters in reversed order
|
||||
*/
|
||||
public fun String.reverse() : String {
|
||||
public fun String.reverse(): String {
|
||||
return StringBuilder().append(this).reverse().toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun <T: Comparable<T>> Iterable<T>.sort() : List<T> {
|
||||
public fun <T : Comparable<T>> Iterable<T>.sort(): List<T> {
|
||||
val sortedList = toArrayList()
|
||||
java.util.Collections.sort(sortedList)
|
||||
return sortedList
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all elements, sorted by the specified *comparator*
|
||||
*/
|
||||
public fun <T> Array<out T>.sortBy(comparator : Comparator<T>) : List<T> {
|
||||
public fun <T> Array<out T>.sortBy(comparator: Comparator<T>): List<T> {
|
||||
val sortedList = toArrayList()
|
||||
java.util.Collections.sort(sortedList, comparator)
|
||||
return sortedList
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all elements, sorted by the specified *comparator*
|
||||
*/
|
||||
public fun <T> Iterable<T>.sortBy(comparator : Comparator<T>) : List<T> {
|
||||
public fun <T> Iterable<T>.sortBy(comparator: Comparator<T>): List<T> {
|
||||
val sortedList = toArrayList()
|
||||
java.util.Collections.sort(sortedList, comparator)
|
||||
return sortedList
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all elements, sorted by results of specified *order* function.
|
||||
*/
|
||||
public inline fun <T, R: Comparable<R>> Array<out T>.sortBy(order: (T) -> R) : List<T> {
|
||||
public inline fun <T, R : Comparable<R>> Array<out T>.sortBy(order: (T) -> R): List<T> {
|
||||
val sortedList = toArrayList()
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> order(x).compareTo(order(y))}
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> order(x).compareTo(order(y)) }
|
||||
java.util.Collections.sort(sortedList, sortBy)
|
||||
return sortedList
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all elements, sorted by results of specified *order* function.
|
||||
*/
|
||||
public inline fun <T, R: Comparable<R>> Iterable<T>.sortBy(order: (T) -> R) : List<T> {
|
||||
public inline fun <T, R : Comparable<R>> Iterable<T>.sortBy(order: (T) -> R): List<T> {
|
||||
val sortedList = toArrayList()
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> order(x).compareTo(order(y))}
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> order(x).compareTo(order(y)) }
|
||||
java.util.Collections.sort(sortedList, sortBy)
|
||||
return sortedList
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun <T: Comparable<T>> Iterable<T>.sortDescending() : List<T> {
|
||||
public fun <T : Comparable<T>> Iterable<T>.sortDescending(): List<T> {
|
||||
val sortedList = toArrayList()
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -x.compareTo(y)}
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -x.compareTo(y) }
|
||||
java.util.Collections.sort(sortedList, sortBy)
|
||||
return sortedList
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all elements, sorted by results of specified *order* function.
|
||||
*/
|
||||
public inline fun <T, R: Comparable<R>> Array<out T>.sortDescendingBy(order: (T) -> R) : List<T> {
|
||||
public inline fun <T, R : Comparable<R>> Array<out T>.sortDescendingBy(order: (T) -> R): List<T> {
|
||||
val sortedList = toArrayList()
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -order(x).compareTo(order(y))}
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -order(x).compareTo(order(y)) }
|
||||
java.util.Collections.sort(sortedList, sortBy)
|
||||
return sortedList
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all elements, sorted by results of specified *order* function.
|
||||
*/
|
||||
public inline fun <T, R: Comparable<R>> Iterable<T>.sortDescendingBy(order: (T) -> R) : List<T> {
|
||||
public inline fun <T, R : Comparable<R>> Iterable<T>.sortDescendingBy(order: (T) -> R): List<T> {
|
||||
val sortedList = toArrayList()
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -order(x).compareTo(order(y))}
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -order(x).compareTo(order(y)) }
|
||||
java.util.Collections.sort(sortedList, sortBy)
|
||||
return sortedList
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,771 +10,742 @@ import java.util.*
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun <T> Array<out T>.toArrayList() : ArrayList<T> {
|
||||
public fun <T> Array<out T>.toArrayList(): ArrayList<T> {
|
||||
val list = ArrayList<T>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun BooleanArray.toArrayList() : ArrayList<Boolean> {
|
||||
public fun BooleanArray.toArrayList(): ArrayList<Boolean> {
|
||||
val list = ArrayList<Boolean>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun ByteArray.toArrayList() : ArrayList<Byte> {
|
||||
public fun ByteArray.toArrayList(): ArrayList<Byte> {
|
||||
val list = ArrayList<Byte>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun CharArray.toArrayList() : ArrayList<Char> {
|
||||
public fun CharArray.toArrayList(): ArrayList<Char> {
|
||||
val list = ArrayList<Char>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun DoubleArray.toArrayList() : ArrayList<Double> {
|
||||
public fun DoubleArray.toArrayList(): ArrayList<Double> {
|
||||
val list = ArrayList<Double>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun FloatArray.toArrayList() : ArrayList<Float> {
|
||||
public fun FloatArray.toArrayList(): ArrayList<Float> {
|
||||
val list = ArrayList<Float>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun IntArray.toArrayList() : ArrayList<Int> {
|
||||
public fun IntArray.toArrayList(): ArrayList<Int> {
|
||||
val list = ArrayList<Int>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun LongArray.toArrayList() : ArrayList<Long> {
|
||||
public fun LongArray.toArrayList(): ArrayList<Long> {
|
||||
val list = ArrayList<Long>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun ShortArray.toArrayList() : ArrayList<Short> {
|
||||
public fun ShortArray.toArrayList(): ArrayList<Short> {
|
||||
val list = ArrayList<Short>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun <T> Iterable<T>.toArrayList() : ArrayList<T> {
|
||||
public fun <T> Iterable<T>.toArrayList(): ArrayList<T> {
|
||||
return toCollection(ArrayList<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun <T> Stream<T>.toArrayList() : ArrayList<T> {
|
||||
public fun <T> Stream<T>.toArrayList(): ArrayList<T> {
|
||||
return toCollection(ArrayList<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun String.toArrayList() : ArrayList<Char> {
|
||||
public fun String.toArrayList(): ArrayList<Char> {
|
||||
return toCollection(ArrayList<Char>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <T, C : MutableCollection<in T>> Array<out T>.toCollection(collection : C) : C {
|
||||
public fun <T, C : MutableCollection<in T>> Array<out T>.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <C : MutableCollection<in Boolean>> BooleanArray.toCollection(collection : C) : C {
|
||||
public fun <C : MutableCollection<in Boolean>> BooleanArray.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <C : MutableCollection<in Byte>> ByteArray.toCollection(collection : C) : C {
|
||||
public fun <C : MutableCollection<in Byte>> ByteArray.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <C : MutableCollection<in Char>> CharArray.toCollection(collection : C) : C {
|
||||
public fun <C : MutableCollection<in Char>> CharArray.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <C : MutableCollection<in Double>> DoubleArray.toCollection(collection : C) : C {
|
||||
public fun <C : MutableCollection<in Double>> DoubleArray.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <C : MutableCollection<in Float>> FloatArray.toCollection(collection : C) : C {
|
||||
public fun <C : MutableCollection<in Float>> FloatArray.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <C : MutableCollection<in Int>> IntArray.toCollection(collection : C) : C {
|
||||
public fun <C : MutableCollection<in Int>> IntArray.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <C : MutableCollection<in Long>> LongArray.toCollection(collection : C) : C {
|
||||
public fun <C : MutableCollection<in Long>> LongArray.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <C : MutableCollection<in Short>> ShortArray.toCollection(collection : C) : C {
|
||||
public fun <C : MutableCollection<in Short>> ShortArray.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(collection : C) : C {
|
||||
public fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <T, C : MutableCollection<in T>> Stream<T>.toCollection(collection : C) : C {
|
||||
public fun <T, C : MutableCollection<in T>> Stream<T>.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given *collection*
|
||||
*/
|
||||
public fun <C : MutableCollection<in Char>> String.toCollection(collection : C) : C {
|
||||
public fun <C : MutableCollection<in Char>> String.toCollection(collection: C): C {
|
||||
for (item in this) {
|
||||
collection.add(item)
|
||||
}
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun <T> Array<out T>.toHashSet() : HashSet<T> {
|
||||
public fun <T> Array<out T>.toHashSet(): HashSet<T> {
|
||||
return toCollection(HashSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun BooleanArray.toHashSet() : HashSet<Boolean> {
|
||||
public fun BooleanArray.toHashSet(): HashSet<Boolean> {
|
||||
return toCollection(HashSet<Boolean>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun ByteArray.toHashSet() : HashSet<Byte> {
|
||||
public fun ByteArray.toHashSet(): HashSet<Byte> {
|
||||
return toCollection(HashSet<Byte>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun CharArray.toHashSet() : HashSet<Char> {
|
||||
public fun CharArray.toHashSet(): HashSet<Char> {
|
||||
return toCollection(HashSet<Char>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun DoubleArray.toHashSet() : HashSet<Double> {
|
||||
public fun DoubleArray.toHashSet(): HashSet<Double> {
|
||||
return toCollection(HashSet<Double>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun FloatArray.toHashSet() : HashSet<Float> {
|
||||
public fun FloatArray.toHashSet(): HashSet<Float> {
|
||||
return toCollection(HashSet<Float>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun IntArray.toHashSet() : HashSet<Int> {
|
||||
public fun IntArray.toHashSet(): HashSet<Int> {
|
||||
return toCollection(HashSet<Int>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun LongArray.toHashSet() : HashSet<Long> {
|
||||
public fun LongArray.toHashSet(): HashSet<Long> {
|
||||
return toCollection(HashSet<Long>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun ShortArray.toHashSet() : HashSet<Short> {
|
||||
public fun ShortArray.toHashSet(): HashSet<Short> {
|
||||
return toCollection(HashSet<Short>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun <T> Iterable<T>.toHashSet() : HashSet<T> {
|
||||
public fun <T> Iterable<T>.toHashSet(): HashSet<T> {
|
||||
return toCollection(HashSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun <T> Stream<T>.toHashSet() : HashSet<T> {
|
||||
public fun <T> Stream<T>.toHashSet(): HashSet<T> {
|
||||
return toCollection(HashSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet of all elements
|
||||
*/
|
||||
public fun String.toHashSet() : HashSet<Char> {
|
||||
public fun String.toHashSet(): HashSet<Char> {
|
||||
return toCollection(HashSet<Char>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun <T> Array<out T>.toLinkedList() : LinkedList<T> {
|
||||
public fun <T> Array<out T>.toLinkedList(): LinkedList<T> {
|
||||
return toCollection(LinkedList<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun BooleanArray.toLinkedList() : LinkedList<Boolean> {
|
||||
public fun BooleanArray.toLinkedList(): LinkedList<Boolean> {
|
||||
return toCollection(LinkedList<Boolean>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun ByteArray.toLinkedList() : LinkedList<Byte> {
|
||||
public fun ByteArray.toLinkedList(): LinkedList<Byte> {
|
||||
return toCollection(LinkedList<Byte>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun CharArray.toLinkedList() : LinkedList<Char> {
|
||||
public fun CharArray.toLinkedList(): LinkedList<Char> {
|
||||
return toCollection(LinkedList<Char>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun DoubleArray.toLinkedList() : LinkedList<Double> {
|
||||
public fun DoubleArray.toLinkedList(): LinkedList<Double> {
|
||||
return toCollection(LinkedList<Double>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun FloatArray.toLinkedList() : LinkedList<Float> {
|
||||
public fun FloatArray.toLinkedList(): LinkedList<Float> {
|
||||
return toCollection(LinkedList<Float>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun IntArray.toLinkedList() : LinkedList<Int> {
|
||||
public fun IntArray.toLinkedList(): LinkedList<Int> {
|
||||
return toCollection(LinkedList<Int>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun LongArray.toLinkedList() : LinkedList<Long> {
|
||||
public fun LongArray.toLinkedList(): LinkedList<Long> {
|
||||
return toCollection(LinkedList<Long>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun ShortArray.toLinkedList() : LinkedList<Short> {
|
||||
public fun ShortArray.toLinkedList(): LinkedList<Short> {
|
||||
return toCollection(LinkedList<Short>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun <T> Iterable<T>.toLinkedList() : LinkedList<T> {
|
||||
public fun <T> Iterable<T>.toLinkedList(): LinkedList<T> {
|
||||
return toCollection(LinkedList<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun <T> Stream<T>.toLinkedList() : LinkedList<T> {
|
||||
public fun <T> Stream<T>.toLinkedList(): LinkedList<T> {
|
||||
return toCollection(LinkedList<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a LinkedList containing all elements
|
||||
*/
|
||||
public fun String.toLinkedList() : LinkedList<Char> {
|
||||
public fun String.toLinkedList(): LinkedList<Char> {
|
||||
return toCollection(LinkedList<Char>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun <T> Array<out T>.toList() : List<T> {
|
||||
public fun <T> Array<out T>.toList(): List<T> {
|
||||
return toCollection(ArrayList<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun BooleanArray.toList() : List<Boolean> {
|
||||
public fun BooleanArray.toList(): List<Boolean> {
|
||||
val list = ArrayList<Boolean>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun ByteArray.toList() : List<Byte> {
|
||||
public fun ByteArray.toList(): List<Byte> {
|
||||
val list = ArrayList<Byte>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun CharArray.toList() : List<Char> {
|
||||
public fun CharArray.toList(): List<Char> {
|
||||
val list = ArrayList<Char>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun DoubleArray.toList() : List<Double> {
|
||||
public fun DoubleArray.toList(): List<Double> {
|
||||
val list = ArrayList<Double>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun FloatArray.toList() : List<Float> {
|
||||
public fun FloatArray.toList(): List<Float> {
|
||||
val list = ArrayList<Float>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun IntArray.toList() : List<Int> {
|
||||
public fun IntArray.toList(): List<Int> {
|
||||
val list = ArrayList<Int>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun LongArray.toList() : List<Long> {
|
||||
public fun LongArray.toList(): List<Long> {
|
||||
val list = ArrayList<Long>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun ShortArray.toList() : List<Short> {
|
||||
public fun ShortArray.toList(): List<Short> {
|
||||
val list = ArrayList<Short>(size)
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun <T> Iterable<T>.toList() : List<T> {
|
||||
public fun <T> Iterable<T>.toList(): List<T> {
|
||||
return toCollection(ArrayList<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun <T> Stream<T>.toList() : List<T> {
|
||||
public fun <T> Stream<T>.toList(): List<T> {
|
||||
return toCollection(ArrayList<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun String.toList() : List<Char> {
|
||||
public fun String.toList(): List<Char> {
|
||||
return toCollection(ArrayList<Char>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun <T> Array<out T>.toSet() : Set<T> {
|
||||
public fun <T> Array<out T>.toSet(): Set<T> {
|
||||
return toCollection(LinkedHashSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun BooleanArray.toSet() : Set<Boolean> {
|
||||
public fun BooleanArray.toSet(): Set<Boolean> {
|
||||
return toCollection(LinkedHashSet<Boolean>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun ByteArray.toSet() : Set<Byte> {
|
||||
public fun ByteArray.toSet(): Set<Byte> {
|
||||
return toCollection(LinkedHashSet<Byte>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun CharArray.toSet() : Set<Char> {
|
||||
public fun CharArray.toSet(): Set<Char> {
|
||||
return toCollection(LinkedHashSet<Char>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun DoubleArray.toSet() : Set<Double> {
|
||||
public fun DoubleArray.toSet(): Set<Double> {
|
||||
return toCollection(LinkedHashSet<Double>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun FloatArray.toSet() : Set<Float> {
|
||||
public fun FloatArray.toSet(): Set<Float> {
|
||||
return toCollection(LinkedHashSet<Float>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun IntArray.toSet() : Set<Int> {
|
||||
public fun IntArray.toSet(): Set<Int> {
|
||||
return toCollection(LinkedHashSet<Int>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun LongArray.toSet() : Set<Long> {
|
||||
public fun LongArray.toSet(): Set<Long> {
|
||||
return toCollection(LinkedHashSet<Long>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun ShortArray.toSet() : Set<Short> {
|
||||
public fun ShortArray.toSet(): Set<Short> {
|
||||
return toCollection(LinkedHashSet<Short>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun <T> Iterable<T>.toSet() : Set<T> {
|
||||
public fun <T> Iterable<T>.toSet(): Set<T> {
|
||||
return toCollection(LinkedHashSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun <T> Stream<T>.toSet() : Set<T> {
|
||||
public fun <T> Stream<T>.toSet(): Set<T> {
|
||||
return toCollection(LinkedHashSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of all elements
|
||||
*/
|
||||
public fun String.toSet() : Set<Char> {
|
||||
public fun String.toSet(): Set<Char> {
|
||||
return toCollection(LinkedHashSet<Char>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun <T: Comparable<T>> Array<out T>.toSortedList() : List<T> {
|
||||
public fun <T : Comparable<T>> Array<out T>.toSortedList(): List<T> {
|
||||
return toArrayList().sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun BooleanArray.toSortedList() : List<Boolean> {
|
||||
public fun BooleanArray.toSortedList(): List<Boolean> {
|
||||
return toArrayList().sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun ByteArray.toSortedList() : List<Byte> {
|
||||
public fun ByteArray.toSortedList(): List<Byte> {
|
||||
return toArrayList().sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun CharArray.toSortedList() : List<Char> {
|
||||
public fun CharArray.toSortedList(): List<Char> {
|
||||
return toArrayList().sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun DoubleArray.toSortedList() : List<Double> {
|
||||
public fun DoubleArray.toSortedList(): List<Double> {
|
||||
return toArrayList().sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun FloatArray.toSortedList() : List<Float> {
|
||||
public fun FloatArray.toSortedList(): List<Float> {
|
||||
return toArrayList().sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun IntArray.toSortedList() : List<Int> {
|
||||
public fun IntArray.toSortedList(): List<Int> {
|
||||
return toArrayList().sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun LongArray.toSortedList() : List<Long> {
|
||||
public fun LongArray.toSortedList(): List<Long> {
|
||||
return toArrayList().sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun ShortArray.toSortedList() : List<Short> {
|
||||
public fun ShortArray.toSortedList(): List<Short> {
|
||||
return toArrayList().sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun <T: Comparable<T>> Iterable<T>.toSortedList() : List<T> {
|
||||
public fun <T : Comparable<T>> Iterable<T>.toSortedList(): List<T> {
|
||||
return sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun <T: Comparable<T>> Stream<T>.toSortedList() : List<T> {
|
||||
public fun <T : Comparable<T>> Stream<T>.toSortedList(): List<T> {
|
||||
return toArrayList().sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted list of all elements
|
||||
*/
|
||||
public fun String.toSortedList() : List<Char> {
|
||||
public fun String.toSortedList(): List<Char> {
|
||||
return toArrayList().sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun <T> Array<out T>.toSortedSet() : SortedSet<T> {
|
||||
public fun <T> Array<out T>.toSortedSet(): SortedSet<T> {
|
||||
return toCollection(TreeSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun BooleanArray.toSortedSet() : SortedSet<Boolean> {
|
||||
public fun BooleanArray.toSortedSet(): SortedSet<Boolean> {
|
||||
return toCollection(TreeSet<Boolean>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun ByteArray.toSortedSet() : SortedSet<Byte> {
|
||||
public fun ByteArray.toSortedSet(): SortedSet<Byte> {
|
||||
return toCollection(TreeSet<Byte>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun CharArray.toSortedSet() : SortedSet<Char> {
|
||||
public fun CharArray.toSortedSet(): SortedSet<Char> {
|
||||
return toCollection(TreeSet<Char>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun DoubleArray.toSortedSet() : SortedSet<Double> {
|
||||
public fun DoubleArray.toSortedSet(): SortedSet<Double> {
|
||||
return toCollection(TreeSet<Double>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun FloatArray.toSortedSet() : SortedSet<Float> {
|
||||
public fun FloatArray.toSortedSet(): SortedSet<Float> {
|
||||
return toCollection(TreeSet<Float>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun IntArray.toSortedSet() : SortedSet<Int> {
|
||||
public fun IntArray.toSortedSet(): SortedSet<Int> {
|
||||
return toCollection(TreeSet<Int>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun LongArray.toSortedSet() : SortedSet<Long> {
|
||||
public fun LongArray.toSortedSet(): SortedSet<Long> {
|
||||
return toCollection(TreeSet<Long>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun ShortArray.toSortedSet() : SortedSet<Short> {
|
||||
public fun ShortArray.toSortedSet(): SortedSet<Short> {
|
||||
return toCollection(TreeSet<Short>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun <T> Iterable<T>.toSortedSet() : SortedSet<T> {
|
||||
public fun <T> Iterable<T>.toSortedSet(): SortedSet<T> {
|
||||
return toCollection(TreeSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun <T> Stream<T>.toSortedSet() : SortedSet<T> {
|
||||
public fun <T> Stream<T>.toSortedSet(): SortedSet<T> {
|
||||
return toCollection(TreeSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SortedSet of all elements
|
||||
*/
|
||||
public fun String.toSortedSet() : SortedSet<Char> {
|
||||
public fun String.toSortedSet(): SortedSet<Char> {
|
||||
return toCollection(TreeSet<Char>())
|
||||
}
|
||||
|
||||
|
||||
@@ -10,450 +10,433 @@ import java.util.*
|
||||
/**
|
||||
* Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted.
|
||||
*/
|
||||
public fun <T> Array<out T>.binarySearch(element: T, fromIndex: Int = 0, toIndex: Int = size - 1) : Int {
|
||||
public fun <T> Array<out T>.binarySearch(element: T, fromIndex: Int = 0, toIndex: Int = size - 1): Int {
|
||||
return Arrays.binarySearch(this, fromIndex, toIndex, element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted.
|
||||
*/
|
||||
public fun ByteArray.binarySearch(element: Byte, fromIndex: Int = 0, toIndex: Int = size - 1) : Int {
|
||||
public fun ByteArray.binarySearch(element: Byte, fromIndex: Int = 0, toIndex: Int = size - 1): Int {
|
||||
return Arrays.binarySearch(this, fromIndex, toIndex, element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted.
|
||||
*/
|
||||
public fun CharArray.binarySearch(element: Char, fromIndex: Int = 0, toIndex: Int = size - 1) : Int {
|
||||
public fun CharArray.binarySearch(element: Char, fromIndex: Int = 0, toIndex: Int = size - 1): Int {
|
||||
return Arrays.binarySearch(this, fromIndex, toIndex, element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted.
|
||||
*/
|
||||
public fun DoubleArray.binarySearch(element: Double, fromIndex: Int = 0, toIndex: Int = size - 1) : Int {
|
||||
public fun DoubleArray.binarySearch(element: Double, fromIndex: Int = 0, toIndex: Int = size - 1): Int {
|
||||
return Arrays.binarySearch(this, fromIndex, toIndex, element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted.
|
||||
*/
|
||||
public fun FloatArray.binarySearch(element: Float, fromIndex: Int = 0, toIndex: Int = size - 1) : Int {
|
||||
public fun FloatArray.binarySearch(element: Float, fromIndex: Int = 0, toIndex: Int = size - 1): Int {
|
||||
return Arrays.binarySearch(this, fromIndex, toIndex, element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted.
|
||||
*/
|
||||
public fun IntArray.binarySearch(element: Int, fromIndex: Int = 0, toIndex: Int = size - 1) : Int {
|
||||
public fun IntArray.binarySearch(element: Int, fromIndex: Int = 0, toIndex: Int = size - 1): Int {
|
||||
return Arrays.binarySearch(this, fromIndex, toIndex, element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted.
|
||||
*/
|
||||
public fun LongArray.binarySearch(element: Long, fromIndex: Int = 0, toIndex: Int = size - 1) : Int {
|
||||
public fun LongArray.binarySearch(element: Long, fromIndex: Int = 0, toIndex: Int = size - 1): Int {
|
||||
return Arrays.binarySearch(this, fromIndex, toIndex, element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted.
|
||||
*/
|
||||
public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex: Int = size - 1) : Int {
|
||||
public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex: Int = size - 1): Int {
|
||||
return Arrays.binarySearch(this, fromIndex, toIndex, element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun <T> Array<out T>.copyOf() : Array<T> {
|
||||
public fun <T> Array<out T>.copyOf(): Array<T> {
|
||||
return Arrays.copyOf(this, size) as Array<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun BooleanArray.copyOf() : BooleanArray {
|
||||
public fun BooleanArray.copyOf(): BooleanArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun ByteArray.copyOf() : ByteArray {
|
||||
public fun ByteArray.copyOf(): ByteArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun CharArray.copyOf() : CharArray {
|
||||
public fun CharArray.copyOf(): CharArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun DoubleArray.copyOf() : DoubleArray {
|
||||
public fun DoubleArray.copyOf(): DoubleArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun FloatArray.copyOf() : FloatArray {
|
||||
public fun FloatArray.copyOf(): FloatArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun IntArray.copyOf() : IntArray {
|
||||
public fun IntArray.copyOf(): IntArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun LongArray.copyOf() : LongArray {
|
||||
public fun LongArray.copyOf(): LongArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun ShortArray.copyOf() : ShortArray {
|
||||
public fun ShortArray.copyOf(): ShortArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun <T> Array<out T>.copyOf(newSize: Int) : Array<T?> {
|
||||
public fun <T> Array<out T>.copyOf(newSize: Int): Array<T?> {
|
||||
return Arrays.copyOf(this, newSize) as Array<T?>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun BooleanArray.copyOf(newSize: Int) : BooleanArray {
|
||||
public fun BooleanArray.copyOf(newSize: Int): BooleanArray {
|
||||
return Arrays.copyOf(this, newSize)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun ByteArray.copyOf(newSize: Int) : ByteArray {
|
||||
public fun ByteArray.copyOf(newSize: Int): ByteArray {
|
||||
return Arrays.copyOf(this, newSize)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun CharArray.copyOf(newSize: Int) : CharArray {
|
||||
public fun CharArray.copyOf(newSize: Int): CharArray {
|
||||
return Arrays.copyOf(this, newSize)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun DoubleArray.copyOf(newSize: Int) : DoubleArray {
|
||||
public fun DoubleArray.copyOf(newSize: Int): DoubleArray {
|
||||
return Arrays.copyOf(this, newSize)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun FloatArray.copyOf(newSize: Int) : FloatArray {
|
||||
public fun FloatArray.copyOf(newSize: Int): FloatArray {
|
||||
return Arrays.copyOf(this, newSize)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun IntArray.copyOf(newSize: Int) : IntArray {
|
||||
public fun IntArray.copyOf(newSize: Int): IntArray {
|
||||
return Arrays.copyOf(this, newSize)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun LongArray.copyOf(newSize: Int) : LongArray {
|
||||
public fun LongArray.copyOf(newSize: Int): LongArray {
|
||||
return Arrays.copyOf(this, newSize)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun ShortArray.copyOf(newSize: Int) : ShortArray {
|
||||
public fun ShortArray.copyOf(newSize: Int): ShortArray {
|
||||
return Arrays.copyOf(this, newSize)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array
|
||||
*/
|
||||
public fun <T> Array<out T>.copyOfRange(from: Int, to: Int) : Array<T> {
|
||||
public fun <T> Array<out T>.copyOfRange(from: Int, to: Int): Array<T> {
|
||||
return Arrays.copyOfRange(this, from, to)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array
|
||||
*/
|
||||
public fun BooleanArray.copyOfRange(from: Int, to: Int) : BooleanArray {
|
||||
public fun BooleanArray.copyOfRange(from: Int, to: Int): BooleanArray {
|
||||
return Arrays.copyOfRange(this, from, to)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array
|
||||
*/
|
||||
public fun ByteArray.copyOfRange(from: Int, to: Int) : ByteArray {
|
||||
public fun ByteArray.copyOfRange(from: Int, to: Int): ByteArray {
|
||||
return Arrays.copyOfRange(this, from, to)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array
|
||||
*/
|
||||
public fun CharArray.copyOfRange(from: Int, to: Int) : CharArray {
|
||||
public fun CharArray.copyOfRange(from: Int, to: Int): CharArray {
|
||||
return Arrays.copyOfRange(this, from, to)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array
|
||||
*/
|
||||
public fun DoubleArray.copyOfRange(from: Int, to: Int) : DoubleArray {
|
||||
public fun DoubleArray.copyOfRange(from: Int, to: Int): DoubleArray {
|
||||
return Arrays.copyOfRange(this, from, to)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array
|
||||
*/
|
||||
public fun FloatArray.copyOfRange(from: Int, to: Int) : FloatArray {
|
||||
public fun FloatArray.copyOfRange(from: Int, to: Int): FloatArray {
|
||||
return Arrays.copyOfRange(this, from, to)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array
|
||||
*/
|
||||
public fun IntArray.copyOfRange(from: Int, to: Int) : IntArray {
|
||||
public fun IntArray.copyOfRange(from: Int, to: Int): IntArray {
|
||||
return Arrays.copyOfRange(this, from, to)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array
|
||||
*/
|
||||
public fun LongArray.copyOfRange(from: Int, to: Int) : LongArray {
|
||||
public fun LongArray.copyOfRange(from: Int, to: Int): LongArray {
|
||||
return Arrays.copyOfRange(this, from, to)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array
|
||||
*/
|
||||
public fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray {
|
||||
public fun ShortArray.copyOfRange(from: Int, to: Int): ShortArray {
|
||||
return Arrays.copyOfRange(this, from, to)
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value
|
||||
*/
|
||||
public fun <T> Array<out T>.fill(element: T) : Array<out T> {
|
||||
public fun <T> Array<out T>.fill(element: T): Array<out T> {
|
||||
Arrays.fill(this, element)
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value
|
||||
*/
|
||||
public fun BooleanArray.fill(element: Boolean) : BooleanArray {
|
||||
public fun BooleanArray.fill(element: Boolean): BooleanArray {
|
||||
Arrays.fill(this, element)
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value
|
||||
*/
|
||||
public fun ByteArray.fill(element: Byte) : ByteArray {
|
||||
public fun ByteArray.fill(element: Byte): ByteArray {
|
||||
Arrays.fill(this, element)
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value
|
||||
*/
|
||||
public fun CharArray.fill(element: Char) : CharArray {
|
||||
public fun CharArray.fill(element: Char): CharArray {
|
||||
Arrays.fill(this, element)
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value
|
||||
*/
|
||||
public fun DoubleArray.fill(element: Double) : DoubleArray {
|
||||
public fun DoubleArray.fill(element: Double): DoubleArray {
|
||||
Arrays.fill(this, element)
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value
|
||||
*/
|
||||
public fun FloatArray.fill(element: Float) : FloatArray {
|
||||
public fun FloatArray.fill(element: Float): FloatArray {
|
||||
Arrays.fill(this, element)
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value
|
||||
*/
|
||||
public fun IntArray.fill(element: Int) : IntArray {
|
||||
public fun IntArray.fill(element: Int): IntArray {
|
||||
Arrays.fill(this, element)
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value
|
||||
*/
|
||||
public fun LongArray.fill(element: Long) : LongArray {
|
||||
public fun LongArray.fill(element: Long): LongArray {
|
||||
Arrays.fill(this, element)
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value
|
||||
*/
|
||||
public fun ShortArray.fill(element: Short) : ShortArray {
|
||||
public fun ShortArray.fill(element: Short): ShortArray {
|
||||
Arrays.fill(this, element)
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements that are instances of specified class
|
||||
*/
|
||||
public fun <T, R: T> Array<out T>.filterIsInstance(klass: Class<R>) : List<R> {
|
||||
public fun <T, R : T> Array<out T>.filterIsInstance(klass: Class<R>): List<R> {
|
||||
return filterIsInstanceTo(ArrayList<R>(), klass)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements that are instances of specified class
|
||||
*/
|
||||
public fun <T, R: T> Iterable<T>.filterIsInstance(klass: Class<R>) : List<R> {
|
||||
public fun <T, R : T> Iterable<T>.filterIsInstance(klass: Class<R>): List<R> {
|
||||
return filterIsInstanceTo(ArrayList<R>(), klass)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream containing all elements that are instances of specified class
|
||||
*/
|
||||
public fun <T, R: T> Stream<T>.filterIsInstance(klass: Class<R>) : Stream<T> {
|
||||
public fun <T, R : T> Stream<T>.filterIsInstance(klass: Class<R>): Stream<T> {
|
||||
return FilteringStream(this, true, { klass.isInstance(it) })
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements that are instances of specified class
|
||||
*/
|
||||
public fun <R: Char> String.filterIsInstance(klass: Class<R>) : List<R> {
|
||||
public fun <R : Char> String.filterIsInstance(klass: Class<R>): List<R> {
|
||||
return filterIsInstanceTo(ArrayList<R>(), klass)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are instances of specified class into the given *collection*
|
||||
*/
|
||||
public fun <T, C: MutableCollection<in R>, R: T> Array<out T>.filterIsInstanceTo(collection: C, klass: Class<R>) : C {
|
||||
public fun <T, C : MutableCollection<in R>, R : T> Array<out T>.filterIsInstanceTo(collection: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) collection.add(element as R)
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are instances of specified class into the given *collection*
|
||||
*/
|
||||
public fun <T, C: MutableCollection<in R>, R: T> Iterable<T>.filterIsInstanceTo(collection: C, klass: Class<R>) : C {
|
||||
public fun <T, C : MutableCollection<in R>, R : T> Iterable<T>.filterIsInstanceTo(collection: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) collection.add(element as R)
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are instances of specified class into the given *collection*
|
||||
*/
|
||||
public fun <T, C: MutableCollection<in R>, R: T> Stream<T>.filterIsInstanceTo(collection: C, klass: Class<R>) : C {
|
||||
public fun <T, C : MutableCollection<in R>, R : T> Stream<T>.filterIsInstanceTo(collection: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) collection.add(element as R)
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are instances of specified class into the given *collection*
|
||||
*/
|
||||
public fun <C: MutableCollection<in R>, R: Char> String.filterIsInstanceTo(collection: C, klass: Class<R>) : C {
|
||||
public fun <C : MutableCollection<in R>, R : Char> String.filterIsInstanceTo(collection: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) collection.add(element as R)
|
||||
return collection
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun <T> Array<out T>.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit {
|
||||
public fun <T> Array<out T>.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun ByteArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit {
|
||||
public fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun CharArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit {
|
||||
public fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun DoubleArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit {
|
||||
public fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun FloatArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit {
|
||||
public fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun IntArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit {
|
||||
public fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun LongArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit {
|
||||
public fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun ShortArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit {
|
||||
public fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,96 +10,128 @@ import java.util.*
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun <T> Array<out T>.stream() : Stream<T> {
|
||||
return object : Stream<T> { override fun iterator() : Iterator<T> { return this@stream.iterator() } }
|
||||
|
||||
public fun <T> Array<out T>.stream(): Stream<T> {
|
||||
return object : Stream<T> {
|
||||
override fun iterator(): Iterator<T> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun BooleanArray.stream() : Stream<Boolean> {
|
||||
return object : Stream<Boolean> { override fun iterator() : Iterator<Boolean> { return this@stream.iterator() } }
|
||||
|
||||
public fun BooleanArray.stream(): Stream<Boolean> {
|
||||
return object : Stream<Boolean> {
|
||||
override fun iterator(): Iterator<Boolean> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun ByteArray.stream() : Stream<Byte> {
|
||||
return object : Stream<Byte> { override fun iterator() : Iterator<Byte> { return this@stream.iterator() } }
|
||||
|
||||
public fun ByteArray.stream(): Stream<Byte> {
|
||||
return object : Stream<Byte> {
|
||||
override fun iterator(): Iterator<Byte> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun CharArray.stream() : Stream<Char> {
|
||||
return object : Stream<Char> { override fun iterator() : Iterator<Char> { return this@stream.iterator() } }
|
||||
|
||||
public fun CharArray.stream(): Stream<Char> {
|
||||
return object : Stream<Char> {
|
||||
override fun iterator(): Iterator<Char> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun DoubleArray.stream() : Stream<Double> {
|
||||
return object : Stream<Double> { override fun iterator() : Iterator<Double> { return this@stream.iterator() } }
|
||||
|
||||
public fun DoubleArray.stream(): Stream<Double> {
|
||||
return object : Stream<Double> {
|
||||
override fun iterator(): Iterator<Double> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun FloatArray.stream() : Stream<Float> {
|
||||
return object : Stream<Float> { override fun iterator() : Iterator<Float> { return this@stream.iterator() } }
|
||||
|
||||
public fun FloatArray.stream(): Stream<Float> {
|
||||
return object : Stream<Float> {
|
||||
override fun iterator(): Iterator<Float> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun IntArray.stream() : Stream<Int> {
|
||||
return object : Stream<Int> { override fun iterator() : Iterator<Int> { return this@stream.iterator() } }
|
||||
|
||||
public fun IntArray.stream(): Stream<Int> {
|
||||
return object : Stream<Int> {
|
||||
override fun iterator(): Iterator<Int> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun LongArray.stream() : Stream<Long> {
|
||||
return object : Stream<Long> { override fun iterator() : Iterator<Long> { return this@stream.iterator() } }
|
||||
|
||||
public fun LongArray.stream(): Stream<Long> {
|
||||
return object : Stream<Long> {
|
||||
override fun iterator(): Iterator<Long> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun ShortArray.stream() : Stream<Short> {
|
||||
return object : Stream<Short> { override fun iterator() : Iterator<Short> { return this@stream.iterator() } }
|
||||
|
||||
public fun ShortArray.stream(): Stream<Short> {
|
||||
return object : Stream<Short> {
|
||||
override fun iterator(): Iterator<Short> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun <T> Iterable<T>.stream() : Stream<T> {
|
||||
return object : Stream<T> { override fun iterator() : Iterator<T> { return this@stream.iterator() } }
|
||||
|
||||
public fun <T> Iterable<T>.stream(): Stream<T> {
|
||||
return object : Stream<T> {
|
||||
override fun iterator(): Iterator<T> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun <T> Stream<T>.stream() : Stream<T> {
|
||||
public fun <T> Stream<T>.stream(): Stream<T> {
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun String.stream() : Stream<Char> {
|
||||
return object : Stream<Char> { override fun iterator() : Iterator<Char> { return this@stream.iterator() } }
|
||||
|
||||
public fun String.stream(): Stream<Char> {
|
||||
return object : Stream<Char> {
|
||||
override fun iterator(): Iterator<Char> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.*
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun <T> Array<out T>.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun <T> Array<out T>.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -24,7 +24,6 @@ public fun <T> Array<out T>.appendString(buffer: Appendable, separator: String =
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,7 +31,7 @@ public fun <T> Array<out T>.appendString(buffer: Appendable, separator: String =
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun BooleanArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun BooleanArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -44,7 +43,6 @@ public fun BooleanArray.appendString(buffer: Appendable, separator: String = ",
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +50,7 @@ public fun BooleanArray.appendString(buffer: Appendable, separator: String = ",
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun ByteArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun ByteArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -64,7 +62,6 @@ public fun ByteArray.appendString(buffer: Appendable, separator: String = ", ",
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +69,7 @@ public fun ByteArray.appendString(buffer: Appendable, separator: String = ", ",
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun CharArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun CharArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -84,7 +81,6 @@ public fun CharArray.appendString(buffer: Appendable, separator: String = ", ",
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +88,7 @@ public fun CharArray.appendString(buffer: Appendable, separator: String = ", ",
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun DoubleArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun DoubleArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -104,7 +100,6 @@ public fun DoubleArray.appendString(buffer: Appendable, separator: String = ", "
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +107,7 @@ public fun DoubleArray.appendString(buffer: Appendable, separator: String = ", "
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun FloatArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun FloatArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -124,7 +119,6 @@ public fun FloatArray.appendString(buffer: Appendable, separator: String = ", ",
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +126,7 @@ public fun FloatArray.appendString(buffer: Appendable, separator: String = ", ",
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun IntArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun IntArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -144,7 +138,6 @@ public fun IntArray.appendString(buffer: Appendable, separator: String = ", ", p
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +145,7 @@ public fun IntArray.appendString(buffer: Appendable, separator: String = ", ", p
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun LongArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun LongArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -164,7 +157,6 @@ public fun LongArray.appendString(buffer: Appendable, separator: String = ", ",
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,7 +164,7 @@ public fun LongArray.appendString(buffer: Appendable, separator: String = ", ",
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun ShortArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun ShortArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -184,7 +176,6 @@ public fun ShortArray.appendString(buffer: Appendable, separator: String = ", ",
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +183,7 @@ public fun ShortArray.appendString(buffer: Appendable, separator: String = ", ",
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun <T> Iterable<T>.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun <T> Iterable<T>.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -204,7 +195,6 @@ public fun <T> Iterable<T>.appendString(buffer: Appendable, separator: String =
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +202,7 @@ public fun <T> Iterable<T>.appendString(buffer: Appendable, separator: String =
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun <T> Stream<T>.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun <T> Stream<T>.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -224,7 +214,6 @@ public fun <T> Stream<T>.appendString(buffer: Appendable, separator: String = ",
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,7 +221,7 @@ public fun <T> Stream<T>.appendString(buffer: Appendable, separator: String = ",
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun String.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit {
|
||||
public fun String.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit {
|
||||
buffer.append(prefix)
|
||||
var count = 0
|
||||
for (element in this) {
|
||||
@@ -244,7 +233,6 @@ public fun String.appendString(buffer: Appendable, separator: String = ", ", pre
|
||||
}
|
||||
if (limit >= 0 && count > limit) buffer.append(truncated)
|
||||
buffer.append(postfix)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,11 +240,10 @@ public fun String.appendString(buffer: Appendable, separator: String = ", ", pre
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun <T> Array<out T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun <T> Array<out T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,11 +251,10 @@ public fun <T> Array<out T>.makeString(separator: String = ", ", prefix: String
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun BooleanArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun BooleanArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,11 +262,10 @@ public fun BooleanArray.makeString(separator: String = ", ", prefix: String = ""
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun ByteArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun ByteArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,11 +273,10 @@ public fun ByteArray.makeString(separator: String = ", ", prefix: String = "", p
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun CharArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun CharArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,11 +284,10 @@ public fun CharArray.makeString(separator: String = ", ", prefix: String = "", p
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun DoubleArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun DoubleArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,11 +295,10 @@ public fun DoubleArray.makeString(separator: String = ", ", prefix: String = "",
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun FloatArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun FloatArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,11 +306,10 @@ public fun FloatArray.makeString(separator: String = ", ", prefix: String = "",
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun IntArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun IntArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,11 +317,10 @@ public fun IntArray.makeString(separator: String = ", ", prefix: String = "", po
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun LongArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun LongArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,11 +328,10 @@ public fun LongArray.makeString(separator: String = ", ", prefix: String = "", p
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun ShortArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun ShortArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -360,11 +339,10 @@ public fun ShortArray.makeString(separator: String = ", ", prefix: String = "",
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun <T> Iterable<T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun <T> Iterable<T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -372,11 +350,10 @@ public fun <T> Iterable<T>.makeString(separator: String = ", ", prefix: String =
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun <T> Stream<T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun <T> Stream<T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -384,10 +361,9 @@ public fun <T> Stream<T>.makeString(separator: String = ", ", prefix: String = "
|
||||
* If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will
|
||||
* a special *truncated* separator (which defaults to "..."
|
||||
*/
|
||||
public fun String.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String {
|
||||
public fun String.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@ import templates.Family.*
|
||||
import templates.*
|
||||
import templates.PrimitiveType.*
|
||||
|
||||
fun generateCollectionsAPI(outDir : File) {
|
||||
fun generateCollectionsAPI(outDir: File) {
|
||||
elements().writeTo(File(outDir, "_Elements.kt")) { build() }
|
||||
filtering().writeTo(File(outDir, "_Filtering.kt")) { build() }
|
||||
ordering().writeTo(File(outDir, "_Ordering.kt")) { build() }
|
||||
arrays().writeTo(File(outDir, "_Arrays.kt")) { build() }
|
||||
snapshots().writeTo(File(outDir, "_Snapshots.kt")) { build() }
|
||||
snapshots().writeTo(File(outDir, "_Snapshots.kt")) { build() }
|
||||
mapping().writeTo(File(outDir, "_Mapping.kt")) { build() }
|
||||
aggregates().writeTo(File(outDir, "_Aggregates.kt")) { build() }
|
||||
guards().writeTo(File(outDir, "_Guards.kt")) { build() }
|
||||
@@ -22,11 +22,11 @@ fun generateCollectionsAPI(outDir : File) {
|
||||
numeric().writeTo(File(outDir, "_Numeric.kt")) {
|
||||
val builder = StringBuilder()
|
||||
// TODO: decide if sum for byte and short is needed and how to make it work
|
||||
for(numeric in listOf(Int, Long, /*Byte, Short, */ Double, Float)) {
|
||||
for (numeric in listOf(Int, Long, /*Byte, Short, */ Double, Float)) {
|
||||
build(builder, Iterables, numeric)
|
||||
}
|
||||
|
||||
for(numeric in listOf(Int, Long, Byte, Short, Double, Float)) {
|
||||
for (numeric in listOf(Int, Long, Byte, Short, Double, Float)) {
|
||||
build(builder, ArraysOfObjects, numeric)
|
||||
build(builder, ArraysOfPrimitives, numeric)
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
doc { "Returns the smallest element or null if there are no elements" }
|
||||
returns("T?")
|
||||
exclude(PrimitiveType.Boolean)
|
||||
typeParam("T: Comparable<T>")
|
||||
typeParam("T : Comparable<T>")
|
||||
body {
|
||||
"""
|
||||
val iterator = iterator()
|
||||
@@ -135,8 +135,8 @@ fun aggregates(): List<GenericFunction> {
|
||||
inline(true)
|
||||
|
||||
doc { "Returns the first element yielding the smallest value of the given function or null if there are no elements" }
|
||||
typeParam("R: Comparable<R>")
|
||||
typeParam("T: Any")
|
||||
typeParam("R : Comparable<R>")
|
||||
typeParam("T : Any")
|
||||
returns("T?")
|
||||
body {
|
||||
"""
|
||||
@@ -149,8 +149,8 @@ fun aggregates(): List<GenericFunction> {
|
||||
val e = iterator.next()
|
||||
val v = f(e)
|
||||
if (minValue > v) {
|
||||
minElem = e
|
||||
minValue = v
|
||||
minElem = e
|
||||
minValue = v
|
||||
}
|
||||
}
|
||||
return minElem
|
||||
@@ -166,8 +166,8 @@ fun aggregates(): List<GenericFunction> {
|
||||
val e = this[i]
|
||||
val v = f(e)
|
||||
if (minValue > v) {
|
||||
minElem = e
|
||||
minValue = v
|
||||
minElem = e
|
||||
minValue = v
|
||||
}
|
||||
}
|
||||
return minElem
|
||||
@@ -180,7 +180,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
|
||||
only(Maps)
|
||||
doc { "Returns the first element yielding the smallest value of the given function or null if there are no elements" }
|
||||
typeParam("R: Comparable<R>")
|
||||
typeParam("R : Comparable<R>")
|
||||
returns("T?")
|
||||
body {
|
||||
"""
|
||||
@@ -193,8 +193,8 @@ fun aggregates(): List<GenericFunction> {
|
||||
val e = iterator.next()
|
||||
val v = f(e)
|
||||
if (minValue > v) {
|
||||
minElem = e
|
||||
minValue = v
|
||||
minElem = e
|
||||
minValue = v
|
||||
}
|
||||
}
|
||||
return minElem
|
||||
@@ -206,7 +206,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
doc { "Returns the largest element or null if there are no elements" }
|
||||
returns("T?")
|
||||
exclude(PrimitiveType.Boolean)
|
||||
typeParam("T: Comparable<T>")
|
||||
typeParam("T : Comparable<T>")
|
||||
body {
|
||||
"""
|
||||
val iterator = iterator()
|
||||
@@ -239,8 +239,8 @@ fun aggregates(): List<GenericFunction> {
|
||||
inline(true)
|
||||
|
||||
doc { "Returns the first element yielding the largest value of the given function or null if there are no elements" }
|
||||
typeParam("R: Comparable<R>")
|
||||
typeParam("T: Any")
|
||||
typeParam("R : Comparable<R>")
|
||||
typeParam("T : Any")
|
||||
returns("T?")
|
||||
body {
|
||||
"""
|
||||
@@ -253,8 +253,8 @@ fun aggregates(): List<GenericFunction> {
|
||||
val e = iterator.next()
|
||||
val v = f(e)
|
||||
if (maxValue < v) {
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
}
|
||||
}
|
||||
return maxElem
|
||||
@@ -270,8 +270,8 @@ fun aggregates(): List<GenericFunction> {
|
||||
val e = this[i]
|
||||
val v = f(e)
|
||||
if (maxValue < v) {
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
}
|
||||
}
|
||||
return maxElem
|
||||
@@ -284,7 +284,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
|
||||
only(Maps)
|
||||
doc { "Returns the first element yielding the largest value of the given function or null if there are no elements" }
|
||||
typeParam("R: Comparable<R>")
|
||||
typeParam("R : Comparable<R>")
|
||||
returns("T?")
|
||||
body {
|
||||
"""
|
||||
@@ -297,8 +297,8 @@ fun aggregates(): List<GenericFunction> {
|
||||
val e = iterator.next()
|
||||
val v = f(e)
|
||||
if (maxValue < v) {
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
}
|
||||
}
|
||||
return maxElem
|
||||
|
||||
@@ -116,7 +116,7 @@ fun elements(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("elementAt(index : Int)") {
|
||||
templates add f("elementAt(index: Int)") {
|
||||
doc { "Returns element at given *index*" }
|
||||
returns("T")
|
||||
body {
|
||||
@@ -241,10 +241,12 @@ fun elements(): List<GenericFunction> {
|
||||
body {
|
||||
"""
|
||||
when (this) {
|
||||
is List<*> -> if (size == 0)
|
||||
is List<*> -> {
|
||||
if (size == 0)
|
||||
throw IllegalArgumentException("Collection is empty")
|
||||
else
|
||||
return this[size - 1] as T
|
||||
}
|
||||
else -> {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext())
|
||||
|
||||
@@ -91,7 +91,7 @@ class GenericFunction(val signature: String) : Comparable<GenericFunction> {
|
||||
typeParams.add(t)
|
||||
}
|
||||
|
||||
fun inline(value : Boolean, vararg families: Family) {
|
||||
fun inline(value: Boolean, vararg families: Family) {
|
||||
if (families.isEmpty())
|
||||
defaultInline = value
|
||||
else
|
||||
@@ -148,7 +148,7 @@ class GenericFunction(val signature: String) : Comparable<GenericFunction> {
|
||||
Iterables -> "Iterable<T>"
|
||||
Collections -> "Collection<T>"
|
||||
Lists -> "List<T>"
|
||||
Maps -> "Map<K,V>"
|
||||
Maps -> "Map<K, V>"
|
||||
Streams -> "Stream<T>"
|
||||
ArraysOfObjects -> "Array<T>"
|
||||
Strings -> "String"
|
||||
@@ -186,7 +186,7 @@ class GenericFunction(val signature: String) : Comparable<GenericFunction> {
|
||||
"T" -> {
|
||||
when (f) {
|
||||
Strings -> "Char"
|
||||
Maps -> "Map.Entry<K,V>"
|
||||
Maps -> "Map.Entry<K, V>"
|
||||
else -> primitive?.name() ?: token
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ class GenericFunction(val signature: String) : Comparable<GenericFunction> {
|
||||
fun effectiveTypeParams(): List<String> {
|
||||
val types = ArrayList(typeParams)
|
||||
if (primitive == null && f != Strings) {
|
||||
val implicitTypeParameters = receiver.dropWhile { it != '<' }.drop(1).takeWhile { it != '>' }.split(",")
|
||||
val implicitTypeParameters = receiver.dropWhile { it != '<' }.drop(1).filterNot { it == ' ' }.takeWhile { it != '>' }.split(",")
|
||||
for (implicit in implicitTypeParameters.reverse()) {
|
||||
if (!types.any { it.startsWith(implicit) }) {
|
||||
types.add(0, implicit)
|
||||
@@ -249,18 +249,21 @@ class GenericFunction(val signature: String) : Comparable<GenericFunction> {
|
||||
|
||||
|
||||
builder.append(receiverType)
|
||||
builder.append(".${signature.renderType()} : ${returnType.renderType()} {")
|
||||
builder.append(".${signature.renderType()}: ${returnType.renderType()} {")
|
||||
|
||||
val body = (bodies[f] ?: defaultBody).trim("\n")
|
||||
val prefix: Int = body.takeWhile { it == ' ' }.length
|
||||
val indent: Int = body.takeWhile { it == ' ' }.length
|
||||
|
||||
builder.append('\n')
|
||||
StringReader(body).forEachLine {
|
||||
builder.append('\n')
|
||||
var count = prefix
|
||||
builder.append(" ").append(it.dropWhile { count-- > 0 && it == ' ' } .renderType())
|
||||
var count = indent
|
||||
val line = it.dropWhile { count-- > 0 && it == ' ' } .renderType()
|
||||
if (line.isNotEmpty()) {
|
||||
builder.append(" ").append(line)
|
||||
builder.append("\n")
|
||||
}
|
||||
}
|
||||
|
||||
builder.append("\n}\n\n")
|
||||
builder.append("}\n\n")
|
||||
}
|
||||
|
||||
public override fun compareTo(other: GenericFunction): Int = this.signature.compareTo(other.signature)
|
||||
|
||||
@@ -29,7 +29,7 @@ fun filtering(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
body(Strings) { "return substring(Math.min(n, size))" }
|
||||
returns(Strings) { "String"}
|
||||
returns(Strings) { "String" }
|
||||
|
||||
body(Collections, ArraysOfObjects, ArraysOfPrimitives) {
|
||||
"""
|
||||
@@ -63,7 +63,7 @@ fun filtering(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
body(Strings) { "return substring(0, Math.min(n, size))" }
|
||||
returns(Strings) { "String"}
|
||||
returns(Strings) { "String" }
|
||||
|
||||
doc(Streams) { "Returns a stream containing first *n* elements" }
|
||||
returns(Streams) { "Stream<T>" }
|
||||
@@ -90,7 +90,7 @@ fun filtering(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("dropWhile(predicate: (T)->Boolean)") {
|
||||
templates add f("dropWhile(predicate: (T) -> Boolean)") {
|
||||
inline(true)
|
||||
|
||||
doc { "Returns a list containing all elements except first elements that satisfy the given *predicate*" }
|
||||
@@ -102,7 +102,7 @@ fun filtering(): List<GenericFunction> {
|
||||
for (item in this)
|
||||
if (yielding)
|
||||
list.add(item)
|
||||
else if(!predicate(item)) {
|
||||
else if (!predicate(item)) {
|
||||
list.add(item)
|
||||
yielding = true
|
||||
}
|
||||
@@ -110,7 +110,7 @@ fun filtering(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
|
||||
returns(Strings) { "String"}
|
||||
returns(Strings) { "String" }
|
||||
body(Strings) {
|
||||
"""
|
||||
for (index in 0..length)
|
||||
@@ -128,20 +128,20 @@ fun filtering(): List<GenericFunction> {
|
||||
"""
|
||||
var yielding = false
|
||||
return FilteringStream(this) {
|
||||
if (yielding)
|
||||
true
|
||||
else if (!predicate(it)) {
|
||||
yielding = true
|
||||
true
|
||||
} else
|
||||
false
|
||||
}
|
||||
if (yielding)
|
||||
true
|
||||
else if (!predicate(it)) {
|
||||
yielding = true
|
||||
true
|
||||
} else
|
||||
false
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
templates add f("takeWhile(predicate: (T)->Boolean)") {
|
||||
templates add f("takeWhile(predicate: (T) -> Boolean)") {
|
||||
inline(true)
|
||||
|
||||
doc { "Returns a list containing first elements satisfying the given *predicate*" }
|
||||
@@ -150,15 +150,15 @@ fun filtering(): List<GenericFunction> {
|
||||
"""
|
||||
val list = ArrayList<T>()
|
||||
for (item in this) {
|
||||
if(!predicate(item))
|
||||
if (!predicate(item))
|
||||
break;
|
||||
list.add(item)
|
||||
list.add(item)
|
||||
}
|
||||
return list
|
||||
"""
|
||||
}
|
||||
|
||||
returns(Strings) { "String"}
|
||||
returns(Strings) { "String" }
|
||||
body(Strings) {
|
||||
"""
|
||||
for (index in 0..length)
|
||||
@@ -179,7 +179,7 @@ fun filtering(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("filter(predicate: (T)->Boolean)") {
|
||||
templates add f("filter(predicate: (T) -> Boolean)") {
|
||||
inline(true)
|
||||
|
||||
doc { "Returns a list containing all elements matching the given *predicate*" }
|
||||
@@ -190,7 +190,7 @@ fun filtering(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
|
||||
returns(Strings) { "String"}
|
||||
returns(Strings) { "String" }
|
||||
body(Strings) {
|
||||
"""
|
||||
return filterTo(StringBuilder(), predicate).toString()
|
||||
@@ -212,7 +212,7 @@ fun filtering(): List<GenericFunction> {
|
||||
inline(true)
|
||||
|
||||
doc { "Appends all elements matching the given *predicate* into the given *collection*" }
|
||||
typeParam("C: TCollection")
|
||||
typeParam("C : TCollection")
|
||||
returns("C")
|
||||
|
||||
body {
|
||||
@@ -236,7 +236,7 @@ fun filtering(): List<GenericFunction> {
|
||||
include(Maps)
|
||||
}
|
||||
|
||||
templates add f("filterNot(predicate: (T)->Boolean)") {
|
||||
templates add f("filterNot(predicate: (T) -> Boolean)") {
|
||||
inline(true)
|
||||
|
||||
doc { "Returns a list containing all elements not matching the given *predicate*" }
|
||||
@@ -247,7 +247,7 @@ fun filtering(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
|
||||
returns(Strings) { "String"}
|
||||
returns(Strings) { "String" }
|
||||
body(Strings) {
|
||||
"""
|
||||
return filterNotTo(StringBuilder(), predicate).toString()
|
||||
@@ -269,7 +269,7 @@ fun filtering(): List<GenericFunction> {
|
||||
inline(true)
|
||||
|
||||
doc { "Appends all elements not matching the given *predicate* to the given *collection*" }
|
||||
typeParam("C: TCollection")
|
||||
typeParam("C : TCollection")
|
||||
returns("C")
|
||||
|
||||
body {
|
||||
@@ -292,7 +292,7 @@ fun filtering(): List<GenericFunction> {
|
||||
templates add f("filterNotNull()") {
|
||||
exclude(ArraysOfPrimitives, Strings)
|
||||
doc { "Returns a list containing all elements that are not null" }
|
||||
typeParam("T: Any")
|
||||
typeParam("T : Any")
|
||||
returns("List<T>")
|
||||
toNullableT = true
|
||||
body {
|
||||
@@ -314,8 +314,8 @@ fun filtering(): List<GenericFunction> {
|
||||
exclude(ArraysOfPrimitives, Strings)
|
||||
doc { "Appends all elements that are not null to the given *collection*" }
|
||||
returns("C")
|
||||
typeParam("C: TCollection")
|
||||
typeParam("T: Any")
|
||||
typeParam("C : TCollection")
|
||||
typeParam("T : Any")
|
||||
toNullableT = true
|
||||
body {
|
||||
"""
|
||||
|
||||
@@ -11,9 +11,9 @@ fun generators(): List<GenericFunction> {
|
||||
returns("List<T>")
|
||||
body {
|
||||
"""
|
||||
val answer = toArrayList()
|
||||
answer.add(element)
|
||||
return answer
|
||||
val answer = toArrayList()
|
||||
answer.add(element)
|
||||
return answer
|
||||
"""
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ fun generators(): List<GenericFunction> {
|
||||
returns("List<T>")
|
||||
body {
|
||||
"""
|
||||
val answer = toArrayList()
|
||||
answer.addAll(collection)
|
||||
return answer
|
||||
val answer = toArrayList()
|
||||
answer.addAll(collection)
|
||||
return answer
|
||||
"""
|
||||
}
|
||||
}
|
||||
@@ -45,9 +45,9 @@ fun generators(): List<GenericFunction> {
|
||||
returns("List<T>")
|
||||
body {
|
||||
"""
|
||||
val answer = toArrayList()
|
||||
answer.addAll(array)
|
||||
return answer
|
||||
val answer = toArrayList()
|
||||
answer.addAll(array)
|
||||
return answer
|
||||
"""
|
||||
}
|
||||
}
|
||||
@@ -88,32 +88,32 @@ fun generators(): List<GenericFunction> {
|
||||
returns("Pair<List<T>, List<T>>")
|
||||
body {
|
||||
"""
|
||||
val first = ArrayList<T>()
|
||||
val second = ArrayList<T>()
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
first.add(element)
|
||||
} else {
|
||||
second.add(element)
|
||||
}
|
||||
val first = ArrayList<T>()
|
||||
val second = ArrayList<T>()
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
first.add(element)
|
||||
} else {
|
||||
second.add(element)
|
||||
}
|
||||
return Pair(first, second)
|
||||
}
|
||||
return Pair(first, second)
|
||||
"""
|
||||
}
|
||||
|
||||
returns(Strings) { "Pair<String, String>" }
|
||||
body(Strings) {
|
||||
"""
|
||||
val first = StringBuilder()
|
||||
val second = StringBuilder()
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
first.append(element)
|
||||
} else {
|
||||
second.append(element)
|
||||
}
|
||||
val first = StringBuilder()
|
||||
val second = StringBuilder()
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
first.append(element)
|
||||
} else {
|
||||
second.append(element)
|
||||
}
|
||||
return Pair(first.toString(), second.toString())
|
||||
}
|
||||
return Pair(first.toString(), second.toString())
|
||||
"""
|
||||
}
|
||||
}
|
||||
@@ -126,37 +126,37 @@ fun generators(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
typeParam("R")
|
||||
returns("List<Pair<T,R>>")
|
||||
returns("List<Pair<T, R>>")
|
||||
body {
|
||||
"""
|
||||
val first = iterator()
|
||||
val second = other.iterator()
|
||||
val list = ArrayList<Pair<T,R>>()
|
||||
while (first.hasNext() && second.hasNext()) {
|
||||
list.add(first.next() to second.next())
|
||||
}
|
||||
return list
|
||||
val first = iterator()
|
||||
val second = other.iterator()
|
||||
val list = ArrayList<Pair<T, R>>()
|
||||
while (first.hasNext() && second.hasNext()) {
|
||||
list.add(first.next() to second.next())
|
||||
}
|
||||
return list
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("zip(other : String)") {
|
||||
templates add f("zip(other: String)") {
|
||||
only(Strings)
|
||||
doc {
|
||||
"""
|
||||
Returns a list of pairs built from characters of both strings with same indexes. List has length of shortest collection.
|
||||
"""
|
||||
}
|
||||
returns("List<Pair<Char,Char>>")
|
||||
returns("List<Pair<Char, Char>>")
|
||||
body {
|
||||
"""
|
||||
val first = iterator()
|
||||
val second = other.iterator()
|
||||
val list = ArrayList<Pair<Char,Char>>()
|
||||
while (first.hasNext() && second.hasNext()) {
|
||||
list.add(first.next() to second.next())
|
||||
}
|
||||
return list
|
||||
val first = iterator()
|
||||
val second = other.iterator()
|
||||
val list = ArrayList<Pair<Char, Char>>()
|
||||
while (first.hasNext() && second.hasNext()) {
|
||||
list.add(first.next() to second.next())
|
||||
}
|
||||
return list
|
||||
"""
|
||||
}
|
||||
}
|
||||
@@ -169,16 +169,16 @@ fun generators(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
typeParam("R")
|
||||
returns("List<Pair<T,R>>")
|
||||
returns("List<Pair<T, R>>")
|
||||
body {
|
||||
"""
|
||||
val first = iterator()
|
||||
val second = array.iterator()
|
||||
val list = ArrayList<Pair<T,R>>()
|
||||
while (first.hasNext() && second.hasNext()) {
|
||||
list.add(first.next() to second.next())
|
||||
}
|
||||
return list
|
||||
val first = iterator()
|
||||
val second = array.iterator()
|
||||
val list = ArrayList<Pair<T, R>>()
|
||||
while (first.hasNext() && second.hasNext()) {
|
||||
list.add(first.next() to second.next())
|
||||
}
|
||||
return list
|
||||
"""
|
||||
}
|
||||
}
|
||||
@@ -191,10 +191,10 @@ fun generators(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
typeParam("R")
|
||||
returns("Stream<Pair<T,R>>")
|
||||
returns("Stream<Pair<T, R>>")
|
||||
body {
|
||||
"""
|
||||
return ZippingStream(this, stream)
|
||||
return ZippingStream(this, stream)
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ fun guards(): List<GenericFunction> {
|
||||
include(Lists)
|
||||
exclude(Strings, ArraysOfPrimitives)
|
||||
doc { "Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements" }
|
||||
typeParam("T:Any")
|
||||
typeParam("T : Any")
|
||||
toNullableT = true
|
||||
returns("SELF")
|
||||
body {
|
||||
|
||||
@@ -25,7 +25,7 @@ fun mapping(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("map(transform : (T) -> R)") {
|
||||
templates add f("map(transform: (T) -> R)") {
|
||||
inline(true)
|
||||
|
||||
doc { "Returns a list containing the results of applying the given *transform* function to each element of the original collection" }
|
||||
@@ -39,16 +39,16 @@ fun mapping(): List<GenericFunction> {
|
||||
returns(Streams) { "Stream<R>" }
|
||||
doc(Streams) { "Returns a stream containing the results of applying the given *transform* function to each element of the original stream" }
|
||||
body(Streams) {
|
||||
"return TransformingStream(this, transform) "
|
||||
"return TransformingStream(this, transform)"
|
||||
}
|
||||
include(Maps)
|
||||
}
|
||||
|
||||
templates add f("mapNotNull(transform : (T) -> R)") {
|
||||
templates add f("mapNotNull(transform: (T) -> R)") {
|
||||
inline(true)
|
||||
exclude(Strings, ArraysOfPrimitives)
|
||||
doc { "Returns a list containing the results of applying the given *transform* function to each non-null element of the original collection" }
|
||||
typeParam("T: Any")
|
||||
typeParam("T : Any")
|
||||
typeParam("R")
|
||||
returns("List<R>")
|
||||
toNullableT = true
|
||||
@@ -68,7 +68,7 @@ fun mapping(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("mapTo(collection: C, transform : (T) -> R)") {
|
||||
templates add f("mapTo(collection: C, transform: (T) -> R)") {
|
||||
inline(true)
|
||||
|
||||
doc {
|
||||
@@ -78,7 +78,7 @@ fun mapping(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
typeParam("R")
|
||||
typeParam("C: MutableCollection<in R>")
|
||||
typeParam("C : MutableCollection<in R>")
|
||||
returns("C")
|
||||
|
||||
body {
|
||||
@@ -91,7 +91,7 @@ fun mapping(): List<GenericFunction> {
|
||||
include(Maps)
|
||||
}
|
||||
|
||||
templates add f("mapNotNullTo(collection: C, transform : (T) -> R)") {
|
||||
templates add f("mapNotNullTo(collection: C, transform: (T) -> R)") {
|
||||
inline(true)
|
||||
exclude(Strings, ArraysOfPrimitives)
|
||||
doc {
|
||||
@@ -100,9 +100,9 @@ fun mapping(): List<GenericFunction> {
|
||||
to the given *collection*
|
||||
"""
|
||||
}
|
||||
typeParam("T: Any")
|
||||
typeParam("T : Any")
|
||||
typeParam("R")
|
||||
typeParam("C: MutableCollection<in R>")
|
||||
typeParam("C : MutableCollection<in R>")
|
||||
returns("C")
|
||||
toNullableT = true
|
||||
body {
|
||||
@@ -110,14 +110,14 @@ fun mapping(): List<GenericFunction> {
|
||||
for (element in this) {
|
||||
if (element != null) {
|
||||
collection.add(transform(element))
|
||||
}
|
||||
}
|
||||
}
|
||||
return collection
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("flatMap(transform: (T)-> Iterable<R>)") {
|
||||
templates add f("flatMap(transform: (T) -> Iterable<R>)") {
|
||||
inline(true)
|
||||
|
||||
exclude(Streams)
|
||||
@@ -130,7 +130,7 @@ fun mapping(): List<GenericFunction> {
|
||||
include(Maps)
|
||||
}
|
||||
|
||||
templates add f("flatMap(transform: (T)-> Stream<R>)") {
|
||||
templates add f("flatMap(transform: (T) -> Stream<R>)") {
|
||||
only(Streams)
|
||||
doc { "Returns a single stream of all elements streamed from results of *transform* function being invoked on each element of original stream" }
|
||||
typeParam("R")
|
||||
@@ -145,7 +145,7 @@ fun mapping(): List<GenericFunction> {
|
||||
exclude(Streams)
|
||||
doc { "Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*" }
|
||||
typeParam("R")
|
||||
typeParam("C: MutableCollection<in R>")
|
||||
typeParam("C : MutableCollection<in R>")
|
||||
returns("C")
|
||||
body {
|
||||
"""
|
||||
@@ -165,7 +165,7 @@ fun mapping(): List<GenericFunction> {
|
||||
only(Streams)
|
||||
doc { "Appends all elements yielded from results of *transform* function being invoked on each element of original stream, to the given *collection*" }
|
||||
typeParam("R")
|
||||
typeParam("C: MutableCollection<in R>")
|
||||
typeParam("C : MutableCollection<in R>")
|
||||
returns("C")
|
||||
body {
|
||||
"""
|
||||
|
||||
@@ -10,12 +10,12 @@ fun numeric(): List<GenericFunction> {
|
||||
returns("SUM")
|
||||
body {
|
||||
"""
|
||||
val iterator = iterator()
|
||||
var sum : SUM = ZERO
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
val iterator = iterator()
|
||||
var sum: SUM = ZERO
|
||||
while (iterator.hasNext()) {
|
||||
sum += iterator.next()
|
||||
}
|
||||
return sum
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ fun ordering(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
doc(Strings) { "Returns a string with characters in reversed order" }
|
||||
returns(Strings) { "String"}
|
||||
returns(Strings) { "String" }
|
||||
body(Strings) {
|
||||
// TODO: Replace with StringBuilder(this) when JS can handle it
|
||||
"""
|
||||
@@ -35,7 +35,7 @@ fun ordering(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
returns("List<T>")
|
||||
typeParam("T: Comparable<T>")
|
||||
typeParam("T : Comparable<T>")
|
||||
body {
|
||||
"""
|
||||
val sortedList = toArrayList()
|
||||
@@ -57,11 +57,11 @@ fun ordering(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
returns("List<T>")
|
||||
typeParam("T: Comparable<T>")
|
||||
typeParam("T : Comparable<T>")
|
||||
body {
|
||||
"""
|
||||
val sortedList = toArrayList()
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -x.compareTo(y)}
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -x.compareTo(y) }
|
||||
java.util.Collections.sort(sortedList, sortBy)
|
||||
return sortedList
|
||||
"""
|
||||
@@ -82,11 +82,11 @@ fun ordering(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
returns("List<T>")
|
||||
typeParam("R: Comparable<R>")
|
||||
typeParam("R : Comparable<R>")
|
||||
body {
|
||||
"""
|
||||
val sortedList = toArrayList()
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> order(x).compareTo(order(y))}
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> order(x).compareTo(order(y)) }
|
||||
java.util.Collections.sort(sortedList, sortBy)
|
||||
return sortedList
|
||||
"""
|
||||
@@ -106,11 +106,11 @@ fun ordering(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
returns("List<T>")
|
||||
typeParam("R: Comparable<R>")
|
||||
typeParam("R : Comparable<R>")
|
||||
body {
|
||||
"""
|
||||
val sortedList = toArrayList()
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -order(x).compareTo(order(y))}
|
||||
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -order(x).compareTo(order(y)) }
|
||||
java.util.Collections.sort(sortedList, sortBy)
|
||||
return sortedList
|
||||
"""
|
||||
@@ -121,7 +121,7 @@ fun ordering(): List<GenericFunction> {
|
||||
exclude(Strings)
|
||||
}
|
||||
|
||||
templates add f("sortBy(comparator : Comparator<T>)") {
|
||||
templates add f("sortBy(comparator: Comparator<T>)") {
|
||||
doc {
|
||||
"""
|
||||
Returns a list of all elements, sorted by the specified *comparator*
|
||||
|
||||
@@ -5,7 +5,7 @@ import templates.Family.*
|
||||
fun snapshots(): List<GenericFunction> {
|
||||
val templates = arrayListOf<GenericFunction>()
|
||||
|
||||
templates add f("toCollection(collection : C)") {
|
||||
templates add f("toCollection(collection: C)") {
|
||||
doc { "Appends all elements to the given *collection*" }
|
||||
returns("C")
|
||||
typeParam("C : MutableCollection<in T>")
|
||||
@@ -94,7 +94,7 @@ fun snapshots(): List<GenericFunction> {
|
||||
|
||||
templates add f("toSortedList()") {
|
||||
doc { "Returns a sorted list of all elements" }
|
||||
typeParam("T: Comparable<T>")
|
||||
typeParam("T : Comparable<T>")
|
||||
returns("List<T>")
|
||||
body { "return toArrayList().sort()" }
|
||||
body(Iterables) { "return sort()" }
|
||||
|
||||
@@ -63,7 +63,7 @@ fun specialJVM(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("sort(fromIndex : Int = 0, toIndex : Int = size - 1)") {
|
||||
templates add f("sort(fromIndex: Int = 0, toIndex: Int = size - 1)") {
|
||||
only(ArraysOfObjects, ArraysOfPrimitives)
|
||||
exclude(PrimitiveType.Boolean)
|
||||
doc { "Sorts array or range in array inplace" }
|
||||
@@ -75,8 +75,8 @@ fun specialJVM(): List<GenericFunction> {
|
||||
|
||||
templates add f("filterIsInstanceTo(collection: C, klass: Class<R>)") {
|
||||
doc { "Appends all elements that are instances of specified class into the given *collection*" }
|
||||
typeParam("C: MutableCollection<in R>")
|
||||
typeParam("R: T")
|
||||
typeParam("C : MutableCollection<in R>")
|
||||
typeParam("R : T")
|
||||
returns("C")
|
||||
exclude(ArraysOfPrimitives)
|
||||
body {
|
||||
@@ -89,7 +89,7 @@ fun specialJVM(): List<GenericFunction> {
|
||||
|
||||
templates add f("filterIsInstance(klass: Class<R>)") {
|
||||
doc { "Returns a list containing all elements that are instances of specified class" }
|
||||
typeParam("R: T")
|
||||
typeParam("R : T")
|
||||
returns("List<R>")
|
||||
body {
|
||||
"""
|
||||
|
||||
@@ -10,7 +10,11 @@ fun streams(): List<GenericFunction> {
|
||||
returns("Stream<T>")
|
||||
body {
|
||||
"""
|
||||
return object : Stream<T> { override fun iterator() : Iterator<T> { return this@stream.iterator() } }
|
||||
return object : Stream<T> {
|
||||
override fun iterator(): Iterator<T> {
|
||||
return this@stream.iterator()
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import templates.Family.*
|
||||
fun strings(): List<GenericFunction> {
|
||||
val templates = arrayListOf<GenericFunction>()
|
||||
|
||||
templates add f("appendString(buffer: Appendable, separator: String = \", \", prefix: String =\"\", postfix: String = \"\", limit: Int = -1, truncated: String = \"...\")") {
|
||||
templates add f("appendString(buffer: Appendable, separator: String = \", \", prefix: String = \"\", postfix: String = \"\", limit: Int = -1, truncated: String = \"...\")") {
|
||||
doc {
|
||||
"""
|
||||
Appends the string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied
|
||||
|
||||
Reference in New Issue
Block a user