Package com.github.pgreze.kounter

Types

Link copied to clipboard
typealias Counter<T> = MapWithDefault<T, Int>

A specialized MapWithDefault allowing to count multiple elements.

Link copied to clipboard
interface MutableCounter<T> : MapWithDefault<T, Int> , MutableMapWithDefault<T, Int>

Mutable alternative of Counter, also bringing the convenient addAll method.

Functions

Link copied to clipboard
fun <T> counterOf(): Counter<T>
fun <T> counterOf(items: Array<T>): Counter<T>
fun <T> counterOf(vararg keys: Pair<T, Int>): Counter<T>
fun counterOf(s: CharSequence): Counter<Char>
fun <T> counterOf(items: Iterable<T>): Counter<T>
fun <T> counterOf(items: Iterator<T>): Counter<T>
Link copied to clipboard
fun <T> mutableCounterOf(): MutableCounter<T>
fun <T> mutableCounterOf(items: Array<T>): MutableCounter<T>
fun <T> mutableCounterOf(vararg keys: Pair<T, Int>): MutableCounter<T>
fun mutableCounterOf(s: CharSequence): MutableCounter<Char>
fun <T> mutableCounterOf(items: Iterable<T>): MutableCounter<T>
fun <T> mutableCounterOf(items: Iterator<T>): MutableCounter<T>
Link copied to clipboard
fun <T> Counter<T>.plusAll(map: Map<T, Int>): Counter<T>
Link copied to clipboard
fun <T> Map<T, Int>.toCounter(): Counter<T>
Link copied to clipboard
fun <T> Counter<T>.toMutableCounter(): MutableCounter<T>