Packages

c

fs2.Segment

Force

final class Force[+O, +R] extends AnyVal

Operations on a Segment which force evaluation of some part or all of a segments elements.

Source
Segment.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Force
  2. AnyVal
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Force(self: Segment[O, R])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from Force[O, R] to any2stringadd[Force[O, R]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Force[O, R], B)
    Implicit
    This member is added by an implicit conversion from Force[O, R] to ArrowAssoc[Force[O, R]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. final def drop(n: Long): Either[(R, Long), Segment[O, R]]

    Eagerly drops n elements from the head of this segment, returning either the result and the number of elements remaining to drop, if the end of the segment was reached, or a new segment, if the end of the segment was not reached.

    Eagerly drops n elements from the head of this segment, returning either the result and the number of elements remaining to drop, if the end of the segment was reached, or a new segment, if the end of the segment was not reached.

    Example:
    1. scala> Segment(1,2,3,4,5).force.drop(3).toOption.get.force.toVector
      res0: Vector[Int] = Vector(4, 5)
      scala> Segment(1,2,3,4,5).force.drop(7)
      res1: Either[(Unit, Long),Segment[Int,Unit]] = Left(((),2))
  8. final def dropWhile(p: (O) ⇒ Boolean, dropFailure: Boolean = false): Either[R, Segment[O, R]]

    Eagerly drops elements from the head of this segment until the supplied predicate returns false, returning either the result, if the end of the segment was reached without the predicate failing, or the remaining segment.

    Eagerly drops elements from the head of this segment until the supplied predicate returns false, returning either the result, if the end of the segment was reached without the predicate failing, or the remaining segment.

    If dropFailure is true, the first element that failed the predicate will be dropped. If false, the first element that failed the predicate will be the first element of the remainder.

    Example:
    1. scala> Segment(1,2,3,4,5).force.dropWhile(_ < 3).map(_.force.toVector)
      res0: Either[Unit,Vector[Int]] = Right(Vector(3, 4, 5))
      scala> Segment(1,2,3,4,5).force.dropWhile(_ < 10)
      res1: Either[Unit,Segment[Int,Unit]] = Left(())
  9. def ensuring(cond: (Force[O, R]) ⇒ Boolean, msg: ⇒ Any): Force[O, R]
    Implicit
    This member is added by an implicit conversion from Force[O, R] to Ensuring[Force[O, R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: (Force[O, R]) ⇒ Boolean): Force[O, R]
    Implicit
    This member is added by an implicit conversion from Force[O, R] to Ensuring[Force[O, R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean, msg: ⇒ Any): Force[O, R]
    Implicit
    This member is added by an implicit conversion from Force[O, R] to Ensuring[Force[O, R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: Boolean): Force[O, R]
    Implicit
    This member is added by an implicit conversion from Force[O, R] to Ensuring[Force[O, R]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def foreach(f: (O) ⇒ Unit): R

    Invokes f on each output of this segment.

    Invokes f on each output of this segment.

    Example:
    1. scala> val buf = collection.mutable.ListBuffer[Int]()
      scala> Segment(1,2,3).cons(0).force.foreach(i => buf += i)
      res0: Unit = ()
      scala> buf.toList
      res1: List[Int] = List(0, 1, 2, 3)
  14. def foreachChunk(f: (Chunk[O]) ⇒ Unit): R

    Invokes f on each chunk of this segment.

    Invokes f on each chunk of this segment.

    Example:
    1. scala> val buf = collection.mutable.ListBuffer[Chunk[Int]]()
      scala> Segment(1,2,3).cons(0).force.foreachChunk(c => buf += c)
      res0: Unit = ()
      scala> buf.toList
      res1: List[Chunk[Int]] = List(Chunk(0), Chunk(1, 2, 3))
  15. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from Force[O, R] to StringFormat[Force[O, R]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  16. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. final def run(implicit ev: <:<[O, Nothing]): R

    Computes the result of this segment.

    Computes the result of this segment. May only be called when O is Nothing, to prevent accidentally ignoring output values. To intentionally ignore outputs, call s.drain.force.run.

    Example:
    1. scala> Segment(1, 2, 3).withSize.drain.force.run
      res0: (Unit,Long) = ((),3)
  19. final def splitAt(n: Long, maxSteps: Option[Long] = None): Either[(R, Catenable[Chunk[O]], Long), (Catenable[Chunk[O]], Segment[O, R])]

    Splits this segment at the specified index by simultaneously taking and dropping.

    Splits this segment at the specified index by simultaneously taking and dropping.

    If the segment has less than n elements, a left is returned, providing the result of the segment, all sub-segments taken, and the remaining number of elements (i.e., size - n).

    If the segment has more than n elements, a right is returned, providing the sub-segments up to the n-th element and a remainder segment.

    The prefix is computed eagerly while the suffix is computed lazily.

    The maxSteps parameter provides a notion of fairness. If specified, steps through the staged machine are counted while executing and if the limit is reached, execution completes, returning a Right consisting of whatever elements were seen in the first maxSteps steps. This provides fairness but yielding the computation back to the caller but with less than n accumulated values.

    Example:
    1. scala> Segment(1, 2, 3, 4, 5).force.splitAt(2)
      res0: Either[(Unit,Catenable[Chunk[Int]],Long),(Catenable[Chunk[Int]],Segment[Int,Unit])] = Right((Catenable(Chunk(1, 2)),Chunk(3, 4, 5)))
      scala> Segment(1, 2, 3, 4, 5).force.splitAt(7)
      res0: Either[(Unit,Catenable[Chunk[Int]],Long),(Catenable[Chunk[Int]],Segment[Int,Unit])] = Left(((),Catenable(Chunk(1, 2, 3, 4, 5)),2))
  20. final def splitWhile(p: (O) ⇒ Boolean, emitFailure: Boolean = false): Either[(R, Catenable[Chunk[O]]), (Catenable[Chunk[O]], Segment[O, R])]

    Splits this segment at the first element where the supplied predicate returns false.

    Splits this segment at the first element where the supplied predicate returns false.

    Analagous to siumultaneously running takeWhile and dropWhile.

    If emitFailure is false, the first element which fails the predicate is returned in the suffix segment. If true, it is returned as the last element in the prefix segment.

    If the end of the segment is reached and the predicate has not failed, a left is returned, providing the segment result and the catenated sub-segments. Otherwise, a right is returned, providing the prefix sub-segments and the suffix remainder.

    Example:
    1. scala> Segment(1, 2, 3, 4, 5).force.splitWhile(_ != 3)
      res0: Either[(Unit,Catenable[Chunk[Int]]),(Catenable[Chunk[Int]],Segment[Int,Unit])] = Right((Catenable(Chunk(1, 2)),Chunk(3, 4, 5)))
      scala> Segment(1, 2, 3, 4, 5).force.splitWhile(_ != 7)
      res0: Either[(Unit,Catenable[Chunk[Int]]),(Catenable[Chunk[Int]],Segment[Int,Unit])] = Left(((),Catenable(Chunk(1, 2, 3, 4, 5))))
  21. def toArray[O2 >: O](implicit ct: ClassTag[O2]): Array[O2]

    Converts this segment to an array, discarding the result.

    Converts this segment to an array, discarding the result.

    Caution: calling toArray on an infinite sequence will not terminate.

    Example:
    1. scala> Segment(1, 2, 3).cons(0).cons(-1).force.toArray
      res0: Array[Int] = Array(-1, 0, 1, 2, 3)
  22. def toCatenable: Catenable[O]

    Converts this segment to a catenable of output values, discarding the result.

    Converts this segment to a catenable of output values, discarding the result.

    Caution: calling toCatenable on an infinite sequence will not terminate.

    Example:
    1. scala> Segment(1, 2, 3).cons(0).cons(-1).force.toCatenable.toList
      res0: List[Int] = List(-1, 0, 1, 2, 3)
  23. def toChunk: Chunk[O]

    Converts this segment to a single chunk, discarding the result.

    Converts this segment to a single chunk, discarding the result.

    Caution: calling toChunk on an infinite sequence will not terminate.

    Example:
    1. scala> Segment(1, 2, 3).cons(0).cons(-1).force.toChunk
      res0: Chunk[Int] = Chunk(-1, 0, 1, 2, 3)
  24. def toChunks: Catenable[Chunk[O]]

    Converts this segment to a sequence of chunks, discarding the result.

    Converts this segment to a sequence of chunks, discarding the result.

    Caution: calling toChunks on an infinite sequence will not terminate.

    Example:
    1. scala> Segment(1, 2, 3).cons(0).cons(-1).force.toChunks.toList
      res0: List[Chunk[Int]] = List(Chunk(-1), Chunk(0), Chunk(1, 2, 3))
  25. def toList: List[O]

    Converts this chunk to a list, discarding the result.

    Converts this chunk to a list, discarding the result.

    Caution: calling toList on an infinite sequence will not terminate.

    Example:
    1. scala> Segment(1, 2, 3).cons(0).cons(-1).force.toList
      res0: List[Int] = List(-1, 0, 1, 2, 3)
  26. def toString(): String
    Definition Classes
    Any
  27. def toVector: Vector[O]

    Converts this segment to a vector, discarding the result.

    Converts this segment to a vector, discarding the result.

    Caution: calling toVector on an infinite sequence will not terminate.

    Example:
    1. scala> Segment(1, 2, 3).cons(0).cons(-1).force.toVector
      res0: Vector[Int] = Vector(-1, 0, 1, 2, 3)
  28. final def uncons: Either[R, (Segment[O, Unit], Segment[O, R])]

    Returns the first output sub-segment of this segment along with the remainder, wrapped in Right, or if this segment is empty, returns the result wrapped in Left.

    Returns the first output sub-segment of this segment along with the remainder, wrapped in Right, or if this segment is empty, returns the result wrapped in Left.

    Example:
    1. scala> Segment(1, 2, 3).cons(0).force.uncons
      res0: Either[Unit,(Segment[Int,Unit], Segment[Int,Unit])] = Right((Chunk(0),Chunk(1, 2, 3)))
      scala> Segment.empty[Int].force.uncons
      res1: Either[Unit,(Segment[Int,Unit], Segment[Int,Unit])] = Left(())
  29. final def uncons1: Either[R, (O, Segment[O, R])]

    Returns the first output of this segment along with the remainder, wrapped in Right, or if this segment is empty, returns the result wrapped in Left.

    Returns the first output of this segment along with the remainder, wrapped in Right, or if this segment is empty, returns the result wrapped in Left.

    Annotations
    @tailrec()
    Example:
    1. scala> Segment(1, 2, 3).cons(0).force.uncons1
      res0: Either[Unit,(Int, Segment[Int,Unit])] = Right((0,Chunk(1, 2, 3)))
      scala> Segment.empty[Int].force.uncons1
      res1: Either[Unit,(Int, Segment[Int,Unit])] = Left(())
  30. final def unconsAll: (Catenable[Chunk[O]], R)

    Returns all output chunks and the result of this segment after stepping it to completion.

    Returns all output chunks and the result of this segment after stepping it to completion.

    Will not terminate if run on an infinite segment.

    Example:
    1. scala> Segment(1, 2, 3).prepend(Segment(-1, 0)).force.unconsAll
      res0: (Catenable[Chunk[Int]], Unit) = (Catenable(Chunk(-1, 0), Chunk(1, 2, 3)),())
  31. final def unconsChunk: Either[R, (Chunk[O], Segment[O, R])]

    Returns the first output chunk of this segment along with the remainder, wrapped in Right, or if this segment is empty, returns the result wrapped in Left.

    Returns the first output chunk of this segment along with the remainder, wrapped in Right, or if this segment is empty, returns the result wrapped in Left.

    Example:
    1. scala> Segment(1, 2, 3).prepend(Segment(-1, 0)).force.unconsChunk
      res0: Either[Unit,(Chunk[Int], Segment[Int,Unit])] = Right((Chunk(-1, 0),Chunk(1, 2, 3)))
      scala> Segment.empty[Int].force.unconsChunk
      res1: Either[Unit,(Chunk[Int], Segment[Int,Unit])] = Left(())
  32. final def unconsChunks: Either[R, (Catenable[Chunk[O]], Segment[O, R])]

    Returns the first output chunks of this segment along with the remainder, wrapped in Right, or if this segment is empty, returns the result wrapped in Left.

    Returns the first output chunks of this segment along with the remainder, wrapped in Right, or if this segment is empty, returns the result wrapped in Left.

    Differs from unconsChunk when a single step results in multiple outputs.

    Example:
    1. scala> Segment(1, 2, 3).prepend(Segment(-1, 0)).force.unconsChunks
      res0: Either[Unit,(Catenable[Chunk[Int]], Segment[Int,Unit])] = Right((Catenable(Chunk(-1, 0)),Chunk(1, 2, 3)))
      scala> Segment.empty[Int].force.unconsChunks
      res1: Either[Unit,(Catenable[Chunk[Int]], Segment[Int,Unit])] = Left(())
  33. def [B](y: B): (Force[O, R], B)
    Implicit
    This member is added by an implicit conversion from Force[O, R] to ArrowAssoc[Force[O, R]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyVal

Inherited from Any

Inherited by implicit conversion any2stringadd from Force[O, R] to any2stringadd[Force[O, R]]

Inherited by implicit conversion StringFormat from Force[O, R] to StringFormat[Force[O, R]]

Inherited by implicit conversion Ensuring from Force[O, R] to Ensuring[Force[O, R]]

Inherited by implicit conversion ArrowAssoc from Force[O, R] to ArrowAssoc[Force[O, R]]

Ungrouped