standard library: added isEmpty/isNotEmpty functions for primitive arrays

This commit is contained in:
nik
2013-12-01 15:02:45 +04:00
committed by Evgeny Gerashchenko
parent b636538422
commit 45e9211943
12 changed files with 171 additions and 6 deletions
@@ -183,6 +183,20 @@ public inline fun <K> BooleanArray.groupByTo(result: MutableMap<K, MutableList<B
return result
}
/**
* Returns true if the array is empty
*/
public fun BooleanArray.isEmpty() : Boolean {
return size == 0
}
/**
* Returns true if the array is empty
*/
public fun BooleanArray.isNotEmpty() : Boolean {
return !isEmpty()
}
/**
* Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied.
* 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
@@ -183,6 +183,20 @@ public inline fun <K> ByteArray.groupByTo(result: MutableMap<K, MutableList<Byte
return result
}
/**
* Returns true if the array is empty
*/
public fun ByteArray.isEmpty() : Boolean {
return size == 0
}
/**
* Returns true if the array is empty
*/
public fun ByteArray.isNotEmpty() : Boolean {
return !isEmpty()
}
/**
* Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied.
* 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
@@ -183,6 +183,20 @@ public inline fun <K> CharArray.groupByTo(result: MutableMap<K, MutableList<Char
return result
}
/**
* Returns true if the array is empty
*/
public fun CharArray.isEmpty() : Boolean {
return size == 0
}
/**
* Returns true if the array is empty
*/
public fun CharArray.isNotEmpty() : Boolean {
return !isEmpty()
}
/**
* Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied.
* 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
@@ -183,6 +183,20 @@ public inline fun <K> DoubleArray.groupByTo(result: MutableMap<K, MutableList<Do
return result
}
/**
* Returns true if the array is empty
*/
public fun DoubleArray.isEmpty() : Boolean {
return size == 0
}
/**
* Returns true if the array is empty
*/
public fun DoubleArray.isNotEmpty() : Boolean {
return !isEmpty()
}
/**
* Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied.
* 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
@@ -183,6 +183,20 @@ public inline fun <K> FloatArray.groupByTo(result: MutableMap<K, MutableList<Flo
return result
}
/**
* Returns true if the array is empty
*/
public fun FloatArray.isEmpty() : Boolean {
return size == 0
}
/**
* Returns true if the array is empty
*/
public fun FloatArray.isNotEmpty() : Boolean {
return !isEmpty()
}
/**
* Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied.
* 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
@@ -183,6 +183,20 @@ public inline fun <K> IntArray.groupByTo(result: MutableMap<K, MutableList<Int>>
return result
}
/**
* Returns true if the array is empty
*/
public fun IntArray.isEmpty() : Boolean {
return size == 0
}
/**
* Returns true if the array is empty
*/
public fun IntArray.isNotEmpty() : Boolean {
return !isEmpty()
}
/**
* Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied.
* 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
@@ -183,6 +183,20 @@ public inline fun <K> LongArray.groupByTo(result: MutableMap<K, MutableList<Long
return result
}
/**
* Returns true if the array is empty
*/
public fun LongArray.isEmpty() : Boolean {
return size == 0
}
/**
* Returns true if the array is empty
*/
public fun LongArray.isNotEmpty() : Boolean {
return !isEmpty()
}
/**
* Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied.
* 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
@@ -183,6 +183,20 @@ public inline fun <K> ShortArray.groupByTo(result: MutableMap<K, MutableList<Sho
return result
}
/**
* Returns true if the array is empty
*/
public fun ShortArray.isEmpty() : Boolean {
return size == 0
}
/**
* Returns true if the array is empty
*/
public fun ShortArray.isNotEmpty() : Boolean {
return !isEmpty()
}
/**
* Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied.
* 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