kmongo / kotlin.collections

Package kotlin.collections

Extensions for External Classes

com.mongodb.client.MongoCursor

com.mongodb.client.MongoIterable

Functions

all

fun <T> MongoIterable<T>.all(predicate: (T) -> Boolean): Boolean

any

fun <T> MongoIterable<T>.any(): Boolean
fun <T> MongoIterable<T>.any(predicate: (T) -> Boolean): Boolean

asSequence

fun <T> MongoIterable<T>.asSequence(): Sequence<T>

associate

fun <T, K, V> MongoIterable<T>.associate(transform: (T) -> Pair<K, V>): Map<K, V>

associateBy

fun <T, K> MongoIterable<T>.associateBy(keySelector: (T) -> K): Map<K, T>
fun <T, K, V> MongoIterable<T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V>

associateByTo

fun <T, K, M : MutableMap<in K, in T>> MongoIterable<T>.associateByTo(destination: M, keySelector: (T) -> K): M
fun <T, K, V, M : MutableMap<in K, in V>> MongoIterable<T>.associateByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M

associateTo

fun <T, K, V, M : MutableMap<in K, in V>> MongoIterable<T>.associateTo(destination: M, transform: (T) -> Pair<K, V>): M

chunked

fun <T> MongoIterable<T>.chunked(size: Int): List<List<T>>
fun <T, R> MongoIterable<T>.chunked(size: Int, transform: (List<T>) -> R): List<R>

contains

operator fun <T> MongoIterable<T>.contains(element: T): Boolean

count

fun <T> MongoIterable<T>.count(): Int
fun <T> MongoIterable<T>.count(predicate: (T) -> Boolean): Int

distinct

fun <T> MongoIterable<T>.distinct(): List<T>

distinctBy

fun <T, K> MongoIterable<T>.distinctBy(selector: (T) -> K): List<T>

drop

fun <T> MongoIterable<T>.drop(n: Int): List<T>

dropWhile

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

elementAt

fun <T> MongoIterable<T>.elementAt(index: Int): T

elementAtOrElse

fun <T> MongoIterable<T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T

elementAtOrNull

fun <T> MongoIterable<T>.elementAtOrNull(index: Int): T?

filter

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

filterIndexed

fun <T> MongoIterable<T>.filterIndexed(predicate: (index: Int, T) -> Boolean): List<T>

filterIndexedTo

fun <T, C : MutableCollection<in T>> MongoIterable<T>.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C

filterIsInstance

fun <R> MongoIterable<*>.filterIsInstance(): List<R>
fun <R> MongoIterable<*>.filterIsInstance(klass: Class<R>): List<R>

filterIsInstanceTo

fun <R, C : MutableCollection<in R>> MongoIterable<*>.filterIsInstanceTo(destination: C): C
fun <C : MutableCollection<in R>, R> MongoIterable<*>.filterIsInstanceTo(destination: C, klass: Class<R>): C

filterNot

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

filterNotTo

fun <T, C : MutableCollection<in T>> MongoIterable<T>.filterNotTo(destination: C, predicate: (T) -> Boolean): C

filterTo

fun <T, C : MutableCollection<in T>> MongoIterable<T>.filterTo(destination: C, predicate: (T) -> Boolean): C

find

fun <T> MongoIterable<T>.find(predicate: (T) -> Boolean): T?

findLast

fun <T> MongoIterable<T>.findLast(predicate: (T) -> Boolean): T?

first

fun <T> MongoIterable<T>.first(predicate: (T) -> Boolean): T

firstOrNull

fun <T> MongoIterable<T>.firstOrNull(): T?
fun <T> MongoIterable<T>.firstOrNull(predicate: (T) -> Boolean): T?

flatMap

fun <T, R> MongoIterable<T>.flatMap(transform: (T) -> MongoIterable<R>): List<R>

flatMapTo

fun <T, R, C : MutableCollection<in R>> MongoIterable<T>.flatMapTo(destination: C, transform: (T) -> MongoIterable<R>): C

fold

fun <T, R> MongoIterable<T>.fold(initial: R, operation: (acc: R, T) -> R): R

foldIndexed

fun <T, R> MongoIterable<T>.foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R

forEach

