t

Stream._extend._map

trait _map[A] extends Stream.Flow._extend._map[A]

Stream Conversion Interface

Stream map changes elements type

Self Type
Stream[A]
Ordering
  1. Alphabetic
Inherited
  1. Stream._extend._map
  2. Stream.Flow._extend._map
  3. Stream.Flow._extend.Z.Shared
  4. scala.AnyRef
  5. 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. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  4. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  6. def flatMap[B](f: Mapping[A, ~[B]])(implicit i: Ilk[B]): Stream[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

    f

    function to provide a stream of elements for each existing element

    Definition Classes
    _map_map
    Example:
    1. ~.*(1, 2, 3).flatMap(i => ~.*(i * 10, i * 100, i * 1000)).lp
      
      // Output
      ~(10, 100, 1000, 20, 200, 2000, 30, 300, 3000)
  7. def flatten[B](implicit f: Mapping[A, ~[B]], i: Ilk[B]): Stream[B]

    Converts a stream of streams into a flat stream

    Converts a stream of streams into a flat stream

    val stream: ~[~[Char]] = ~.*(
      'a' <> 'd',
      List('x', 'y', 'z'),
      Vector('v', 'e', 'c', 't', 'o', 'r'))
    
    stream.flatten.lp // Prints: ~(a, b, c, d, x, y, z, v, e, c, t, o, r)
    Definition Classes
    _map
  8. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  9. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  10. def letLookup[B](f: PartialFunction[A, B])(implicit arg0: Ilk[B]): Stream[B]

    Filter and converter

    Filter and converter

    Only lets elements for which given PartialFinction is defined

    The elements are converted to the new type

    def all = ~[Any] + "ABC" + 1 + 22.0 + "DE" + 333F + "F"
    
    all.letLookup({ case s: String if (s.length > 1) => s }).lp
    
    // Output
    ~(ABC, DE)
    Definition Classes
    _map → Shared
    Note

    'letLookup' always requires double evaluation for each element, so 'letMap' is preferred in many cases

  11. def letMap[B](f: Mapping[A, Opt[B]])(implicit i: Ilk[B]): Stream[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)
    
    all.letMap(_.toIntOut.valueOpt).lp              // Prints: ~(1, 22, 333)

    Note: 'letMap' is a better alternative to letLookup with PartialFunction, because it is evaluated just once for each element

    Definition Classes
    _map → Shared
  12. def letType[B](implicit t: ClassTag[B]): Stream[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
    _map → Shared
  13. def map[B](f: Mapping[A, B])(implicit i: Ilk[B]): Stream[B]

    Element conversion

    Element conversion

    Converts every element in the pipeline with given function

    (1 <> 5).all.map( _ / 2.0).lp
    
    // Output
    ~(0.5, 1.0, 1.5, 2.0, 2.5)
    Definition Classes
    _map_map
  14. def mapIdx[B](f: Mapping.Idx[A, B], start: Int = 0)(implicit i: Ilk[B]): ~[B]

    Indexed element conversion

    Indexed element conversion

    Converts every element in the pipeline with given function

    f

    the conversion function which also accepts element index in the sequence

    start

    the starting value of indexing

    Definition Classes
    _map
    Example:
    1. ('A' <> 'G').all.mapIdx(_ + "=" + _, 1).lp
      
      // Output
      ~(1=A, 2=B, 3=C, 4=D, 5=E, 6=F, 7=G)
  15. def mapRef[B](f: Mapping[A, B])(implicit i: Ilk[B]): ~[B]

    Non - specialized mapping

    Non - specialized mapping

    Logically same as map, mapRef will box primitives if they are involved

    Should be rarely used for testing and special cases

    Definition Classes
    _map
  16. def mapType[B]: Stream[B]

    Element cast

    Element cast

    Casts the pipeline elements into the type specified

    def all: ~[Any] = 1 ~+ 2 + 3
    
    all.mapType[Int].lp // Prints: ~(1, 2, 3)
    Definition Classes
    _map_map
    Note

    If there is a problem for element casting, it will come up later during pumping action

  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. final def notify(): Unit
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  20. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  21. def toString(): String
    Definition Classes
    AnyRef → Any
  22. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. 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
Linear Supertypes
Stream.Flow._extend._map[A], Shared[A], AnyRef, Any
Source: _map.scala