StatefulChain

class StatefulChain<S, out R>(state: S, seed: S.() -> R, forkState: (S) -> S, gen: suspend S.(R) -> R) : Chain<R>

A chain with possibly mutable state. The state must not be changed outside the chain. Two chins should never share the state.

Parameters

S

the state of the chain.

forkState

the function to copy current state without modifying it.

Constructors

StatefulChain
Link copied to clipboard
common
fun <S, out R> StatefulChain(state: S, seed: S.() -> R, forkState: (S) -> S, gen: suspend S.(R) -> R)
the state of the chain.

Functions

collect
Link copied to clipboard
common
open suspend override fun collect(collector: FlowCollector<R>)
fork
Link copied to clipboard
common
open suspend override fun fork(): Chain<R>
Create a copy of current chain state.
next
Link copied to clipboard
common
open suspend override fun next(): R
Generate next value, changing state if needed
value
Link copied to clipboard
common
fun value(): R?

Properties

gen
Link copied to clipboard
common
val gen: suspend S.(R) -> R
value
Link copied to clipboard
common
var value: R? = null

Sources

common source
Link copied to clipboard