kotlin
Extensions on jet.BooleanArray

extension functions on class jet.BooleanArray
from package kotlin

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
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 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
fun <C>
BooleanArray
filterNotNullTo(result: C): C
Filters all non-null elements into the given list
fun <C>
BooleanArray
filterNotTo(result: C, predicate: (Boolean-> Boolean): C
Returns a list containing all elements which do not match the given predicate
fun <C>
BooleanArray
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
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
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
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
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
fun BooleanArray forEach(operation: (Boolean-> Unit): Unit
Performs the given operation on each element
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
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
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.
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
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
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
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
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
source

all


 fun BooleanArray.all(predicate: (Boolean-> Boolean): Boolean

Returns true if all elements match the given predicate

source
val data = arrayList("foo", "bar") assertTrue { data.all{it.length == 3} } assertNot { data.all{s -> s.startsWith("b")} }
source

any


 fun BooleanArray.any(predicate: (Boolean-> Boolean): Boolean

Returns true if any elements match the given predicate

source
val data = arrayList("foo", "bar") assertTrue { data.any{it.startsWith("f")} } assertNot { data.any{it.startsWith("x")} }
source

appendString


 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 “…”

source
val data = arrayList("foo", "bar") val buffer = StringBuilder() val text = data.appendString(buffer, "-", "{", "}") assertEquals("{foo-bar}", buffer.toString())
source

copyOf


 fun BooleanArray.copyOf( [newLength: Int]): BooleanArray
source

copyOfRange


 fun BooleanArray.copyOfRange(from: Int, to: Int): BooleanArray
source

count


 fun BooleanArray.count(predicate: (Boolean-> Boolean): Int

Returns the number of elements which match the given predicate

source
val data = arrayList("foo", "bar") assertEquals(1, data.count{it.startsWith("b")}) assertEquals(2, data.count{it.size == 3})
source

drop


 fun BooleanArray.drop(n: Int): List<Boolean>

Returns a list containing everything but the first n elements

source
val coll = arrayList("foo", "bar", "abc") assertEquals(arrayList("bar", "abc"), coll.drop(1)) assertEquals(arrayList("abc"), coll.drop(2))
source

dropWhile


 fun BooleanArray.dropWhile(predicate: (Boolean-> Boolean): List<Boolean>

Returns a list containing the everything but the first elements that satisfy the given predicate

source
val coll = arrayList("foo", "bar", "abc") assertEquals(arrayList("bar", "abc"), coll.dropWhile{ it.startsWith("f") })
source

dropWhileTo


 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

source

fill


 fun BooleanArray.fill(value: Boolean): Unit
source

filter


 fun BooleanArray.filter(predicate: (Boolean-> Boolean): List<Boolean>

Returns a list containing all elements which match the given predicate

source
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)
source

filterNot


 fun BooleanArray.filterNot(predicate: (Boolean-> Boolean): List<Boolean>

Returns a list containing all elements which do not match the given predicate

source
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)
source

filterNotNull


 fun BooleanArray.filterNotNull(): List<Boolean>

Returns a list containing all the non-null elements

source
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> }
source

filterNotNullTo


 fun <C> BooleanArray.filterNotNullTo(result: C): C

Filters all non-null elements into the given list

@includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList

source

filterNotTo


 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

source

filterTo


 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

source

find


 fun BooleanArray.find(predicate: (Boolean-> Boolean): Boolean

Returns the first element which matches the given predicate or null if none matched

source
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)
source

flatMap


 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

source

flatMapTo


 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

source

fold


 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

source
// 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} }
source

foldRight


 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

source
expect("1234") { val numbers = arrayList(1, 2, 3, 4) numbers.map{it.toString()}.foldRight(""){ a, b -> a + b} }
source

forEach


 fun BooleanArray.forEach(operation: (Boolean-> Unit): Unit

Performs the given operation on each element

source
val data = arrayList("foo", "bar") var count = 0 data.forEach{ count += it.length } assertEquals(6, count)
source

groupBy


 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

source
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)
source

groupByTo


 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

source
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)
source

hashCode


 fun Any.hashCode(): Int

A helper method for calling hashCode() on Kotlin objects
TODO remove when Any supports equals() and hashCode()

source

makeString


 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 “…”

source
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)
source

map


 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

source
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)
source

mapTo


 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

source

partition


 fun BooleanArray.partition(predicate: (Boolean-> Boolean): Pair<List<Boolean>, List<Boolean>>

Partitions this collection into a pair of collection

source
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")
source

plus


 fun BooleanArray.plus(element: Boolean): List<Boolean>

Creates a copy of this collection as a List with the element added at the end

source
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)
source

plus


 fun BooleanArray.plus(elements: BooleanArray): List<Boolean>

Creates a copy of this collection as a List with all the elements added at the end

source
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)
source

reduce


 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

source
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} }
source

reduceRight


 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

source
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} }
source

requireNoNulls


 fun BooleanArray.requireNoNulls(): List<Boolean>

Returns a list containing all the non-null elements, throwing an IllegalArgumentException if there are any null elements

source
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() }
source

reverse


 fun BooleanArray.reverse(): List<Boolean>

Reverses the order the elements into a list

source
val data = arrayList("foo", "bar") val rev = data.reverse() assertEquals(arrayList("bar", "foo"), rev)
source

take


 fun BooleanArray.take(n: Int): List<Boolean>

Returns a list containing the first n elements

source
val coll = arrayList("foo", "bar", "abc") assertEquals(arrayList("foo"), coll.take(1)) assertEquals(arrayList("foo", "bar"), coll.take(2))
source

takeWhile


 fun BooleanArray.takeWhile(predicate: (Boolean-> Boolean): List<Boolean>

Returns a list containing the first elements that satisfy the given predicate

source
val coll = arrayList("foo", "bar", "abc") assertEquals(arrayList("foo"), coll.takeWhile{ it.startsWith("f") }) assertEquals(arrayList("foo", "bar", "abc"), coll.takeWhile{ it.size == 3 })
source

takeWhileTo


 fun <C> BooleanArray.takeWhileTo(result: C, predicate: (Boolean-> Boolean): C

Returns a list containing the first elements that satisfy the given predicate

source

toCollection


 fun BooleanArray.toCollection(): Collection<Boolean>

Copies all elements into a [[List]

source

toCollection


 fun <C> BooleanArray.toCollection(result: C): C

Copies all elements into the given collection

source

toLinkedList


 fun BooleanArray.toLinkedList(): LinkedList<Boolean>

Copies all elements into a LinkedList

source

toList


 fun BooleanArray.toList(): List<Boolean>

Copies all elements into a List

source

toSet


 fun BooleanArray.toSet(): Set<Boolean>

Copies all elements into a Set

source

toSortedSet


 fun BooleanArray.toSortedSet(): SortedSet<Boolean>

Copies all elements into a SortedSet



Copyright © 2010-2012. All Rights Reserved.