fun <T> MongoIterable<T>.forEach(action: (T) -> Unit): Unit

forEachIndexed

fun <T> MongoIterable<T>.forEachIndexed(action: (index: Int, T) -> Unit): Unit

groupBy

fun <T, K> MongoIterable<T>.groupBy(keySelector: (T) -> K): Map<K, List<T>>
fun <T, K, V> MongoIterable<T>.groupBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, List<V>>

groupByTo

fun <T, K, M : MutableMap<in K, MutableList<T>>> MongoIterable<T>.groupByTo(destination: M, keySelector: (T) -> K): M
fun <T, K, V, M : MutableMap<in K, MutableList<V>>> MongoIterable<T>.groupByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M

groupingBy

(Since: 1.1)
fun <T, K> MongoIterable<T>.groupingBy(keySelector: (T) -> K): Grouping<T, K>

indexOf

fun <T> MongoIterable<T>.indexOf(element: T): Int

indexOfFirst

fun <T> MongoIterable<T>.indexOfFirst(predicate: (T) -> Boolean): Int

indexOfLast

fun <T> MongoIterable<T>.indexOfLast(predicate: (T) -> Boolean): Int

intersect

infix fun <T> MongoIterable<T>.intersect(other: Iterable<T>): Set<T>

joinTo

fun <T, A : Appendable> MongoIterable<T>.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): A

joinToString

fun <T> MongoIterable<T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String

kCursor

fun <T> MongoIterable<T>.kCursor(): MongoCursorIterable<T>

last

fun <T> MongoIterable<T>.last(): T
fun <T> MongoIterable<T>.last(predicate: (T) -> Boolean): T

lastIndexOf

fun <T> MongoIterable<T>.lastIndexOf(element: T): Int

lastOrNull

fun <T> MongoIterable<T>.lastOrNull(): T?
fun <T> MongoIterable<T>.lastOrNull(predicate: (T) -> Boolean): T?

map

fun <T, R> MongoIterable<T>.map(transform: (T) -> R): List<R>

mapIndexed

fun <T, R> MongoIterable<T>.mapIndexed(transform: (index: Int, T) -> R): List<R>

mapIndexedNotNull

fun <T, R : Any> MongoIterable<T>.mapIndexedNotNull(transform: (index: Int, T) -> R?): List<R>

mapIndexedNotNullTo

fun <T, R : Any, C : MutableCollection<in R>> MongoIterable<T>.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C

mapIndexedTo

fun <T, R, C : MutableCollection<in R>> MongoIterable<T>.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C

mapNotNull

fun <T, R : Any> MongoIterable<T>.mapNotNull(transform: (T) -> R?): List<R>

mapNotNullTo

fun <T, R : Any, C : MutableCollection<in R>> MongoIterable<T>.mapNotNullTo(destination: C, transform: (T) -> R?): C

mapTo

fun <T, R, C : MutableCollection<in R>> MongoIterable<T>.mapTo(destination: C, transform: (T) -> R): C

maxBy

fun <T, R : Comparable<R>> MongoIterable<T>.maxBy(selector: (T) -> R): T?

maxByOrNull

fun <T, R : Comparable<R>> MongoIterable<T>.maxByOrNull(selector: (T) -> R): T?

maxWith

fun <T> MongoIterable<T>.maxWith(comparator: <ERROR CLASS><in T>): T?

maxWithOrNull

fun <T> MongoIterable<T>.maxWithOrNull(comparator: <ERROR CLASS><in T>): T?

minBy

fun <T, R : Comparable<R>> MongoIterable<T>.minBy(selector: (T) -> R): T?

minByOrNull

fun <T, R : Comparable<R>> MongoIterable<T>.minByOrNull(selector: (T) -> R): T?

minus

operator fun <T> MongoIterable<T>.minus(element: T): List<T>
operator fun <T> MongoIterable<T>.minus(elements: Array<out T>): List<T>
operator fun <T> MongoIterable<T>.minus(elements: Iterable<T>): List<T>
operator fun <T> MongoIterable<T>.minus(elements: Sequence<T>): List<T>

minusElement

fun <T> MongoIterable<T>.minusElement(element: T): List<T>

minWith

fun <T> MongoIterable<T>.minWith(comparator: <ERROR CLASS><in T>): T?

