|
|||||||||||
| FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | PROPERTY | CONSTR | FUNCTION | DETAIL: PROPERTY | CONSTR | FUNCTION | ||||||||||
| Function Summary | ||
|---|---|---|
fun BooleanArray |
all(predicate: (Boolean) -> Boolean): Boolean
Returns true if all elements match the given predicate |
|
fun BooleanArray |
any(predicate: (Boolean) -> Boolean): Boolean
Returns true if any elements match the given predicate |
|
fun BooleanArray |
appendString(buffer: Appendable, [separator: String, prefix: String, postfix: String, limit: Int, truncated: String]): Unit
Appends the string from all the elements separated using the separator and using the given prefix and postfix if supplied |
|
fun BooleanArray |
copyOf( [newLength: Int]): BooleanArray
|
|
fun BooleanArray |
copyOfRange(from: Int, to: Int): BooleanArray
|
|
fun BooleanArray |
count(predicate: (Boolean) -> Boolean): Int
Returns the number of elements which match the given predicate |
|
fun BooleanArray |
drop(n: Int): List<Boolean>
Returns a list containing everything but the first n elements |
|
fun BooleanArray |
dropWhile(predicate: (Boolean) -> Boolean): List<Boolean>
Returns a list containing the everything but the first elements that satisfy the given predicate |
|
|
dropWhileTo(result: L, predicate: (Boolean) -> Boolean): L
Returns a list containing the everything but the first elements that satisfy the given predicate |
|
fun BooleanArray |
fill(value: Boolean): Unit
|
|
fun BooleanArray |
filter(predicate: (Boolean) -> Boolean): List<Boolean>
Returns a list containing all elements which match the given predicate |
|
fun BooleanArray |
filterNot(predicate: (Boolean) -> Boolean): List<Boolean>
Returns a list containing all elements which do not match the given predicate |
|
fun BooleanArray |
filterNotNull(): List<Boolean>
Returns a list containing all the non-null elements |
|
|
filterNotNullTo(result: C): C
Filters all non-null elements into the given list |
|
|
filterNotTo(result: C, predicate: (Boolean) -> Boolean): C
Returns a list containing all elements which do not match the given predicate |
|
|
filterTo(result: C, predicate: (Boolean) -> Boolean): C
Filters all elements which match the given predicate into the given list |
|
fun BooleanArray |
find(predicate: (Boolean) -> Boolean): Boolean
Returns the first element which matches the given predicate or null if none matched |
|
|
flatMap(transform: (Boolean) -> Collection<R>): Collection<R>
Returns the result of transforming each element to one or more values which are concatenated together into a single collection |
|
|
flatMapTo(result: MutableCollection<R>, transform: (Boolean) -> Collection<R>): Collection<R>
Returns the result of transforming each element to one or more values which are concatenated together into a single list |
|
|
fold(initial: R, operation: (R, Boolean) -> R): R
Folds all elements from from left to right with the initial value to perform the operation on sequential pairs of elements |
|
|
foldRight(initial: R, operation: (Boolean, R) -> R): R
Folds all elements from right to left with the initial value to perform the operation on sequential pairs of elements |
|
fun BooleanArray |
forEach(operation: (Boolean) -> Unit): Unit
Performs the given operation on each element |
|
|
groupBy(toKey: (Boolean) -> K): Map<K, List<Boolean>>
Groups the elements in the collection into a new Map using the supplied toKey function to calculate the key to group the elements by |
|
|
groupByTo(result: MutableMap<K, MutableList<Boolean>>, toKey: (Boolean) -> K): Map<K, MutableList<Boolean>>
Groups the elements in the collection into the given Map using the supplied toKey function to calculate the key to group the elements by |
|
fun Any |
hashCode(): Int
A helper method for calling hashCode() on Kotlin objects TODO remove when Any supports equals() and hashCode() |
|
fun BooleanArray |
makeString( [separator: String, prefix: String, postfix: String, limit: Int, truncated: String]): String
Creates a string from all the elements separated using the separator and using the given prefix and postfix if supplied. |
|
|
map(transform: (Boolean) -> R): List<R>
Returns a new List containing the results of applying the given transform function to each element in this collection |
|
|
mapTo(result: C, transform: (Boolean) -> R): C
Transforms each element of this collection with the given transform function and adds each return value to the given results collection |
|
fun BooleanArray |
partition(predicate: (Boolean) -> Boolean): Pair<List<Boolean>, List<Boolean>>
Partitions this collection into a pair of collection |
|
fun BooleanArray |
plus(element: Boolean): List<Boolean>
Creates a copy of this collection as a List with the element added at the end |
|
fun BooleanArray |
plus(elements: BooleanArray): List<Boolean>
Creates a copy of this collection as a List with all the elements added at the end |
|
fun BooleanArray |
reduce(operation: (Boolean, Boolean) -> Boolean): Boolean
Applies binary operation to all elements of iterable, going from left to right. Similar to fold function, but uses the first element as initial value |
|
fun BooleanArray |
reduceRight(operation: (Boolean, Boolean) -> Boolean): Boolean
Applies binary operation to all elements of iterable, going from right to left. Similar to foldRight function, but uses the last element as initial value |
|
fun BooleanArray |
requireNoNulls(): List<Boolean>
Returns a list containing all the non-null elements, throwing an IllegalArgumentException if there are any null elements |
|
fun BooleanArray |
reverse(): List<Boolean>
Reverses the order the elements into a list |
|
fun BooleanArray |
take(n: Int): List<Boolean>
Returns a list containing the first n elements |
|
fun BooleanArray |
takeWhile(predicate: (Boolean) -> Boolean): List<Boolean>
Returns a list containing the first elements that satisfy the given predicate |
|
|
takeWhileTo(result: C, predicate: (Boolean) -> Boolean): C
Returns a list containing the first elements that satisfy the given predicate |
|
fun BooleanArray |
toCollection(): Collection<Boolean>
Copies all elements into a [[List] |
|
|
toCollection(result: C): C
Copies all elements into the given collection |
|
fun BooleanArray |
toLinkedList(): LinkedList<Boolean>
Copies all elements into a LinkedList |
|
fun BooleanArray |
toList(): List<Boolean>
Copies all elements into a List |
|
fun BooleanArray |
toSet(): Set<Boolean>
Copies all elements into a Set |
|
fun BooleanArray |
toSortedSet(): SortedSet<Boolean>
Copies all elements into a SortedSet |
|
| Function Detail |
|---|
fun BooleanArray.all(predicate: (Boolean) -> Boolean): Boolean
Returns true if all elements match the given predicate
val data = arrayList("foo", "bar")
assertTrue {
data.all{it.length == 3}
}
assertNot {
data.all{s -> s.startsWith("b")}
}
fun BooleanArray.any(predicate: (Boolean) -> Boolean): Boolean
Returns true if any elements match the given predicate
val data = arrayList("foo", "bar")
assertTrue {
data.any{it.startsWith("f")}
}
assertNot {
data.any{it.startsWith("x")}
}
fun BooleanArray.appendString(buffer: Appendable, [separator: String, prefix: String, postfix: String, limit: Int, truncated: String]): Unit
Appends the 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
a special truncated separator (which defaults to “…”
val data = arrayList("foo", "bar")
val buffer = StringBuilder()
val text = data.appendString(buffer, "-", "{", "}")
assertEquals("{foo-bar}", buffer.toString())
fun BooleanArray.count(predicate: (Boolean) -> Boolean): Int
Returns the number of elements which match the given predicate
val data = arrayList("foo", "bar")
assertEquals(1, data.count{it.startsWith("b")})
assertEquals(2, data.count{it.size == 3})
fun BooleanArray.drop(n: Int): List<Boolean>
Returns a list containing everything but the first n elements
val coll = arrayList("foo", "bar", "abc")
assertEquals(arrayList("bar", "abc"), coll.drop(1))
assertEquals(arrayList("abc"), coll.drop(2))
fun BooleanArray.dropWhile(predicate: (Boolean) -> Boolean): List<Boolean>
Returns a list containing the everything but the first elements that satisfy the given predicate
val coll = arrayList("foo", "bar", "abc")
assertEquals(arrayList("bar", "abc"), coll.dropWhile{ it.startsWith("f") })
fun <L> BooleanArray.dropWhileTo(result: L, predicate: (Boolean) -> Boolean): L
Returns a list containing the everything but the first elements that satisfy the given predicate
fun BooleanArray.filter(predicate: (Boolean) -> Boolean): List<Boolean>
Returns a list containing all elements which match the given predicate
val data = arrayList("foo", "bar")
val foo = data.filter{it.startsWith("f")}
assertTrue {
foo.all{it.startsWith("f")}
}
assertEquals(1, foo.size)
assertEquals(arrayList("foo"), foo)
fun BooleanArray.filterNot(predicate: (Boolean) -> Boolean): List<Boolean>
Returns a list containing all elements which do not match the given predicate
val data = arrayList("foo", "bar")
val foo = data.filterNot{it.startsWith("b")}
assertTrue {
foo.all{it.startsWith("f")}
}
assertEquals(1, foo.size)
assertEquals(arrayList("foo"), foo)
fun BooleanArray.filterNotNull(): List<Boolean>
Returns a list containing all the non-null elements
val data = arrayList(null, "foo", null, "bar")
val foo = data.filterNotNull()
assertEquals(2, foo.size)
assertEquals(arrayList("foo", "bar"), foo)
assertTrue {
foo is List<String>
}
fun <C> BooleanArray.filterNotNullTo(result: C): C
Filters all non-null elements into the given list
@includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
fun <C> BooleanArray.filterNotTo(result: C, predicate: (Boolean) -> Boolean): C
Returns a list containing all elements which do not match the given predicate
@includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
fun <C> BooleanArray.filterTo(result: C, predicate: (Boolean) -> Boolean): C
Filters all elements which match the given predicate into the given list
@includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
fun BooleanArray.find(predicate: (Boolean) -> Boolean): Boolean
Returns the first element which matches the given predicate or null if none matched
val data = arrayList("foo", "bar")
val x = data.find{it.startsWith("x")}
assertNull(x)
val f = data.find{it.startsWith("f")}
f!!
assertEquals("foo", f)
fun <R> BooleanArray.flatMap(transform: (Boolean) -> Collection<R>): Collection<R>
Returns the result of transforming each element to one or more values which are concatenated together into a single collection
@includeFunctionBody ../../test/CollectionTest.kt flatMap
fun <R> BooleanArray.flatMapTo(result: MutableCollection<R>, transform: (Boolean) -> Collection<R>): Collection<R>
Returns the result of transforming each element to one or more values which are concatenated together into a single list
@includeFunctionBody ../../test/CollectionTest.kt flatMap
fun <R> BooleanArray.fold(initial: R, operation: (R, Boolean) -> R): R
Folds all elements from from left to right with the initial value to perform the operation on sequential pairs of elements
// lets calculate the sum of some numbers
expect(10) {
val numbers = arrayList(1, 2, 3, 4)
numbers.fold(0){ a, b -> a + b}
}
expect(0) {
val numbers = arrayList<Int>()
numbers.fold(0){ a, b -> a + b}
}
// lets concatenate some strings
expect("1234") {
val numbers = arrayList(1, 2, 3, 4)
numbers.map{it.toString()}.fold(""){ a, b -> a + b}
}
fun <R> BooleanArray.foldRight(initial: R, operation: (Boolean, R) -> R): R
Folds all elements from right to left with the initial value to perform the operation on sequential pairs of elements
expect("1234") {
val numbers = arrayList(1, 2, 3, 4)
numbers.map{it.toString()}.foldRight(""){ a, b -> a + b}
}
fun BooleanArray.forEach(operation: (Boolean) -> Unit): Unit
Performs the given operation on each element
val data = arrayList("foo", "bar")
var count = 0
data.forEach{ count += it.length }
assertEquals(6, count)
fun <K> BooleanArray.groupBy(toKey: (Boolean) -> K): Map<K, List<Boolean>>
Groups the elements in the collection into a new Map using the supplied toKey function to calculate the key to group the elements by
val words = arrayList("a", "ab", "abc", "def", "abcd")
val byLength = words.groupBy{ it.length }
assertEquals(4, byLength.size())
val l3 = byLength.getOrElse(3, {ArrayList<String>()})
assertEquals(2, l3.size)
fun <K> BooleanArray.groupByTo(result: MutableMap<K, MutableList<Boolean>>, toKey: (Boolean) -> K): Map<K, MutableList<Boolean>>
Groups the elements in the collection into the given Map using the supplied toKey function to calculate the key to group the elements by
val words = arrayList("a", "ab", "abc", "def", "abcd")
val byLength = words.groupBy{ it.length }
assertEquals(4, byLength.size())
val l3 = byLength.getOrElse(3, {ArrayList<String>()})
assertEquals(2, l3.size)
fun Any.hashCode(): Int
A helper method for calling hashCode() on Kotlin objects
TODO remove when Any supports equals() and hashCode()
fun BooleanArray.makeString( [separator: String, prefix: String, postfix: String, limit: Int, truncated: String]): String
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
a special truncated separator (which defaults to “…”
val data = arrayList("foo", "bar")
val text = data.makeString("-", "<", ">")
assertEquals("<foo-bar>", text)
val big = arrayList("a", "b", "c", "d" , "e", "f")
val text2 = big.makeString(limit = 3, truncated = "*")
assertEquals("a, b, c, *", text2)
fun <R> BooleanArray.map(transform: (Boolean) -> R): List<R>
Returns a new List containing the results of applying the given transform function to each element in this collection
val data = arrayList("foo", "bar")
val lengths = data.map{ it.length }
assertTrue {
lengths.all{it == 3}
}
assertEquals(2, lengths.size)
assertEquals(arrayList(3, 3), lengths)
fun <R, C> BooleanArray.mapTo(result: C, transform: (Boolean) -> R): C
Transforms each element of this collection with the given transform function and
adds each return value to the given results collection
fun BooleanArray.partition(predicate: (Boolean) -> Boolean): Pair<List<Boolean>, List<Boolean>>
Partitions this collection into a pair of collection
val data = arrayList("foo", "bar", "something", "xyz")
val pair = data.partition{it.size == 3}
assertEquals(arrayList("foo", "bar", "xyz"), pair.first, "pair.first")
assertEquals(arrayList("something"), pair.second, "pair.second")
fun BooleanArray.plus(element: Boolean): List<Boolean>
Creates a copy of this collection as a List with the element added at the end
val list = arrayList("foo", "bar")
val list2 = list + "cheese"
assertEquals(arrayList("foo", "bar"), list)
assertEquals(arrayList("foo", "bar", "cheese"), list2)
// lets use a mutable variable
var list3 = arrayList("a", "b")
list3 += "c"
assertEquals(arrayList("a", "b", "c"), list3)
fun BooleanArray.plus(elements: BooleanArray): List<Boolean>
Creates a copy of this collection as a List with all the elements added at the end
val a = arrayList("foo", "bar")
val b = arrayList("cheese", "wine")
val list = a + b
assertEquals(arrayList("foo", "bar", "cheese", "wine"), list)
// lets use a mutable variable
var ml = a
ml += "beer"
ml += b
ml += "z"
assertEquals(arrayList("foo", "bar", "beer", "cheese", "wine", "z"), ml)
fun BooleanArray.reduce(operation: (Boolean, Boolean) -> Boolean): Boolean
Applies binary operation to all elements of iterable, going from left to right.
Similar to fold function, but uses the first element as initial value
expect("1234") {
val list = arrayList("1", "2", "3", "4")
list.reduce { a, b -> a + b }
}
failsWith(javaClass<UnsupportedOperationException>()) {
arrayList<Int>().reduce { a, b -> a + b}
}
fun BooleanArray.reduceRight(operation: (Boolean, Boolean) -> Boolean): Boolean
Applies binary operation to all elements of iterable, going from right to left.
Similar to foldRight function, but uses the last element as initial value
expect("1234") {
val list = arrayList("1", "2", "3", "4")
list.reduceRight { a, b -> a + b }
}
failsWith(javaClass<UnsupportedOperationException>()) {
arrayList<Int>().reduceRight { a, b -> a + b}
}
fun BooleanArray.requireNoNulls(): List<Boolean>
Returns a list containing all the non-null elements, throwing an IllegalArgumentException if there are any null elements
val data = arrayList<String?>("foo", "bar")
val notNull = data.requireNoNulls()
assertEquals(arrayList("foo", "bar"), notNull)
val hasNulls = arrayList("foo", null, "bar")
failsWith(javaClass<IllegalArgumentException>()) {
// should throw an exception as we have a null
hasNulls.requireNoNulls()
}
fun BooleanArray.reverse(): List<Boolean>
Reverses the order the elements into a list
val data = arrayList("foo", "bar")
val rev = data.reverse()
assertEquals(arrayList("bar", "foo"), rev)
fun BooleanArray.take(n: Int): List<Boolean>
Returns a list containing the first n elements
val coll = arrayList("foo", "bar", "abc")
assertEquals(arrayList("foo"), coll.take(1))
assertEquals(arrayList("foo", "bar"), coll.take(2))
fun BooleanArray.takeWhile(predicate: (Boolean) -> Boolean): List<Boolean>
Returns a list containing the first elements that satisfy the given predicate
val coll = arrayList("foo", "bar", "abc")
assertEquals(arrayList("foo"), coll.takeWhile{ it.startsWith("f") })
assertEquals(arrayList("foo", "bar", "abc"), coll.takeWhile{ it.size == 3 })
fun <C> BooleanArray.takeWhileTo(result: C, predicate: (Boolean) -> Boolean): C
Returns a list containing the first elements that satisfy the given predicate
fun BooleanArray.toCollection(): Collection<Boolean>
Copies all elements into a [[List]
fun <C> BooleanArray.toCollection(result: C): C
Copies all elements into the given collection
fun BooleanArray.toLinkedList(): LinkedList<Boolean>
Copies all elements into a LinkedList
|
||||||||||
| FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | PROPERTY | CONSTR | FUNCTION | DETAIL: PROPERTY | CONSTR | FUNCTION | |||||||||