Clean size/length/first/head/empty properties and functions.
This commit is contained in:
@@ -323,70 +323,70 @@ public inline fun String.any(predicate: (Char) -> Boolean): Boolean {
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun <T> Array<out T>.count(): Int {
|
||||
return size
|
||||
return size()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun BooleanArray.count(): Int {
|
||||
return size
|
||||
return size()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun ByteArray.count(): Int {
|
||||
return size
|
||||
return size()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun CharArray.count(): Int {
|
||||
return size
|
||||
return size()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun DoubleArray.count(): Int {
|
||||
return size
|
||||
return size()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun FloatArray.count(): Int {
|
||||
return size
|
||||
return size()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun IntArray.count(): Int {
|
||||
return size
|
||||
return size()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun LongArray.count(): Int {
|
||||
return size
|
||||
return size()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun ShortArray.count(): Int {
|
||||
return size
|
||||
return size()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun <T> Collection<T>.count(): Int {
|
||||
return size
|
||||
return size()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -402,7 +402,7 @@ public fun <T> Iterable<T>.count(): Int {
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun <K, V> Map<K, V>.count(): Int {
|
||||
return size
|
||||
return size()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -418,7 +418,7 @@ public fun <T> Stream<T>.count(): Int {
|
||||
* Returns the number of elements
|
||||
*/
|
||||
public fun String.count(): Int {
|
||||
return size
|
||||
return length()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -650,7 +650,7 @@ public inline fun <R> String.fold(initial: R, operation: (R, Char) -> R): R {
|
||||
* Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <T, R> Array<out T>.foldRight(initial: R, operation: (T, R) -> R): R {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
var accumulator = initial
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -662,7 +662,7 @@ public inline fun <T, R> Array<out T>.foldRight(initial: R, operation: (T, R) ->
|
||||
* Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <R> BooleanArray.foldRight(initial: R, operation: (Boolean, R) -> R): R {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
var accumulator = initial
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -674,7 +674,7 @@ public inline fun <R> BooleanArray.foldRight(initial: R, operation: (Boolean, R)
|
||||
* Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <R> ByteArray.foldRight(initial: R, operation: (Byte, R) -> R): R {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
var accumulator = initial
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -686,7 +686,7 @@ public inline fun <R> ByteArray.foldRight(initial: R, operation: (Byte, R) -> R)
|
||||
* Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <R> CharArray.foldRight(initial: R, operation: (Char, R) -> R): R {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
var accumulator = initial
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -698,7 +698,7 @@ public inline fun <R> CharArray.foldRight(initial: R, operation: (Char, R) -> R)
|
||||
* Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <R> DoubleArray.foldRight(initial: R, operation: (Double, R) -> R): R {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
var accumulator = initial
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -710,7 +710,7 @@ public inline fun <R> DoubleArray.foldRight(initial: R, operation: (Double, R) -
|
||||
* Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <R> FloatArray.foldRight(initial: R, operation: (Float, R) -> R): R {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
var accumulator = initial
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -722,7 +722,7 @@ public inline fun <R> FloatArray.foldRight(initial: R, operation: (Float, R) ->
|
||||
* Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <R> IntArray.foldRight(initial: R, operation: (Int, R) -> R): R {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
var accumulator = initial
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -734,7 +734,7 @@ public inline fun <R> IntArray.foldRight(initial: R, operation: (Int, R) -> R):
|
||||
* Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <R> LongArray.foldRight(initial: R, operation: (Long, R) -> R): R {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
var accumulator = initial
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -746,7 +746,7 @@ public inline fun <R> LongArray.foldRight(initial: R, operation: (Long, R) -> R)
|
||||
* Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <R> ShortArray.foldRight(initial: R, operation: (Short, R) -> R): R {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
var accumulator = initial
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -758,7 +758,7 @@ public inline fun <R> ShortArray.foldRight(initial: R, operation: (Short, R) ->
|
||||
* Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, R) -> R): R {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
var accumulator = initial
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -770,7 +770,7 @@ public inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, R) -> R):
|
||||
* Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <R> String.foldRight(initial: R, operation: (Char, R) -> R): R {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
var accumulator = initial
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -1499,7 +1499,7 @@ public fun String.min(): Char? {
|
||||
* Returns the first element yielding the smallest value of the given function or null if there are no elements
|
||||
*/
|
||||
public inline fun <R : Comparable<R>, T : Any> Array<out T>.minBy(f: (T) -> R): T? {
|
||||
if (size == 0) return null
|
||||
if (size() == 0) return null
|
||||
var minElem = this[0]
|
||||
var minValue = f(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
@@ -1517,7 +1517,7 @@ public inline fun <R : Comparable<R>, T : Any> Array<out T>.minBy(f: (T) -> R):
|
||||
* Returns the first element yielding the smallest value of the given function or null if there are no elements
|
||||
*/
|
||||
public inline fun <R : Comparable<R>> BooleanArray.minBy(f: (Boolean) -> R): Boolean? {
|
||||
if (size == 0) return null
|
||||
if (size() == 0) return null
|
||||
var minElem = this[0]
|
||||
var minValue = f(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
@@ -1535,7 +1535,7 @@ public inline fun <R : Comparable<R>> BooleanArray.minBy(f: (Boolean) -> R): Boo
|
||||
* Returns the first element yielding the smallest value of the given function or null if there are no elements
|
||||
*/
|
||||
public inline fun <R : Comparable<R>> ByteArray.minBy(f: (Byte) -> R): Byte? {
|
||||
if (size == 0) return null
|
||||
if (size() == 0) return null
|
||||
var minElem = this[0]
|
||||
var minValue = f(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
@@ -1553,7 +1553,7 @@ public inline fun <R : Comparable<R>> ByteArray.minBy(f: (Byte) -> R): Byte? {
|
||||
* Returns the first element yielding the smallest value of the given function or null if there are no elements
|
||||
*/
|
||||
public inline fun <R : Comparable<R>> CharArray.minBy(f: (Char) -> R): Char? {
|
||||
if (size == 0) return null
|
||||
if (size() == 0) return null
|
||||
var minElem = this[0]
|
||||
var minValue = f(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
@@ -1571,7 +1571,7 @@ public inline fun <R : Comparable<R>> CharArray.minBy(f: (Char) -> R): Char? {
|
||||
* Returns the first element yielding the smallest value of the given function or null if there are no elements
|
||||
*/
|
||||
public inline fun <R : Comparable<R>> DoubleArray.minBy(f: (Double) -> R): Double? {
|
||||
if (size == 0) return null
|
||||
if (size() == 0) return null
|
||||
var minElem = this[0]
|
||||
var minValue = f(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
@@ -1589,7 +1589,7 @@ public inline fun <R : Comparable<R>> DoubleArray.minBy(f: (Double) -> R): Doubl
|
||||
* Returns the first element yielding the smallest value of the given function or null if there are no elements
|
||||
*/
|
||||
public inline fun <R : Comparable<R>> FloatArray.minBy(f: (Float) -> R): Float? {
|
||||
if (size == 0) return null
|
||||
if (size() == 0) return null
|
||||
var minElem = this[0]
|
||||
var minValue = f(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
@@ -1607,7 +1607,7 @@ public inline fun <R : Comparable<R>> FloatArray.minBy(f: (Float) -> R): Float?
|
||||
* Returns the first element yielding the smallest value of the given function or null if there are no elements
|
||||
*/
|
||||
public inline fun <R : Comparable<R>> IntArray.minBy(f: (Int) -> R): Int? {
|
||||
if (size == 0) return null
|
||||
if (size() == 0) return null
|
||||
var minElem = this[0]
|
||||
var minValue = f(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
@@ -1625,7 +1625,7 @@ public inline fun <R : Comparable<R>> IntArray.minBy(f: (Int) -> R): Int? {
|
||||
* Returns the first element yielding the smallest value of the given function or null if there are no elements
|
||||
*/
|
||||
public inline fun <R : Comparable<R>> LongArray.minBy(f: (Long) -> R): Long? {
|
||||
if (size == 0) return null
|
||||
if (size() == 0) return null
|
||||
var minElem = this[0]
|
||||
var minValue = f(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
@@ -1643,7 +1643,7 @@ public inline fun <R : Comparable<R>> LongArray.minBy(f: (Long) -> R): Long? {
|
||||
* Returns the first element yielding the smallest value of the given function or null if there are no elements
|
||||
*/
|
||||
public inline fun <R : Comparable<R>> ShortArray.minBy(f: (Short) -> R): Short? {
|
||||
if (size == 0) return null
|
||||
if (size() == 0) return null
|
||||
var minElem = this[0]
|
||||
var minValue = f(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
@@ -2101,7 +2101,7 @@ public inline fun String.reduce(operation: (Char, Char) -> Char): Char {
|
||||
* Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <T> Array<out T>.reduceRight(operation: (T, T) -> T): T {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
@@ -2114,7 +2114,7 @@ public inline fun <T> Array<out T>.reduceRight(operation: (T, T) -> T): T {
|
||||
* Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun BooleanArray.reduceRight(operation: (Boolean, Boolean) -> Boolean): Boolean {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
@@ -2127,7 +2127,7 @@ public inline fun BooleanArray.reduceRight(operation: (Boolean, Boolean) -> Bool
|
||||
* Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun ByteArray.reduceRight(operation: (Byte, Byte) -> Byte): Byte {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
@@ -2140,7 +2140,7 @@ public inline fun ByteArray.reduceRight(operation: (Byte, Byte) -> Byte): Byte {
|
||||
* Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun CharArray.reduceRight(operation: (Char, Char) -> Char): Char {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
@@ -2153,7 +2153,7 @@ public inline fun CharArray.reduceRight(operation: (Char, Char) -> Char): Char {
|
||||
* Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun DoubleArray.reduceRight(operation: (Double, Double) -> Double): Double {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
@@ -2166,7 +2166,7 @@ public inline fun DoubleArray.reduceRight(operation: (Double, Double) -> Double)
|
||||
* Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun FloatArray.reduceRight(operation: (Float, Float) -> Float): Float {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
@@ -2179,7 +2179,7 @@ public inline fun FloatArray.reduceRight(operation: (Float, Float) -> Float): Fl
|
||||
* Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun IntArray.reduceRight(operation: (Int, Int) -> Int): Int {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
@@ -2192,7 +2192,7 @@ public inline fun IntArray.reduceRight(operation: (Int, Int) -> Int): Int {
|
||||
* Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun LongArray.reduceRight(operation: (Long, Long) -> Long): Long {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
@@ -2205,7 +2205,7 @@ public inline fun LongArray.reduceRight(operation: (Long, Long) -> Long): Long {
|
||||
* Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun ShortArray.reduceRight(operation: (Short, Short) -> Short): Short {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
@@ -2218,7 +2218,7 @@ public inline fun ShortArray.reduceRight(operation: (Short, Short) -> Short): Sh
|
||||
* Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun <T> List<T>.reduceRight(operation: (T, T) -> T): T {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
@@ -2231,7 +2231,7 @@ public inline fun <T> List<T>.reduceRight(operation: (T, T) -> T): T {
|
||||
* Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value
|
||||
*/
|
||||
public inline fun String.reduceRight(operation: (Char, Char) -> Char): Char {
|
||||
var index = size - 1
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
|
||||
@@ -11,63 +11,63 @@ import java.util.*
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun <T> Array<out T>.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
return size() == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun BooleanArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
return size() == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun ByteArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
return size() == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun CharArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
return size() == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun DoubleArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
return size() == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun FloatArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
return size() == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun IntArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
return size() == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun LongArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
return size() == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the array is empty
|
||||
*/
|
||||
public fun ShortArray.isEmpty(): Boolean {
|
||||
return size == 0
|
||||
return size() == 0
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -549,7 +549,7 @@ public fun String.elementAt(index: Int): Char {
|
||||
* Returns first element
|
||||
*/
|
||||
public fun <T> Array<out T>.first(): T {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[0]
|
||||
}
|
||||
@@ -558,7 +558,7 @@ public fun <T> Array<out T>.first(): T {
|
||||
* Returns first element
|
||||
*/
|
||||
public fun BooleanArray.first(): Boolean {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[0]
|
||||
}
|
||||
@@ -567,7 +567,7 @@ public fun BooleanArray.first(): Boolean {
|
||||
* Returns first element
|
||||
*/
|
||||
public fun ByteArray.first(): Byte {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[0]
|
||||
}
|
||||
@@ -576,7 +576,7 @@ public fun ByteArray.first(): Byte {
|
||||
* Returns first element
|
||||
*/
|
||||
public fun CharArray.first(): Char {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[0]
|
||||
}
|
||||
@@ -585,7 +585,7 @@ public fun CharArray.first(): Char {
|
||||
* Returns first element
|
||||
*/
|
||||
public fun DoubleArray.first(): Double {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[0]
|
||||
}
|
||||
@@ -594,7 +594,7 @@ public fun DoubleArray.first(): Double {
|
||||
* Returns first element
|
||||
*/
|
||||
public fun FloatArray.first(): Float {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[0]
|
||||
}
|
||||
@@ -603,7 +603,7 @@ public fun FloatArray.first(): Float {
|
||||
* Returns first element
|
||||
*/
|
||||
public fun IntArray.first(): Int {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[0]
|
||||
}
|
||||
@@ -612,7 +612,7 @@ public fun IntArray.first(): Int {
|
||||
* Returns first element
|
||||
*/
|
||||
public fun LongArray.first(): Long {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[0]
|
||||
}
|
||||
@@ -621,7 +621,7 @@ public fun LongArray.first(): Long {
|
||||
* Returns first element
|
||||
*/
|
||||
public fun ShortArray.first(): Short {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[0]
|
||||
}
|
||||
@@ -632,7 +632,7 @@ public fun ShortArray.first(): Short {
|
||||
public fun <T> Iterable<T>.first(): T {
|
||||
when (this) {
|
||||
is List<*> -> {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
else
|
||||
return this[0] as T
|
||||
@@ -650,7 +650,7 @@ public fun <T> Iterable<T>.first(): T {
|
||||
* Returns first element
|
||||
*/
|
||||
public fun <T> List<T>.first(): T {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[0]
|
||||
}
|
||||
@@ -661,7 +661,7 @@ public fun <T> List<T>.first(): T {
|
||||
public fun <T> Stream<T>.first(): T {
|
||||
when (this) {
|
||||
is List<*> -> {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
else
|
||||
return this[0] as T
|
||||
@@ -679,7 +679,7 @@ public fun <T> Stream<T>.first(): T {
|
||||
* Returns first element
|
||||
*/
|
||||
public fun String.first(): Char {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[0]
|
||||
}
|
||||
@@ -784,63 +784,63 @@ public inline fun String.first(predicate: (Char) -> Boolean): Char {
|
||||
* Returns first element, or null if collection is empty
|
||||
*/
|
||||
public fun <T> Array<out T>.firstOrNull(): T? {
|
||||
return if (size > 0) this[0] else null
|
||||
return if (isEmpty()) null else this[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns first element, or null if collection is empty
|
||||
*/
|
||||
public fun BooleanArray.firstOrNull(): Boolean? {
|
||||
return if (size > 0) this[0] else null
|
||||
return if (isEmpty()) null else this[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns first element, or null if collection is empty
|
||||
*/
|
||||
public fun ByteArray.firstOrNull(): Byte? {
|
||||
return if (size > 0) this[0] else null
|
||||
return if (isEmpty()) null else this[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns first element, or null if collection is empty
|
||||
*/
|
||||
public fun CharArray.firstOrNull(): Char? {
|
||||
return if (size > 0) this[0] else null
|
||||
return if (isEmpty()) null else this[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns first element, or null if collection is empty
|
||||
*/
|
||||
public fun DoubleArray.firstOrNull(): Double? {
|
||||
return if (size > 0) this[0] else null
|
||||
return if (isEmpty()) null else this[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns first element, or null if collection is empty
|
||||
*/
|
||||
public fun FloatArray.firstOrNull(): Float? {
|
||||
return if (size > 0) this[0] else null
|
||||
return if (isEmpty()) null else this[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns first element, or null if collection is empty
|
||||
*/
|
||||
public fun IntArray.firstOrNull(): Int? {
|
||||
return if (size > 0) this[0] else null
|
||||
return if (isEmpty()) null else this[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns first element, or null if collection is empty
|
||||
*/
|
||||
public fun LongArray.firstOrNull(): Long? {
|
||||
return if (size > 0) this[0] else null
|
||||
return if (isEmpty()) null else this[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns first element, or null if collection is empty
|
||||
*/
|
||||
public fun ShortArray.firstOrNull(): Short? {
|
||||
return if (size > 0) this[0] else null
|
||||
return if (isEmpty()) null else this[0]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -849,7 +849,7 @@ public fun ShortArray.firstOrNull(): Short? {
|
||||
public fun <T> Iterable<T>.firstOrNull(): T? {
|
||||
when (this) {
|
||||
is List<*> -> {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
return null
|
||||
else
|
||||
return this[0] as T
|
||||
@@ -867,7 +867,7 @@ public fun <T> Iterable<T>.firstOrNull(): T? {
|
||||
* Returns first element, or null if collection is empty
|
||||
*/
|
||||
public fun <T> List<T>.firstOrNull(): T? {
|
||||
return if (size > 0) this[0] else null
|
||||
return if (isEmpty()) null else this[0]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -876,7 +876,7 @@ public fun <T> List<T>.firstOrNull(): T? {
|
||||
public fun <T> Stream<T>.firstOrNull(): T? {
|
||||
when (this) {
|
||||
is List<*> -> {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
return null
|
||||
else
|
||||
return this[0] as T
|
||||
@@ -894,7 +894,7 @@ public fun <T> Stream<T>.firstOrNull(): T? {
|
||||
* Returns first element, or null if collection is empty
|
||||
*/
|
||||
public fun String.firstOrNull(): Char? {
|
||||
return if (size > 0) this[0] else null
|
||||
return if (isEmpty()) null else this[0]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1139,81 +1139,81 @@ public fun <T> Stream<T>.indexOf(element: T): Int {
|
||||
* Returns last element
|
||||
*/
|
||||
public fun <T> Array<out T>.last(): T {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[size - 1]
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element
|
||||
*/
|
||||
public fun BooleanArray.last(): Boolean {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[size - 1]
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element
|
||||
*/
|
||||
public fun ByteArray.last(): Byte {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[size - 1]
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element
|
||||
*/
|
||||
public fun CharArray.last(): Char {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[size - 1]
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element
|
||||
*/
|
||||
public fun DoubleArray.last(): Double {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[size - 1]
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element
|
||||
*/
|
||||
public fun FloatArray.last(): Float {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[size - 1]
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element
|
||||
*/
|
||||
public fun IntArray.last(): Int {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[size - 1]
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element
|
||||
*/
|
||||
public fun LongArray.last(): Long {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[size - 1]
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element
|
||||
*/
|
||||
public fun ShortArray.last(): Short {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[size - 1]
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1222,10 +1222,10 @@ public fun ShortArray.last(): Short {
|
||||
public fun <T> Iterable<T>.last(): T {
|
||||
when (this) {
|
||||
is List<*> -> {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
else
|
||||
return this[size - 1] as T
|
||||
return this[this.lastIndex] as T
|
||||
}
|
||||
else -> {
|
||||
val iterator = iterator()
|
||||
@@ -1243,41 +1243,31 @@ public fun <T> Iterable<T>.last(): T {
|
||||
* Returns last element
|
||||
*/
|
||||
public fun <T> List<T>.last(): T {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[size - 1]
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element
|
||||
*/
|
||||
public fun <T> Stream<T>.last(): T {
|
||||
when (this) {
|
||||
is List<*> -> {
|
||||
if (size == 0)
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
else
|
||||
return this[size - 1] as T
|
||||
}
|
||||
else -> {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
var last = iterator.next()
|
||||
while (iterator.hasNext())
|
||||
last = iterator.next()
|
||||
return last
|
||||
}
|
||||
}
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
var last = iterator.next()
|
||||
while (iterator.hasNext())
|
||||
last = iterator.next()
|
||||
return last
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element
|
||||
*/
|
||||
public fun String.last(): Char {
|
||||
if (size == 0)
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty")
|
||||
return this[size - 1]
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1640,63 +1630,63 @@ public fun <T> Stream<T>.lastIndexOf(element: T): Int {
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun <T> Array<out T>.lastOrNull(): T? {
|
||||
return if (size > 0) this[size - 1] else null
|
||||
return if (isEmpty()) null else this[size() - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun BooleanArray.lastOrNull(): Boolean? {
|
||||
return if (size > 0) this[size - 1] else null
|
||||
return if (isEmpty()) null else this[size() - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun ByteArray.lastOrNull(): Byte? {
|
||||
return if (size > 0) this[size - 1] else null
|
||||
return if (isEmpty()) null else this[size() - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun CharArray.lastOrNull(): Char? {
|
||||
return if (size > 0) this[size - 1] else null
|
||||
return if (isEmpty()) null else this[size() - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun DoubleArray.lastOrNull(): Double? {
|
||||
return if (size > 0) this[size - 1] else null
|
||||
return if (isEmpty()) null else this[size() - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun FloatArray.lastOrNull(): Float? {
|
||||
return if (size > 0) this[size - 1] else null
|
||||
return if (isEmpty()) null else this[size() - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun IntArray.lastOrNull(): Int? {
|
||||
return if (size > 0) this[size - 1] else null
|
||||
return if (isEmpty()) null else this[size() - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun LongArray.lastOrNull(): Long? {
|
||||
return if (size > 0) this[size - 1] else null
|
||||
return if (isEmpty()) null else this[size() - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun ShortArray.lastOrNull(): Short? {
|
||||
return if (size > 0) this[size - 1] else null
|
||||
return if (isEmpty()) null else this[size() - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1704,7 +1694,7 @@ public fun ShortArray.lastOrNull(): Short? {
|
||||
*/
|
||||
public fun <T> Iterable<T>.lastOrNull(): T? {
|
||||
when (this) {
|
||||
is List<*> -> return if (size > 0) this[size - 1] as T else null
|
||||
is List<*> -> return if (isEmpty()) null else this[size() - 1] as T
|
||||
else -> {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext())
|
||||
@@ -1721,32 +1711,27 @@ public fun <T> Iterable<T>.lastOrNull(): T? {
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun <T> List<T>.lastOrNull(): T? {
|
||||
return if (size > 0) this[size - 1] else null
|
||||
return if (isEmpty()) null else this[size() - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun <T> Stream<T>.lastOrNull(): T? {
|
||||
when (this) {
|
||||
is List<*> -> return if (size > 0) this[size - 1] as T else null
|
||||
else -> {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext())
|
||||
return null
|
||||
var last = iterator.next()
|
||||
while (iterator.hasNext())
|
||||
last = iterator.next()
|
||||
return last
|
||||
}
|
||||
}
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext())
|
||||
return null
|
||||
var last = iterator.next()
|
||||
while (iterator.hasNext())
|
||||
last = iterator.next()
|
||||
return last
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last element, or null if collection is empty
|
||||
*/
|
||||
public fun String.lastOrNull(): Char? {
|
||||
return if (size > 0) this[size - 1] else null
|
||||
return if (isEmpty()) null else this[length() - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1909,7 +1894,7 @@ public inline fun String.lastOrNull(predicate: (Char) -> Boolean): Char? {
|
||||
* Returns single element, or throws exception if there is no or more than one element
|
||||
*/
|
||||
public fun <T> Array<out T>.single(): T {
|
||||
return when (size) {
|
||||
return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -1920,7 +1905,7 @@ public fun <T> Array<out T>.single(): T {
|
||||
* Returns single element, or throws exception if there is no or more than one element
|
||||
*/
|
||||
public fun BooleanArray.single(): Boolean {
|
||||
return when (size) {
|
||||
return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -1931,7 +1916,7 @@ public fun BooleanArray.single(): Boolean {
|
||||
* Returns single element, or throws exception if there is no or more than one element
|
||||
*/
|
||||
public fun ByteArray.single(): Byte {
|
||||
return when (size) {
|
||||
return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -1942,7 +1927,7 @@ public fun ByteArray.single(): Byte {
|
||||
* Returns single element, or throws exception if there is no or more than one element
|
||||
*/
|
||||
public fun CharArray.single(): Char {
|
||||
return when (size) {
|
||||
return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -1953,7 +1938,7 @@ public fun CharArray.single(): Char {
|
||||
* Returns single element, or throws exception if there is no or more than one element
|
||||
*/
|
||||
public fun DoubleArray.single(): Double {
|
||||
return when (size) {
|
||||
return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -1964,7 +1949,7 @@ public fun DoubleArray.single(): Double {
|
||||
* Returns single element, or throws exception if there is no or more than one element
|
||||
*/
|
||||
public fun FloatArray.single(): Float {
|
||||
return when (size) {
|
||||
return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -1975,7 +1960,7 @@ public fun FloatArray.single(): Float {
|
||||
* Returns single element, or throws exception if there is no or more than one element
|
||||
*/
|
||||
public fun IntArray.single(): Int {
|
||||
return when (size) {
|
||||
return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -1986,7 +1971,7 @@ public fun IntArray.single(): Int {
|
||||
* Returns single element, or throws exception if there is no or more than one element
|
||||
*/
|
||||
public fun LongArray.single(): Long {
|
||||
return when (size) {
|
||||
return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -1997,7 +1982,7 @@ public fun LongArray.single(): Long {
|
||||
* Returns single element, or throws exception if there is no or more than one element
|
||||
*/
|
||||
public fun ShortArray.single(): Short {
|
||||
return when (size) {
|
||||
return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -2009,7 +1994,7 @@ public fun ShortArray.single(): Short {
|
||||
*/
|
||||
public fun <T> Iterable<T>.single(): T {
|
||||
when (this) {
|
||||
is List<*> -> return when (size) {
|
||||
is List<*> -> return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0] as T
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -2030,7 +2015,7 @@ public fun <T> Iterable<T>.single(): T {
|
||||
* Returns single element, or throws exception if there is no or more than one element
|
||||
*/
|
||||
public fun <T> List<T>.single(): T {
|
||||
return when (size) {
|
||||
return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -2042,7 +2027,7 @@ public fun <T> List<T>.single(): T {
|
||||
*/
|
||||
public fun <T> Stream<T>.single(): T {
|
||||
when (this) {
|
||||
is List<*> -> return when (size) {
|
||||
is List<*> -> return when (size()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0] as T
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -2063,7 +2048,7 @@ public fun <T> Stream<T>.single(): T {
|
||||
* Returns single element, or throws exception if there is no or more than one element
|
||||
*/
|
||||
public fun String.single(): Char {
|
||||
return when (size) {
|
||||
return when (length()) {
|
||||
0 -> throw NoSuchElementException("Collection is empty")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element")
|
||||
@@ -2278,63 +2263,63 @@ public inline fun String.single(predicate: (Char) -> Boolean): Char {
|
||||
* Returns single element, or null if collection is empty, or throws exception if there is more than one element
|
||||
*/
|
||||
public fun <T> Array<out T>.singleOrNull(): T? {
|
||||
return if (size == 1) this[0] else null
|
||||
return if (size() == 1) this[0] else null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns single element, or null if collection is empty, or throws exception if there is more than one element
|
||||
*/
|
||||
public fun BooleanArray.singleOrNull(): Boolean? {
|
||||
return if (size == 1) this[0] else null
|
||||
return if (size() == 1) this[0] else null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns single element, or null if collection is empty, or throws exception if there is more than one element
|
||||
*/
|
||||
public fun ByteArray.singleOrNull(): Byte? {
|
||||
return if (size == 1) this[0] else null
|
||||
return if (size() == 1) this[0] else null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns single element, or null if collection is empty, or throws exception if there is more than one element
|
||||
*/
|
||||
public fun CharArray.singleOrNull(): Char? {
|
||||
return if (size == 1) this[0] else null
|
||||
return if (size() == 1) this[0] else null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns single element, or null if collection is empty, or throws exception if there is more than one element
|
||||
*/
|
||||
public fun DoubleArray.singleOrNull(): Double? {
|
||||
return if (size == 1) this[0] else null
|
||||
return if (size() == 1) this[0] else null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns single element, or null if collection is empty, or throws exception if there is more than one element
|
||||
*/
|
||||
public fun FloatArray.singleOrNull(): Float? {
|
||||
return if (size == 1) this[0] else null
|
||||
return if (size() == 1) this[0] else null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns single element, or null if collection is empty, or throws exception if there is more than one element
|
||||
*/
|
||||
public fun IntArray.singleOrNull(): Int? {
|
||||
return if (size == 1) this[0] else null
|
||||
return if (size() == 1) this[0] else null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns single element, or null if collection is empty, or throws exception if there is more than one element
|
||||
*/
|
||||
public fun LongArray.singleOrNull(): Long? {
|
||||
return if (size == 1) this[0] else null
|
||||
return if (size() == 1) this[0] else null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns single element, or null if collection is empty, or throws exception if there is more than one element
|
||||
*/
|
||||
public fun ShortArray.singleOrNull(): Short? {
|
||||
return if (size == 1) this[0] else null
|
||||
return if (size() == 1) this[0] else null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2342,7 +2327,7 @@ public fun ShortArray.singleOrNull(): Short? {
|
||||
*/
|
||||
public fun <T> Iterable<T>.singleOrNull(): T? {
|
||||
when (this) {
|
||||
is List<*> -> return if (size == 1) this[0] as T else null
|
||||
is List<*> -> return if (size() == 1) this[0] as T else null
|
||||
else -> {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext())
|
||||
@@ -2359,7 +2344,7 @@ public fun <T> Iterable<T>.singleOrNull(): T? {
|
||||
* Returns single element, or null if collection is empty, or throws exception if there is more than one element
|
||||
*/
|
||||
public fun <T> List<T>.singleOrNull(): T? {
|
||||
return if (size == 1) this[0] else null
|
||||
return if (size() == 1) this[0] else null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2367,7 +2352,7 @@ public fun <T> List<T>.singleOrNull(): T? {
|
||||
*/
|
||||
public fun <T> Stream<T>.singleOrNull(): T? {
|
||||
when (this) {
|
||||
is List<*> -> return if (size == 1) this[0] as T else null
|
||||
is List<*> -> return if (size() == 1) this[0] as T else null
|
||||
else -> {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext())
|
||||
@@ -2384,7 +2369,7 @@ public fun <T> Stream<T>.singleOrNull(): T? {
|
||||
* Returns single element, or null if collection is empty, or throws exception if there is more than one element
|
||||
*/
|
||||
public fun String.singleOrNull(): Char? {
|
||||
return if (size == 1) this[0] else null
|
||||
return if (length() == 1) this[0] else null
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,10 +11,10 @@ import java.util.*
|
||||
* Returns a list containing all elements except first *n* elements
|
||||
*/
|
||||
public fun <T> Array<out T>.drop(n: Int): List<T> {
|
||||
if (n >= size)
|
||||
if (n >= size())
|
||||
return ArrayList<T>()
|
||||
var count = 0
|
||||
val list = ArrayList<T>(size - n)
|
||||
val list = ArrayList<T>(size() - n)
|
||||
for (item in this) {
|
||||
if (count++ >= n) list.add(item)
|
||||
}
|
||||
@@ -25,10 +25,10 @@ public fun <T> Array<out T>.drop(n: Int): List<T> {
|
||||
* Returns a list containing all elements except first *n* elements
|
||||
*/
|
||||
public fun BooleanArray.drop(n: Int): List<Boolean> {
|
||||
if (n >= size)
|
||||
if (n >= size())
|
||||
return ArrayList<Boolean>()
|
||||
var count = 0
|
||||
val list = ArrayList<Boolean>(size - n)
|
||||
val list = ArrayList<Boolean>(size() - n)
|
||||
for (item in this) {
|
||||
if (count++ >= n) list.add(item)
|
||||
}
|
||||
@@ -39,10 +39,10 @@ public fun BooleanArray.drop(n: Int): List<Boolean> {
|
||||
* Returns a list containing all elements except first *n* elements
|
||||
*/
|
||||
public fun ByteArray.drop(n: Int): List<Byte> {
|
||||
if (n >= size)
|
||||
if (n >= size())
|
||||
return ArrayList<Byte>()
|
||||
var count = 0
|
||||
val list = ArrayList<Byte>(size - n)
|
||||
val list = ArrayList<Byte>(size() - n)
|
||||
for (item in this) {
|
||||
if (count++ >= n) list.add(item)
|
||||
}
|
||||
@@ -53,10 +53,10 @@ public fun ByteArray.drop(n: Int): List<Byte> {
|
||||
* Returns a list containing all elements except first *n* elements
|
||||
*/
|
||||
public fun CharArray.drop(n: Int): List<Char> {
|
||||
if (n >= size)
|
||||
if (n >= size())
|
||||
return ArrayList<Char>()
|
||||
var count = 0
|
||||
val list = ArrayList<Char>(size - n)
|
||||
val list = ArrayList<Char>(size() - n)
|
||||
for (item in this) {
|
||||
if (count++ >= n) list.add(item)
|
||||
}
|
||||
@@ -67,10 +67,10 @@ public fun CharArray.drop(n: Int): List<Char> {
|
||||
* Returns a list containing all elements except first *n* elements
|
||||
*/
|
||||
public fun DoubleArray.drop(n: Int): List<Double> {
|
||||
if (n >= size)
|
||||
if (n >= size())
|
||||
return ArrayList<Double>()
|
||||
var count = 0
|
||||
val list = ArrayList<Double>(size - n)
|
||||
val list = ArrayList<Double>(size() - n)
|
||||
for (item in this) {
|
||||
if (count++ >= n) list.add(item)
|
||||
}
|
||||
@@ -81,10 +81,10 @@ public fun DoubleArray.drop(n: Int): List<Double> {
|
||||
* Returns a list containing all elements except first *n* elements
|
||||
*/
|
||||
public fun FloatArray.drop(n: Int): List<Float> {
|
||||
if (n >= size)
|
||||
if (n >= size())
|
||||
return ArrayList<Float>()
|
||||
var count = 0
|
||||
val list = ArrayList<Float>(size - n)
|
||||
val list = ArrayList<Float>(size() - n)
|
||||
for (item in this) {
|
||||
if (count++ >= n) list.add(item)
|
||||
}
|
||||
@@ -95,10 +95,10 @@ public fun FloatArray.drop(n: Int): List<Float> {
|
||||
* Returns a list containing all elements except first *n* elements
|
||||
*/
|
||||
public fun IntArray.drop(n: Int): List<Int> {
|
||||
if (n >= size)
|
||||
if (n >= size())
|
||||
return ArrayList<Int>()
|
||||
var count = 0
|
||||
val list = ArrayList<Int>(size - n)
|
||||
val list = ArrayList<Int>(size() - n)
|
||||
for (item in this) {
|
||||
if (count++ >= n) list.add(item)
|
||||
}
|
||||
@@ -109,10 +109,10 @@ public fun IntArray.drop(n: Int): List<Int> {
|
||||
* Returns a list containing all elements except first *n* elements
|
||||
*/
|
||||
public fun LongArray.drop(n: Int): List<Long> {
|
||||
if (n >= size)
|
||||
if (n >= size())
|
||||
return ArrayList<Long>()
|
||||
var count = 0
|
||||
val list = ArrayList<Long>(size - n)
|
||||
val list = ArrayList<Long>(size() - n)
|
||||
for (item in this) {
|
||||
if (count++ >= n) list.add(item)
|
||||
}
|
||||
@@ -123,10 +123,10 @@ public fun LongArray.drop(n: Int): List<Long> {
|
||||
* Returns a list containing all elements except first *n* elements
|
||||
*/
|
||||
public fun ShortArray.drop(n: Int): List<Short> {
|
||||
if (n >= size)
|
||||
if (n >= size())
|
||||
return ArrayList<Short>()
|
||||
var count = 0
|
||||
val list = ArrayList<Short>(size - n)
|
||||
val list = ArrayList<Short>(size() - n)
|
||||
for (item in this) {
|
||||
if (count++ >= n) list.add(item)
|
||||
}
|
||||
@@ -137,10 +137,10 @@ public fun ShortArray.drop(n: Int): List<Short> {
|
||||
* Returns a list containing all elements except first *n* elements
|
||||
*/
|
||||
public fun <T> Collection<T>.drop(n: Int): List<T> {
|
||||
if (n >= size)
|
||||
if (n >= size())
|
||||
return ArrayList<T>()
|
||||
var count = 0
|
||||
val list = ArrayList<T>(size - n)
|
||||
val list = ArrayList<T>(size() - n)
|
||||
for (item in this) {
|
||||
if (count++ >= n) list.add(item)
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public fun <T> Stream<T>.drop(n: Int): Stream<T> {
|
||||
* Returns a list containing all elements except first *n* elements
|
||||
*/
|
||||
public fun String.drop(n: Int): String {
|
||||
return substring(Math.min(n, size))
|
||||
return substring(Math.min(n, length()))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -885,7 +885,7 @@ public fun String.slice(indices: Iterable<Int>): String {
|
||||
*/
|
||||
public fun <T> Array<out T>.take(n: Int): List<T> {
|
||||
var count = 0
|
||||
val realN = if (n > size) size else n
|
||||
val realN = if (n > size()) size() else n
|
||||
val list = ArrayList<T>(realN)
|
||||
for (item in this) {
|
||||
if (count++ == realN)
|
||||
@@ -900,7 +900,7 @@ public fun <T> Array<out T>.take(n: Int): List<T> {
|
||||
*/
|
||||
public fun BooleanArray.take(n: Int): List<Boolean> {
|
||||
var count = 0
|
||||
val realN = if (n > size) size else n
|
||||
val realN = if (n > size()) size() else n
|
||||
val list = ArrayList<Boolean>(realN)
|
||||
for (item in this) {
|
||||
if (count++ == realN)
|
||||
@@ -915,7 +915,7 @@ public fun BooleanArray.take(n: Int): List<Boolean> {
|
||||
*/
|
||||
public fun ByteArray.take(n: Int): List<Byte> {
|
||||
var count = 0
|
||||
val realN = if (n > size) size else n
|
||||
val realN = if (n > size()) size() else n
|
||||
val list = ArrayList<Byte>(realN)
|
||||
for (item in this) {
|
||||
if (count++ == realN)
|
||||
@@ -930,7 +930,7 @@ public fun ByteArray.take(n: Int): List<Byte> {
|
||||
*/
|
||||
public fun CharArray.take(n: Int): List<Char> {
|
||||
var count = 0
|
||||
val realN = if (n > size) size else n
|
||||
val realN = if (n > size()) size() else n
|
||||
val list = ArrayList<Char>(realN)
|
||||
for (item in this) {
|
||||
if (count++ == realN)
|
||||
@@ -945,7 +945,7 @@ public fun CharArray.take(n: Int): List<Char> {
|
||||
*/
|
||||
public fun DoubleArray.take(n: Int): List<Double> {
|
||||
var count = 0
|
||||
val realN = if (n > size) size else n
|
||||
val realN = if (n > size()) size() else n
|
||||
val list = ArrayList<Double>(realN)
|
||||
for (item in this) {
|
||||
if (count++ == realN)
|
||||
@@ -960,7 +960,7 @@ public fun DoubleArray.take(n: Int): List<Double> {
|
||||
*/
|
||||
public fun FloatArray.take(n: Int): List<Float> {
|
||||
var count = 0
|
||||
val realN = if (n > size) size else n
|
||||
val realN = if (n > size()) size() else n
|
||||
val list = ArrayList<Float>(realN)
|
||||
for (item in this) {
|
||||
if (count++ == realN)
|
||||
@@ -975,7 +975,7 @@ public fun FloatArray.take(n: Int): List<Float> {
|
||||
*/
|
||||
public fun IntArray.take(n: Int): List<Int> {
|
||||
var count = 0
|
||||
val realN = if (n > size) size else n
|
||||
val realN = if (n > size()) size() else n
|
||||
val list = ArrayList<Int>(realN)
|
||||
for (item in this) {
|
||||
if (count++ == realN)
|
||||
@@ -990,7 +990,7 @@ public fun IntArray.take(n: Int): List<Int> {
|
||||
*/
|
||||
public fun LongArray.take(n: Int): List<Long> {
|
||||
var count = 0
|
||||
val realN = if (n > size) size else n
|
||||
val realN = if (n > size()) size() else n
|
||||
val list = ArrayList<Long>(realN)
|
||||
for (item in this) {
|
||||
if (count++ == realN)
|
||||
@@ -1005,7 +1005,7 @@ public fun LongArray.take(n: Int): List<Long> {
|
||||
*/
|
||||
public fun ShortArray.take(n: Int): List<Short> {
|
||||
var count = 0
|
||||
val realN = if (n > size) size else n
|
||||
val realN = if (n > size()) size() else n
|
||||
val list = ArrayList<Short>(realN)
|
||||
for (item in this) {
|
||||
if (count++ == realN)
|
||||
@@ -1020,7 +1020,7 @@ public fun ShortArray.take(n: Int): List<Short> {
|
||||
*/
|
||||
public fun <T> Collection<T>.take(n: Int): List<T> {
|
||||
var count = 0
|
||||
val realN = if (n > size) size else n
|
||||
val realN = if (n > size()) size() else n
|
||||
val list = ArrayList<T>(realN)
|
||||
for (item in this) {
|
||||
if (count++ == realN)
|
||||
@@ -1055,7 +1055,7 @@ public fun <T> Stream<T>.take(n: Int): Stream<T> {
|
||||
* Returns a list containing first *n* elements
|
||||
*/
|
||||
public fun String.take(n: Int): String {
|
||||
return substring(0, Math.min(n, size))
|
||||
return substring(0, Math.min(n, length()))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -261,7 +261,7 @@ public fun <T> Iterable<T>.subtract(other: Iterable<T>): Set<T> {
|
||||
* Returns a mutable set containing all distinct elements from the given collection.
|
||||
*/
|
||||
public fun <T> Array<out T>.toMutableSet(): MutableSet<T> {
|
||||
val set = LinkedHashSet<T>(size)
|
||||
val set = LinkedHashSet<T>(size())
|
||||
for (item in this) set.add(item)
|
||||
return set
|
||||
}
|
||||
@@ -270,7 +270,7 @@ public fun <T> Array<out T>.toMutableSet(): MutableSet<T> {
|
||||
* Returns a mutable set containing all distinct elements from the given collection.
|
||||
*/
|
||||
public fun BooleanArray.toMutableSet(): MutableSet<Boolean> {
|
||||
val set = LinkedHashSet<Boolean>(size)
|
||||
val set = LinkedHashSet<Boolean>(size())
|
||||
for (item in this) set.add(item)
|
||||
return set
|
||||
}
|
||||
@@ -279,7 +279,7 @@ public fun BooleanArray.toMutableSet(): MutableSet<Boolean> {
|
||||
* Returns a mutable set containing all distinct elements from the given collection.
|
||||
*/
|
||||
public fun ByteArray.toMutableSet(): MutableSet<Byte> {
|
||||
val set = LinkedHashSet<Byte>(size)
|
||||
val set = LinkedHashSet<Byte>(size())
|
||||
for (item in this) set.add(item)
|
||||
return set
|
||||
}
|
||||
@@ -288,7 +288,7 @@ public fun ByteArray.toMutableSet(): MutableSet<Byte> {
|
||||
* Returns a mutable set containing all distinct elements from the given collection.
|
||||
*/
|
||||
public fun CharArray.toMutableSet(): MutableSet<Char> {
|
||||
val set = LinkedHashSet<Char>(size)
|
||||
val set = LinkedHashSet<Char>(size())
|
||||
for (item in this) set.add(item)
|
||||
return set
|
||||
}
|
||||
@@ -297,7 +297,7 @@ public fun CharArray.toMutableSet(): MutableSet<Char> {
|
||||
* Returns a mutable set containing all distinct elements from the given collection.
|
||||
*/
|
||||
public fun DoubleArray.toMutableSet(): MutableSet<Double> {
|
||||
val set = LinkedHashSet<Double>(size)
|
||||
val set = LinkedHashSet<Double>(size())
|
||||
for (item in this) set.add(item)
|
||||
return set
|
||||
}
|
||||
@@ -306,7 +306,7 @@ public fun DoubleArray.toMutableSet(): MutableSet<Double> {
|
||||
* Returns a mutable set containing all distinct elements from the given collection.
|
||||
*/
|
||||
public fun FloatArray.toMutableSet(): MutableSet<Float> {
|
||||
val set = LinkedHashSet<Float>(size)
|
||||
val set = LinkedHashSet<Float>(size())
|
||||
for (item in this) set.add(item)
|
||||
return set
|
||||
}
|
||||
@@ -315,7 +315,7 @@ public fun FloatArray.toMutableSet(): MutableSet<Float> {
|
||||
* Returns a mutable set containing all distinct elements from the given collection.
|
||||
*/
|
||||
public fun IntArray.toMutableSet(): MutableSet<Int> {
|
||||
val set = LinkedHashSet<Int>(size)
|
||||
val set = LinkedHashSet<Int>(size())
|
||||
for (item in this) set.add(item)
|
||||
return set
|
||||
}
|
||||
@@ -324,7 +324,7 @@ public fun IntArray.toMutableSet(): MutableSet<Int> {
|
||||
* Returns a mutable set containing all distinct elements from the given collection.
|
||||
*/
|
||||
public fun LongArray.toMutableSet(): MutableSet<Long> {
|
||||
val set = LinkedHashSet<Long>(size)
|
||||
val set = LinkedHashSet<Long>(size())
|
||||
for (item in this) set.add(item)
|
||||
return set
|
||||
}
|
||||
@@ -333,7 +333,7 @@ public fun LongArray.toMutableSet(): MutableSet<Long> {
|
||||
* Returns a mutable set containing all distinct elements from the given collection.
|
||||
*/
|
||||
public fun ShortArray.toMutableSet(): MutableSet<Short> {
|
||||
val set = LinkedHashSet<Short>(size)
|
||||
val set = LinkedHashSet<Short>(size())
|
||||
for (item in this) set.add(item)
|
||||
return set
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.*
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun <T> Array<out T>.toArrayList(): ArrayList<T> {
|
||||
val list = ArrayList<T>(size)
|
||||
val list = ArrayList<T>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public fun <T> Array<out T>.toArrayList(): ArrayList<T> {
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun BooleanArray.toArrayList(): ArrayList<Boolean> {
|
||||
val list = ArrayList<Boolean>(size)
|
||||
val list = ArrayList<Boolean>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public fun BooleanArray.toArrayList(): ArrayList<Boolean> {
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun ByteArray.toArrayList(): ArrayList<Byte> {
|
||||
val list = ArrayList<Byte>(size)
|
||||
val list = ArrayList<Byte>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public fun ByteArray.toArrayList(): ArrayList<Byte> {
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun CharArray.toArrayList(): ArrayList<Char> {
|
||||
val list = ArrayList<Char>(size)
|
||||
val list = ArrayList<Char>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public fun CharArray.toArrayList(): ArrayList<Char> {
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun DoubleArray.toArrayList(): ArrayList<Double> {
|
||||
val list = ArrayList<Double>(size)
|
||||
val list = ArrayList<Double>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public fun DoubleArray.toArrayList(): ArrayList<Double> {
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun FloatArray.toArrayList(): ArrayList<Float> {
|
||||
val list = ArrayList<Float>(size)
|
||||
val list = ArrayList<Float>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public fun FloatArray.toArrayList(): ArrayList<Float> {
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun IntArray.toArrayList(): ArrayList<Int> {
|
||||
val list = ArrayList<Int>(size)
|
||||
val list = ArrayList<Int>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public fun IntArray.toArrayList(): ArrayList<Int> {
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun LongArray.toArrayList(): ArrayList<Long> {
|
||||
val list = ArrayList<Long>(size)
|
||||
val list = ArrayList<Long>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public fun LongArray.toArrayList(): ArrayList<Long> {
|
||||
* Returns an ArrayList of all elements
|
||||
*/
|
||||
public fun ShortArray.toArrayList(): ArrayList<Short> {
|
||||
val list = ArrayList<Short>(size)
|
||||
val list = ArrayList<Short>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -401,7 +401,7 @@ public fun String.toLinkedList(): LinkedList<Char> {
|
||||
* Returns a List containing all key-value pairs
|
||||
*/
|
||||
public fun <K, V> Map<K, V>.toList(): List<Pair<K, V>> {
|
||||
val result = ArrayList<Pair<K, V>>(size)
|
||||
val result = ArrayList<Pair<K, V>>(size())
|
||||
for (item in this)
|
||||
result.add(item.key to item.value)
|
||||
return result
|
||||
@@ -418,7 +418,7 @@ public fun <T> Array<out T>.toList(): List<T> {
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun BooleanArray.toList(): List<Boolean> {
|
||||
val list = ArrayList<Boolean>(size)
|
||||
val list = ArrayList<Boolean>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -427,7 +427,7 @@ public fun BooleanArray.toList(): List<Boolean> {
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun ByteArray.toList(): List<Byte> {
|
||||
val list = ArrayList<Byte>(size)
|
||||
val list = ArrayList<Byte>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -436,7 +436,7 @@ public fun ByteArray.toList(): List<Byte> {
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun CharArray.toList(): List<Char> {
|
||||
val list = ArrayList<Char>(size)
|
||||
val list = ArrayList<Char>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -445,7 +445,7 @@ public fun CharArray.toList(): List<Char> {
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun DoubleArray.toList(): List<Double> {
|
||||
val list = ArrayList<Double>(size)
|
||||
val list = ArrayList<Double>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -454,7 +454,7 @@ public fun DoubleArray.toList(): List<Double> {
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun FloatArray.toList(): List<Float> {
|
||||
val list = ArrayList<Float>(size)
|
||||
val list = ArrayList<Float>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -463,7 +463,7 @@ public fun FloatArray.toList(): List<Float> {
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun IntArray.toList(): List<Int> {
|
||||
val list = ArrayList<Int>(size)
|
||||
val list = ArrayList<Int>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -472,7 +472,7 @@ public fun IntArray.toList(): List<Int> {
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun LongArray.toList(): List<Long> {
|
||||
val list = ArrayList<Long>(size)
|
||||
val list = ArrayList<Long>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
@@ -481,7 +481,7 @@ public fun LongArray.toList(): List<Long> {
|
||||
* Returns a List containing all elements
|
||||
*/
|
||||
public fun ShortArray.toList(): List<Short> {
|
||||
val list = ArrayList<Short>(size)
|
||||
val list = ArrayList<Short>(size())
|
||||
for (item in this) list.add(item)
|
||||
return list
|
||||
}
|
||||
|
||||
@@ -10,56 +10,56 @@ 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): Int {
|
||||
public fun <T> Array<out T>.binarySearch(element: T, fromIndex: Int = 0, toIndex: Int = size()): 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): Int {
|
||||
public fun ByteArray.binarySearch(element: Byte, fromIndex: Int = 0, toIndex: Int = size()): 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): Int {
|
||||
public fun CharArray.binarySearch(element: Char, fromIndex: Int = 0, toIndex: Int = size()): 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): Int {
|
||||
public fun DoubleArray.binarySearch(element: Double, fromIndex: Int = 0, toIndex: Int = size()): 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): Int {
|
||||
public fun FloatArray.binarySearch(element: Float, fromIndex: Int = 0, toIndex: Int = size()): 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): Int {
|
||||
public fun IntArray.binarySearch(element: Int, fromIndex: Int = 0, toIndex: Int = size()): 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): Int {
|
||||
public fun LongArray.binarySearch(element: Long, fromIndex: Int = 0, toIndex: Int = size()): 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): Int {
|
||||
public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex: Int = size()): Int {
|
||||
return Arrays.binarySearch(this, fromIndex, toIndex, element)
|
||||
}
|
||||
|
||||
@@ -67,63 +67,63 @@ public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex:
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun <T> Array<out T>.copyOf(): Array<T> {
|
||||
return Arrays.copyOf(this, size) as 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 {
|
||||
return Arrays.copyOf(this, size)
|
||||
return Arrays.copyOf(this, size())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun ByteArray.copyOf(): ByteArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
return Arrays.copyOf(this, size())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun CharArray.copyOf(): CharArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
return Arrays.copyOf(this, size())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun DoubleArray.copyOf(): DoubleArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
return Arrays.copyOf(this, size())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun FloatArray.copyOf(): FloatArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
return Arrays.copyOf(this, size())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun IntArray.copyOf(): IntArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
return Arrays.copyOf(this, size())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun LongArray.copyOf(): LongArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
return Arrays.copyOf(this, size())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array
|
||||
*/
|
||||
public fun ShortArray.copyOf(): ShortArray {
|
||||
return Arrays.copyOf(this, size)
|
||||
return Arrays.copyOf(this, size())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,56 +417,56 @@ public fun <T, C : MutableCollection<in R>, R : T> Stream<T>.filterIsInstanceTo(
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun <T> Array<out T>.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
public fun <T> Array<out T>.sort(fromIndex: Int = 0, toIndex: Int = size()): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
public fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size()): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
public fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size()): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
public fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size()): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
public fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size()): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
public fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size()): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
public fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size()): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts array or range in array inplace
|
||||
*/
|
||||
public fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
public fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size()): Unit {
|
||||
Arrays.sort(this, fromIndex, toIndex)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user