Package kotlin

Core API

See:
          Description

Classes Summary
ComparableRange
ImmutableArrayListBuilder
Pair
Triple
 

Property Summary
val
javaClass: Class<T>
           
 

Function Summary
fun String(stringBuffer: StringBuffer): String
fun String(stringBuilder: StringBuilder): String
fun String(bytes: ByteArray): String
fun String(bytes: ByteArray, charset: Charset): String
fun String(bytes: ByteArray, i: Int, i1: Int): String
fun String(bytes: ByteArray, offset: Int, length: Int, charset: Charset): String
fun String(bytes: ByteArray, offset: Int, length: Int, charsetName: String): String
fun String(bytes: ByteArray, charsetName: String): String
fun String(chars: CharArray): String
fun <T>
T
annotationType(): Class<T>
fun <T>
array(vararg t: T): Array<T>
fun <T>
arrayList(vararg values: T): ArrayList<T>
fun <T>
arrayListOf(vararg values: T): ArrayList<T>
Returns a new ArrayList with a variable number of initial elements
fun assert(value: Boolean, [message: Any]): Unit
Throws an AssertionError with an optional message if the value is false
and runtime assertions have been enabled on the JVM using the -ea JVM option.
fun assert(value: Boolean, lazyMessage: () -> String): Unit
Throws an AssertionError with the specified lazyMessage if the value is false
and runtime assertions have been enabled on the JVM using the -ea JVM option.
fun booleanArray(vararg content: Boolean): BooleanArray
fun byteArray(vararg content: Byte): ByteArray
fun <T>
callable(action: () -> T): Callable<T>
A helper method for creating a Callable from a function
fun charArray(vararg content: Char): CharArray
fun check(value: Boolean, [message: Any]): Unit
Throws an IllegalStateException with an optional message if the value is false.
fun check(value: Boolean, lazyMessage: () -> String): Unit
Throws an IllegalStateException with the lazyMessage if the value is false.
fun <T>
checkNotNull(value: T?, [message: String]): T
Throws an IllegalStateException with the given message if the value is null otherwise
the not null value is returned.
fun checkStepIsPositive(isPositive: Boolean, step: Number): Unit
fun <T>
comparator(vararg functions: (T) -> Any): Comparator<T>
Creates a comparator using the sequence of functions used to calculate a value to compare on
fun <T>
comparator(fn: (T, T) -> Int): Comparator<T>
Creates a comparator using the sequence of functions used to calculate a value to compare on
fun <T>
compareBy(a: T?, b: T?, vararg functions: (T) -> Any): Int
Helper method for implementing Comparable methods using a list of functions
to calculate the values to compare
fun <T>
compareValues(a: T?, b: T?): Int
Compares the two values which may be Comparable otherwise
they are compared via #equals() and if they are not the same then
the #hashCode() method is used as the difference
fun <T>
countTo(n: Int): (T) -> Boolean
fun doubleArray(vararg content: Double): DoubleArray
fun floatArray(vararg content: Float): FloatArray
fun <K, V>
hashMap(vararg values: Pair<K, V>): HashMap<K, V>
fun <K, V>
hashMapOf(vararg values: Pair<K, V>): HashMap<K, V>
Returns a new HashMap populated with the given tuple values where the first value in each tuple
is the key and the second value is the value
fun <T>
hashSet(vararg values: T): HashSet<T>
fun <T>
hashSetOf(vararg values: T): HashSet<T>
Returns a new HashSet with a variable number of initial elements
fun intArray(vararg content: Int): IntArray
fun <T>
iterate(nextFunction: () -> T?): Iterator<T>
Returns an iterator which invokes the function to calculate the next value on each iteration until the function returns null
fun <T>
javaClass(): Class<T>
fun <T>
linkedList(vararg values: T): LinkedList<T>
fun <T>
linkedListOf(vararg values: T): LinkedList<T>
Returns a new LinkedList with a variable number of initial elements
fun <K, V>
linkedMap(vararg values: Pair<K, V>): LinkedHashMap<K, V>
fun <K, V>
linkedMapOf(vararg values: Pair<K, V>): LinkedHashMap<K, V>
Returns a new LinkedHashMap populated with the given tuple values where the first value in each tuple
is the key and the second value is the value. This map preserves insertion order so iterating through
the map’s entries will be in the same order
fun <T>
listBuilder(): ImmutableArrayListBuilder<T>
fun <T>
listOf(vararg values: T): List<T>
Returns a new read-only list of given elements
fun longArray(vararg content: Long): LongArray
fun <K, V>
mapOf(vararg values: Pair<K, V>): Map<K, V>
Returns a new read-only map of given pairs, where the first value is the key, and the second is value
fun <T>
T
rangeTo(that: T): ComparableRange<T>
fun require(value: Boolean, [message: Any]): Unit
Throws an IllegalArgumentException with an optional message if the value is false.
fun require(value: Boolean, lazyMessage: () -> String): Unit
Throws an IllegalArgumentException with the lazyMessage if the value is false.
fun <T>
requireNotNull(value: T?, [message: Any]): T
Throws an IllegalArgumentException with the given message if the value is null otherwise
the not null value is returned.
fun <T>
run(f: () -> T): T
Run function f
fun runnable(action: () -> Unit): Runnable
A helper method for creating a Runnable from a function
fun <T>
setOf(vararg values: T): Set<T>
Returns a new read-only set of given elements
fun shortArray(vararg content: Short): ShortArray
fun <K, V>
sortedMap(vararg values: Pair<K, V>): SortedMap<K, V>
fun <K, V>
sortedMapOf(vararg values: Pair<K, V>): SortedMap<K, V>
Returns a new SortedMap populated with the given tuple values where the first value in each tuple
is the key and the second value is the value
fun <T>
sortedSet(comparator: Comparator<T>, vararg values: T): TreeSet<T>
fun <T>
sortedSet(vararg values: T): TreeSet<T>
fun <T>
sortedSetOf(comparator: Comparator<T>, vararg values: T): TreeSet<T>
Returns a new SortedSet with the given comparator and the initial elements
fun <T>
sortedSetOf(vararg values: T): TreeSet<T>
Returns a new SortedSet with the initial elements
fun <A, B>
A
to(that: B): Pair<A, B>
Creates a tuple of type Pair from this and that which can be useful for creating Map literals
with less noise, for example
 

