Chain

interface Chain<out R> : Flow<R>

A not-necessary-Markov chain of some type

Parameters

R
  • the chain element type

Types

Companion
Link copied to clipboard
common
object Companion

Functions

collect
Link copied to clipboard
common
open suspend override fun collect(collector: FlowCollector<R>)
equals
Link copied to clipboard
common
open operator fun equals(other: Any?): Boolean
fork
Link copied to clipboard
common
abstract fun fork(): Chain<R>
Create a copy of current chain state.
hashCode
Link copied to clipboard
common
open fun hashCode(): Int
next
Link copied to clipboard
common
abstract suspend fun next(): R
Generate next value, changing state if needed
toString
Link copied to clipboard
common
open fun toString(): String

Inheritors

BlockingIntChain
Link copied to clipboard
BlockingRealChain
Link copied to clipboard
SimpleChain
Link copied to clipboard
MarkovChain
Link copied to clipboard
StatefulChain
Link copied to clipboard
ConstantChain
Link copied to clipboard

Extensions

asSequence
Link copied to clipboard
fun <R> Chain<R>.asSequence(): Sequence<R>
Represent a chain as a sequence
collect
Link copied to clipboard
common
fun <T, R> Chain<T>.collect(mapper: suspend (Chain<T>) -> R): Chain<R>
Map the whole chain
collectWithState
Link copied to clipboard
common
fun <T, S, R> Chain<T>.collectWithState(state: S, stateFork: (S) -> S, mapper: suspend S.(Chain<T>) -> R): Chain<R>
filter
Link copied to clipboard
common
fun <T> Chain<T>.filter(block: (T) -> Boolean): Chain<T>
block must be a pure function or at least not use external random variables, otherwise fork could be broken
iterator
Link copied to clipboard
operator fun <R> Chain<R>.iterator(): Iterator<R>
Represent a chain as regular iterator (uses blocking calls)
map
Link copied to clipboard
common
fun <T, R> Chain<T>.map(func: suspend (T) -> R): Chain<R>
Map the chain result using suspended transformation.
zip
Link copied to clipboard
common
fun <T, U, R> Chain<T>.zip(other: Chain<U>, block: suspend (T, U) -> R): Chain<R>
Zip two chains together using given transformation