<commit_before>@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("CollectionsKt")

package moe.pine.rx.collections

import rx.Observable

/**
 * Collection Utils for Observable
 * Created by pine on 2016/02/20.
 */
fun <T> Observable<T>.filterIndexed(predicate: (Int, T) -> Boolean): Observable<T> {
    return this.withIndex().filter { predicate(it.index, it.value) }.map { it.value }
}

inline fun <reified R> Observable<*>.filterIsInstance(): Observable<R> {
    return this.filter { it is R }.map { it as R }
}

fun <R> Observable<*>.filterIsInstance(klass: Class<R>): Observable<R> {
    @Suppress("UNCHECKED_CAST")
    return this.filter { klass.isInstance(it) }.map { it as R }
}

fun <T> Observable<T>.filterNot(predicate: (T) -> Boolean): Observable<T> {
    return this.filter { !predicate(it) }
}

fun <T : Any> Observable<out T?>.filterNotNull(): Observable<T> {
    @Suppress("UNCHECKED_CAST")
    return this.filter { it != null }.map { it as T }
}

fun <T> Observable<Iterable<out T>>.flatten(): Observable<T> {
    return this.flatMapIterable { it }
}

fun <T> Observable<T>.isNotEmpty(): Observable<Boolean> {
    return this.isEmpty.map { !it }
}

fun <T, R> Observable<out T>.mapIndexed(transform: (Int, T) -> R): Observable<R> {
    return this.withIndex().map { transform(it.index, it.value) }
}

fun <T, R: Any> Observable<out T>.mapIndexedNotNull(transform: (Int, T) -> R?): Observable<R> {
    return this.mapIndexed(transform).filterNotNull()
}

fun <T, R : Any> Observable<T>.mapNotNull(transform: (T) -> R?): Observable<R> {<commit_msg>fix(Collections): fix wanrings<commit_after>@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("CollectionsKt")

package moe.pine.rx.collections

import rx.Observable

/**
 * Collection Utils for Observable
 * Created by pine on 2016/02/20.
 */
fun <T> Observable<T>.filterIndexed(predicate: (Int, T) -> Boolean): Observable<T> {
    return this.withIndex().filter { predicate(it.index, it.value) }.map { it.value }
}

inline fun <reified R> Observable<*>.filterIsInstance(): Observable<R> {
    return this.filter { it is R }.map { it as R }
}

fun <R> Observable<*>.filterIsInstance(klass: Class<R>): Observable<R> {
    @Suppress("UNCHECKED_CAST")
    return this.filter { klass.isInstance(it) }.map { it as R }
}

fun <T> Observable<T>.filterNot(predicate: (T) -> Boolean): Observable<T> {
    return this.filter { !predicate(it) }
}

fun <T : Any> Observable<out T?>.filterNotNull(): Observable<T> {
    @Suppress("UNCHECKED_CAST")
    return this.filter { it != null }.map { it as T }
}

fun <T> Observable<Iterable<T>>.flatten(): Observable<T> {
    return this.flatMapIterable { it }
}

fun <T> Observable<T>.isNotEmpty(): Observable<Boolean> {
    return this.isEmpty.map { !it }
}

fun <T, R> Observable<out T>.mapIndexed(transform: (Int, T) -> R): Observable<R> {
    return this.withIndex().map { transform(it.index, it.value) }
}

fun <T, R: Any> Observable<out T>.mapIndexedNotNull(transform: (Int, T) -> R?): Observable<R> {
    return this.mapIndexed(transform).filterNotNull()
}

fun <T, R : Any> Observable<T>.mapNotNull(transform: (T) -> R?): Observable<R> {
{'fraction_non_alphanumeric': 0.1725229503007281, 'fraction_numerical': 0.005064893953782843, 'mean_word_length': 4.467128027681661, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6956184', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1114, 'n_words': 257}