Extensions Summary
java.util.Enumeration hashCode iterator
jet.Any hashCode
jet.Array all any appendString copyOf copyOfRange count drop dropWhile dropWhileTo fill filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode isEmpty makeString map mapTo notEmpty orEmpty partition plus reduce reduceRight requireNoNulls reverse take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedSet
jet.Boolean hashCode toString
jet.BooleanArray all any appendString copyOf copyOfRange count drop dropWhile dropWhileTo fill filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedSet
jet.Byte downTo hashCode toString
jet.ByteArray all any appendString binarySearch copyOf copyOfRange count drop dropWhile dropWhileTo fill filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode inputStream makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse sort take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedSet toString
jet.ByteProgression all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.ByteRange all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.Char downTo hashCode isDefined isDigit isHighSurrogate isISOControl isIdentifierIgnorable isJavaIdentifierPart isJavaIdentifierStart isJavaLetter isJavaLetterOrDigit isLowerCase isUpperCase isWhitespace toString
jet.CharArray all any appendString binarySearch copyOf copyOfRange count drop dropWhile dropWhileTo fill filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse sort take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedSet
jet.CharProgression all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.CharRange all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.CharSequence charAt get hashCode iterator length subSequence toString
jet.Collection all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo notEmpty orEmpty partition plus reduce reduceRight requireNoNulls reverse sort sortBy take takeWhile takeWhileTo toArray toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.Double downTo hashCode toString
jet.DoubleArray all any appendString binarySearch copyOf copyOfRange count drop dropWhile dropWhileTo fill filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse sort take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedSet
jet.DoubleProgression all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.DoubleRange all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.Entry component1 component2 hashCode
jet.Float downTo hashCode toString
jet.FloatArray all any appendString binarySearch copyOf copyOfRange count drop dropWhile dropWhileTo fill filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse sort take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedSet
jet.FloatProgression all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.FloatRange all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.Int downTo hashCode times toString
jet.IntArray all any appendString binarySearch copyOf copyOfRange count drop dropWhile dropWhileTo fill filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse sort take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedSet
jet.IntProgression all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.IntRange all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.Iterable all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse sort sortBy take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.Iterator all any appendString count dropWhileTo filter filterIsInstance filterNot filterNotNull filterNotNullTo filterNotTo filterTo find flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode makeString map partition plus reduce reduceRight requireNoNulls reverse take takeWhile takeWhileTo toArrayList toCollection toHashSet toLinkedList toLinkedSet toList toSet toSortedSet
jet.List all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo notEmpty orEmpty partition plus reduce reduceRight requireNoNulls reverse sort sortBy take takeWhile takeWhileTo toArray toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.Long downTo hashCode toString
jet.LongArray all any appendString binarySearch copyOf copyOfRange count drop dropWhile dropWhileTo fill filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse sort take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedSet
jet.LongProgression all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.LongRange all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.Map getOrElse hashCode iterator map mapTo mapValues mapValuesTo orEmpty toLinkedMap toMap toProperties toSortedMap
jet.MutableIterable all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse sort sortBy take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.MutableMap getOrElse getOrPut hashCode iterator map mapTo mapValues mapValuesTo orEmpty putAll set toLinkedMap toMap toProperties toSortedMap
jet.Set all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo notEmpty orEmpty partition plus reduce reduceRight requireNoNulls reverse sort sortBy take takeWhile takeWhileTo toArray toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.Short downTo hashCode toString
jet.ShortArray all any appendString binarySearch copyOf copyOfRange count drop dropWhile dropWhileTo fill filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse sort take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedSet
jet.ShortProgression all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.ShortRange all any appendString containsItem count drop dropWhile dropWhileTo filter filterNot filterNotNull filterNotNullTo filterNotTo filterTo find first flatMap flatMapTo fold foldRight forEach groupBy groupByTo hashCode last makeString map mapTo partition plus reduce reduceRight requireNoNulls reverse reversed sort sortBy step take takeWhile takeWhileTo toCollection toLinkedList toList toSet toSortedList toSortedSet withIndices
jet.String all any appendString capitalize charAt codePointAt codePointBefore codePointCount compareToIgnoreCase concat contains contentEquals count decapitalize drop dropWhile dropWhileTo endsWith equalsIgnoreCase filter filterNot filterNotTo filterTo find findNot flatMap flatMapTo fold foldRight forEach format get getBytes getChars groupBy groupByTo hashCode indexOf intern isEmpty iterator lastIndexOf length makeString matches notEmpty offsetByCodePoints orEmpty partition reduce reduceRight regionMatches repeat replace replaceAll replaceFirst reverse split startsWith subSequence substring take takeWhile takeWhileTo toBoolean toByteArray toCharArray toCharList toCollection toDouble toFloat toInt toLinkedList toList toLong toLowerCase toRegex toSet toShort toString toUpperCase trim trimLeading trimTrailing
jet.Throwable hashCode printStackTrace
 