minWithOrNull

fun <T> MongoIterable<T>.minWithOrNull(comparator: <ERROR CLASS><in T>): T?

none

fun <T> MongoIterable<T>.none(): Boolean
fun <T> MongoIterable<T>.none(predicate: (T) -> Boolean): Boolean

partition

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

plus

operator fun <T> MongoIterable<T>.plus(element: T): List<T>
operator fun <T> MongoIterable<T>.plus(elements: Array<out T>): List<T>
operator fun <T> MongoIterable<T>.plus(elements: Iterable<T>): List<T>
operator fun <T> MongoIterable<T>.plus(elements: Sequence<T>): List<T>

plusElement

fun <T> MongoIterable<T>.plusElement(element: T): List<T>

reduce

fun <S, T : S> MongoIterable<T>.reduce(operation: (acc: S, T) -> S): S

reduceIndexed

fun <S, T : S> MongoIterable<T>.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S

reversed

fun <T> MongoIterable<T>.reversed(): List<T>

shuffled

fun <T> MongoIterable<T>.shuffled(): List<T>
fun <T> MongoIterable<T>.shuffled(random: Random): List<T>

single

fun <T> MongoIterable<T>.single(): T
fun <T> MongoIterable<T>.single(predicate: (T) -> Boolean): T

singleOrNull

fun <T> MongoIterable<T>.singleOrNull(): T?
fun <T> MongoIterable<T>.singleOrNull(predicate: (T) -> Boolean): T?

sortedBy

fun <T, R : Comparable<R>> MongoIterable<T>.sortedBy(selector: (T) -> R?): List<T>

sortedByDescending

fun <T, R : Comparable<R>> MongoIterable<T>.sortedByDescending(selector: (T) -> R?): List<T>

sortedWith

fun <T> MongoIterable<T>.sortedWith(comparator: <ERROR CLASS><in T>): List<T>

subtract

infix fun <T> MongoIterable<T>.subtract(other: Iterable<T>): Set<T>

sumBy

fun <T> MongoIterable<T>.sumBy(selector: (T) -> Int): Int

sumByDouble

fun <T> MongoIterable<T>.sumByDouble(selector: (T) -> Double): Double

take

fun <T> MongoIterable<T>.take(n: Int): List<T>

takeWhile

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

toCollection

fun <T, C : MutableCollection<in T>> MongoIterable<T>.toCollection(destination: C): C

toHashSet

fun <T> MongoIterable<T>.toHashSet(): <ERROR CLASS><T>

toList

fun <T> MongoIterable<T>.toList(): List<T>

toMutableList

fun <T> MongoIterable<T>.toMutableList(): MutableList<T>

toMutableSet

fun <T> MongoIterable<T>.toMutableSet(): MutableSet<T>

toSet

fun <T> MongoIterable<T>.toSet(): Set<T>

toSortedSet

fun <T> MongoIterable<T>.toSortedSet(comparator: <ERROR CLASS><in T>): SortedSet<T>

union

infix fun <T> MongoIterable<T>.union(other: Iterable<T>): Set<T>

useCursor

fun <T, R> MongoIterable<T>.useCursor(block: (Iterable<T>) -> R): R

windowed

fun <T> MongoIterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): List<List<T>>
fun <T, R> MongoIterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): List<R>

withIndex

fun <T> MongoIterable<T>.withIndex(): MongoIterable<IndexedValue<T>>
fun <T> MongoCursor<T>.withIndex(): MongoCursor<IndexedValue<T>>

zip

infix fun <T, R> MongoIterable<T>.zip(other: Array<out R>): List<Pair<T, R>>
fun <T, R, V> MongoIterable<T>.zip(other: Array<out R>, transform: (a: T, b: R) -> V): List<V>
infix fun <T, R> MongoIterable<T>.zip(other: Iterable<R>): List<Pair<T, R>>
fun <T, R, V> MongoIterable<T>.zip(other: Iterable<R>, transform: (a: T, b: R) -> V): List<V>

zipWithNext

fun <T> MongoIterable<T>.zipWithNext(): List<Pair<T, T>>
fun <T, R> MongoIterable<T>.zipWithNext(transform: (a: T, b: T) -> R): List<R>