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>)
equals
Link copied to clipboard
common
open operator fun equals(other: Any?): Boolean
fork
Link copied to clipboard
common
open override 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
open suspend override fun next(): R
Generate next value, changing state if needed
toString
Link copied to clipboard
common
open fun toString(): String
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