Package kotlin Description

Collections API

There are a number of extension functions on Collection, Iterator, Map and arrays to allow easy composition collections using familiar combinators like

Functions on Collection, Map and arrays are all eager, in that methods like map() will create a complete result List when the method completes.

Functions on Iterator are lazy so that they try to return new iterators that lazily evaluate things. For example map() returns a new Iterator that lazily maps the values in the original iterator.

Preconditions

When writing code it is recommended you add checks early in a function to ensure parameters are valid. There are a number of helper methods for this:

Contents

Other

Function Detail
source

String


 fun String(stringBuffer: StringBuffer): String
source

String


 fun String(stringBuilder: StringBuilder): String
source

String


 fun String(bytes: ByteArray): String
source

String


 fun String(bytes: ByteArray, charset: Charset): String
source

String


 fun String(bytes: ByteArray, i: Int, i1: Int): String
source

String


 fun String(bytes: ByteArray, offset: Int, length: Int, charset: Charset): String
source

String


 fun String(bytes: ByteArray, offset: Int, length: Int, charsetName: String): String
source

String


 fun String(bytes: ByteArray, charsetName: String): String
source

String


 fun String(chars: CharArray): String
source

annotationType


 fun <T> T.annotationType(): Class<T>
source

array


 fun <T> array(vararg t: T): Array<T>
