t
scalqa

Stream.Flow._extend

trait _Trait[A] extends _filter[A] with _flow[A] with _map[A] with _peek[A]

Self Type
Stream.Flow[A]
Ordering
  1. Alphabetic
Inherited
  1. Flow._extend
  2. Flow._extend._peek
  3. Flow._extend._map
  4. Flow._extend._flow
  5. Flow._extend._filter
  6. Flow._extend.Z.Shared
  7. scala.AnyRef
  8. scala.Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Method

  1. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  2. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  3. def collect[B](f: PartialFunction[A, B])(implicit arg0: Tag[B]): Flow[B]

    Filter and converter

    Filter and converter

    Only lets elements for which given PartialFinction is defined

    The elements are converted to returned type

    def all = ~~[Any] + "ABC" + 1 + 22.0 + "DE" + 333F + "F"
    
    all.lp                                     // Prints ~(ABC, 1, 22.0, DE, 333.0, F)
    
    all.collect{
        case s: String if (s.length > 1) => s
    }.lp                                       // Prints ~(ABC, DE)

    Note. collect always requires double evaluation for each element, so letMap is preferred in many cases

    Definition Classes
    Shared
  4. def drop(f: Filter[A]): Flow[A]

    Reversed filter

    Reversed filter

    Discards all the elements satisfying the filter

    (1 to 10).all.drop(_ % 2 == 0).lp // Prints: ~(1, 3, 5, 7, 9)
    Definition Classes
    _filter
  5. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  6. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  7. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  8. abstract def flatMap[B](f: Mapping[A, ~[B]])(implicit arg0: Tag[B]): Flow[B]

    Map multiplier

    Map multiplier

    For every existing element, a mapped stream of elements is inserted into the pipeline

    Note. The mapping can return an empty stream, in which case total number of elements might even be reduced

    ~~(1, 2, 3).flatMap(i => Seq(i * 10, i * 100, i * 1000)).lp
    
    // Output
    ~(10, 100, 1000, 20, 200, 2000, 30, 300, 3000)
    f

    function to provide a stream of elements for each existing element

    Definition Classes
    _map
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. abstract def let(f: Filter[A]): Flow[A]

    Main filter

    Main filter

    Only lets elements satisfying the filter

    let is the main filtering method ('filter' is supported for compatibility only)

    (1 to 10).all.let(_ % 2 == 0).lp // Prints: ~(2, 4, 6, 8, 10)
    Definition Classes
    _filter
  12. def letMap[B](f: Mapping[A, Opt[B]])(implicit arg0: Tag[B]): Flow[B]

    Filter and converter

    Filter and converter

    Only lets elements for which given function returns non empty Opt

    The elements are converted to the new type

    def all = "ABC" ~+ "1" + "22" + "D" + "333" + "E"
    
    all.letMap(v => if (v.length < 2) \/ else v).lp // Prints: ~(ABC, 22, 333)
    
    all.letMap({
      case s if (s.length >= 2) => s
      case _                    => \/
    }).lp                                           // Prints: ~(ABC, 22, 333)

    Note: letMap is often a faster alternative to collect with PartialFunction, because it is evaluated just once for each element

    Definition Classes
    Shared
  13. def letType[B](implicit t: ClassTag[B]): Flow[B]

    Filter and type converter

    Filter and type converter

    Only lets elements, which are instances of the given type

    Note, the result is mapped to the specified type

    def all = ~~[Any] + "1" + 2 + 3.0 + 4l + "5"
    
    all.lp                  // Prints ~(1, 2, 3.0, 4, 5)
    
    all.letType[String].lp  // Prints ~(1, 5)
    Definition Classes
    Shared
  14. abstract def map[B](f: Mapping[A, B])(implicit arg0: Tag[B]): Flow[B]

    Element conversion

    Element conversion

    Converts every element in the pipeline with given function

    (1 to 5).all.map( _ / 2.0).lp  // Prints ~(0.5, 1.0, 1.5, 2.0, 2.5)
    Definition Classes
    _map
  15. def mapCast[B]: Flow[B]

    Element cast

    Element cast

    Casts the pipeline elements into the type specified

    def all: ~[Any] = ~~[Any] + 1 + 2 + 3
    
    all.mapCast[Int].lp   // Prints: ~(1, 2, 3)

    Note. The cast will not fail immediately, and if there is a problem, it will come up later during pumping action

    Definition Classes
    _map
  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. final def notify(): Unit
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  19. abstract def peek(c: Consumer[A]): Flow[A]

    Element access

    Element access

    Provides access to passing pipeline elements

    This method does not change pipeline type or composition in any way

    ('A' to 'C').all.peek(v => println("Passing: " + v)).count  // Returns 3
    
    // Output
    Passing: A
    Passing: B
    Passing: C
    Definition Classes
    _peek
  20. def peekIdx(c: Consumer.Idx[A], start: Int = 0): Flow[A]

    Indexed element access

    Indexed element access

    Provides access to passing pipeline elements with their index in sequence

    ('A' to 'C').all.peekIdx((i, v) => println("Peek " + i + " = " + v), 1).count // Returns 3
    
    // Output
    Peek 1 = A
    Peek 2 = B
    Peek 3 = C
    start

    starting value for element indexing

    Definition Classes
    _peek
  21. def sequential: Stream[A]

    Restore Flow to Stream

    Restore Flow to Stream

    Restores potentially parallel Flow back to Stream

    If this is already a Stream, the operation is instant, returning this

    Otherwise the operation is quite expensive

    In many cases it is advisable to consume pipeline as Flow instead of converting to Stream

    val (count, millis) = (1 to 1000).all
      .parallel                           // Switching to parallel Stream.Flow
      .peek(_ => Thread.sleep(1))         // Expensive operation
      .sequential                         // Back to Stream
      .countAndMillis
    
    println("Count = " + count + ", done in " + millis / 1000F + " secs")
    
    // Output
    Count = 1000, done in 0.224 secs
    
    // Note: We have 1000 elements each pausing for 1 millis.
    //       Without parallel processing total time would be over 1 second
    Definition Classes
    _flow
  22. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Operator

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any