PatchStreamT
Type members
Types
A scalaz.FingerTree representing the snapshot of the sequence at a certain time.
A scalaz.FingerTree representing the snapshot of the sequence at a certain time.
- Note:
The measurement of this scalaz.FingerTree is the size.
Value members
Concrete methods
Givens
Givens
Inherited givens
- Inherited from:
- LowPriority0
Extensions
Extensions
Returns a new data-binding sequence by applying a function to all elements of this sequence and using the elements of the resulting collections.
Returns a new data-binding sequence by applying a function to all elements of this sequence and using the elements of the resulting collections.
Whenever upstream
or one of the subsequence changes, the result
sequence changes accordingly. The time complexity to update the result
sequence, when upstream
changes, is O(log(n) + c)
, where n
is the
size of upstream
, and c
is number of elements in upstream
, mapped
to mutable subsequences by f
, of which the indices in upstream
are
changing. For example, if the size of upstream
is 10 and 4 elements of
them mapped to mutable subsequences, when an element is prepended to
upstream
, c
is 4. However when an element is appended to upstream
,
c
is zero, because no element's index in `upstream is changed.
The time complexity to update the result sequence, when one of the
subsequence changes, is O(log(n))
, where n
is the size of
upstream
.
- Example:
Given a source PatchStreamT from an iterable,
import scala.concurrent.Future import scalaz.std.scalaFuture.given val bindingSeq = PatchStreamT.fromIterable[Future, String](Seq("foo", "bar"))
when flat-mapping it to more PatchStreamT,
val flatten = bindingSeq.flatMap { s => PatchStreamT.fromIterable(s) }
then it should returns a StreamT including each intermediate states during flat-mapping
import com.thoughtworks.dsl.keywords.Await import com.thoughtworks.dsl.macros.Reset.Default.* `*`[Future] { val snapshotLazyList = !Await(flatten.snapshots.toLazyList) snapshotLazyList.map(_.toList.mkString) should be( LazyList( "", "foo", "foobar", ) ) }
Return a CovariantStreamT, whose each element is a scalaz.FingerTree representing the snapshot of the sequence at that time.
Return a CovariantStreamT, whose each element is a scalaz.FingerTree representing the snapshot of the sequence at that time.
- Note:
The measurement of the scalaz.FingerTree is the size.
- Example:
Given a PatchStreamT created from an iterable,
import scala.concurrent.Future import scalaz.std.scalaFuture.given val bindingSeq = PatchStreamT.fromIterable[Future, String](Seq("foo", "bar", "baz"))
when taking snapshots,
val snapshots = bindingSeq.snapshots
then it should contains an empty value and an initial value
import com.thoughtworks.dsl.keywords.Await import com.thoughtworks.dsl.macros.Reset.Default.* `*`[Future] { val snapshotLazyList = !Await(snapshots.toLazyList) inside(snapshotLazyList) { case LazyList(empty, initial) => empty.toList should be(Nil) initial.toList should be(List("foo", "bar", "baz")) } }