source

arrayList


 fun <T> arrayList(vararg values: T): ArrayList<T>
source

arrayListOf


 fun <T> arrayListOf(vararg values: T): ArrayList<T>

Returns a new ArrayList with a variable number of initial elements

source

assert


 fun assert(value: Boolean,  [message: Any]): Unit

Throws an AssertionError with an optional message if the value is false
and runtime assertions have been enabled on the JVM using the -ea JVM option.

source

assert


 fun assert(value: Boolean, lazyMessage: () -> String): Unit

Throws an AssertionError with the specified lazyMessage if the value is false
and runtime assertions have been enabled on the JVM using the -ea JVM option.

source

booleanArray


 fun booleanArray(vararg content: Boolean): BooleanArray
source

byteArray


 fun byteArray(vararg content: Byte): ByteArray
source

callable


 fun <T> callable(action: () -> T): Callable<T>

A helper method for creating a Callable from a function

source

charArray


 fun charArray(vararg content: Char): CharArray
source

check


 fun check(value: Boolean,  [message: Any]): Unit

Throws an IllegalStateException with an optional message if the value is false.

source
val error = failsWith(javaClass<IllegalStateException>()) { check(false, "Hello") } assertEquals("Hello", error.getMessage())
source

check


 fun check(value: Boolean, lazyMessage: () -> String): Unit

Throws an IllegalStateException with the lazyMessage if the value is false.

source
val error = failsWith(javaClass<IllegalStateException>()) { check(false) {"Hello"} } assertEquals("Hello", error.getMessage())
source

checkNotNull


 fun <T> checkNotNull(value: T?,  [message: String]): T

Throws an IllegalStateException with the given message if the value is null otherwise
the not null value is returned.

source
val s1: String? = "S1" val r1: String = checkNotNull(s1) assertEquals("S1", r1)
source

checkStepIsPositive


 fun checkStepIsPositive(isPositive: Boolean, step: Number): Unit
source

comparator


 fun <T> comparator(vararg functions: (T) -> Any): Comparator<T>

Creates a comparator using the sequence of functions used to calculate a value to compare on

source

comparator


 fun <T> comparator(fn: (T, T) -> Int): Comparator<T>

Creates a comparator using the sequence of functions used to calculate a value to compare on

source

compareBy


 fun <T> compareBy(a: T?, b: T?, vararg functions: (T) -> Any): Int

Helper method for implementing Comparable methods using a list of functions
to calculate the values to compare

source

compareValues


 fun <T> compareValues(a: T?, b: T?): Int

Compares the two values which may be Comparable otherwise
they are compared via #equals() and if they are not the same then
the #hashCode() method is used as the difference

source

countTo


 fun <T> countTo(n: Int): (T) -> Boolean
source

doubleArray


 fun doubleArray(vararg content: Double): DoubleArray
source

floatArray


 fun floatArray(vararg content: Float): FloatArray
source

hashMap


 fun <K, V> hashMap(vararg values: Pair<K, V>): HashMap<K, V>
source

hashMapOf


 fun <K, V> hashMapOf(vararg values: Pair<K, V>): HashMap<K, V>

Returns a new HashMap populated with the given tuple values where the first value in each tuple
is the key and the second value is the value

source
val map = hashMap(Pair("a", 1), Pair("b", 2)) assertEquals(2, map.size) assertEquals(1, map.get("a")) assertEquals(2, map.get("b"))
source

hashSet


 fun <T> hashSet(vararg values: T): HashSet<T>
source

hashSetOf


 fun <T> hashSetOf(vararg values: T): HashSet<T>

Returns a new HashSet with a variable number of initial elements

source

intArray


 fun intArray(vararg content: Int): IntArray
source

iterate


 fun <T> iterate(nextFunction: () -> T?): Iterator<T>

Returns an iterator which invokes the function to calculate the next value on each iteration until the function returns null

source
// fibonacci terms var index = 0; var a = 0; var b = 1 return iterate<Int> { when (index++) { 0 -> a; 1 -> b; else -> { val result = a + b; a = b; b = result; result } } }
source

javaClass


 fun <T> javaClass(): Class<T>
source

linkedList


 fun <T> linkedList(vararg values: T): LinkedList<T>
source

linkedListOf


 fun <T> linkedListOf(vararg values: T): LinkedList<T>

Returns a new LinkedList with a variable number of initial elements

source

linkedMap


 fun <K, V> linkedMap(vararg values: Pair<K, V>): LinkedHashMap<K, V>
source

linkedMapOf


 fun <K, V> linkedMapOf(vararg values: Pair<K, V>): LinkedHashMap<K, V>

Returns a new LinkedHashMap populated with the given tuple values where the first value in each tuple
is the key and the second value is the value. This map preserves insertion order so iterating through
the map’s entries will be in the same order

source
val map = linkedMap(Pair("c", 3), Pair("b", 2), Pair("a", 1)) assertEquals(1, map.get("a")) assertEquals(2, map.get("b")) assertEquals(3, map.get("c")) assertEquals(arrayList("c", "b", "a"), map.keySet().toList())
source

listBuilder


 fun <T> listBuilder(): ImmutableArrayListBuilder<T>
source

listOf


 fun <T> listOf(vararg values: T): List<T>

Returns a new read-only list of given elements

source

longArray


 fun longArray(vararg content: Long): LongArray
source

mapOf


 fun <K, V> mapOf(vararg values: Pair<K, V>): Map<K, V>

Returns a new read-only map of given pairs, where the first value is the key, and the second is value

source

rangeTo


 fun <T> T.rangeTo(that: T): ComparableRange<T>
source

require


 fun require(value: Boolean,  [message: Any]): Unit

Throws an IllegalArgumentException with an optional message if the value is false.

source
val error = failsWith(javaClass<IllegalArgumentException>()) { require(false, "Hello") } assertEquals("Hello", error.getMessage())
source

require


 fun require(value: Boolean, lazyMessage: () -> String): Unit

Throws an IllegalArgumentException with the lazyMessage if the value is false.

source
val error = failsWith(javaClass<IllegalArgumentException>()) { require(false) {"Hello"} } assertEquals("Hello", error.getMessage())
source

requireNotNull


 fun <T> requireNotNull(value: T?,  [message: Any]): T

Throws an IllegalArgumentException with the given message if the value is null otherwise
the not null value is returned.

source
val s1: String? = "S1" val r1: String = requireNotNull(s1) assertEquals("S1", r1)
source

run


 fun <T> run(f: () -> T): T

Run function f

source

runnable


 fun runnable(action: () -> Unit): Runnable

A helper method for creating a Runnable from a function

source

setOf


 fun <T> setOf(vararg values: T): Set<T>

Returns a new read-only set of given elements

source

shortArray


 fun shortArray(vararg content: Short): ShortArray
source

sortedMap


 fun <K, V> sortedMap(vararg values: Pair<K, V>): SortedMap<K, V>
source

sortedMapOf


 fun <K, V> sortedMapOf(vararg values: Pair<K, V>): SortedMap<K, V>

Returns a new SortedMap populated with the given tuple values where the first value in each tuple
is the key and the second value is the value

source
val map = sortedMap(Pair("c", 3), Pair("b", 2), Pair("a", 1)) assertEquals(1, map.get("a")) assertEquals(2, map.get("b")) assertEquals(3, map.get("c")) assertEquals(arrayList("a", "b", "c"), map.keySet()!!.toList())
source

sortedSet


 fun <T> sortedSet(comparator: Comparator<T>, vararg values: T): TreeSet<T>
source

sortedSet


 fun <T> sortedSet(vararg values: T): TreeSet<T>
source

sortedSetOf


 fun <T> sortedSetOf(comparator: Comparator<T>, vararg values: T): TreeSet<T>

Returns a new SortedSet with the given comparator and the initial elements

source

sortedSetOf


 fun <T> sortedSetOf(vararg values: T): TreeSet<T>

Returns a new SortedSet with the initial elements

source

to


 fun <A, B> A.to(that: B): Pair<A, B>

Creates a tuple of type Pair from this and that which can be useful for creating Map literals
with less noise, for example

source
val map = hashMap("a" to 1, "b" to 2) assertEquals(2, map.size) assertEquals(1, map.get("a")) assertEquals(2, map.get("b"))



Copyright © 2010-2012. All Rights Reserved.