t
scalqa

Stream._extend._filter

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

Filter Interface

Base word let means 'allow only' certain elements trough the pipeline

Base word drop means 'discard' certain elements from the pipeline

Self Type
Stream[A]
Ordering
  1. Alphabetic
Inherited
  1. Stream._extend._filter
  2. Stream.Flow._extend._filter
  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. def collect[B](f: PartialFunction[A, B])(implicit arg0: Tag[B]): Stream[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
    _filter → Shared
  4. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  5. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. def filter(f: Filter[A]): Stream[A]

    Same as let

    Same as let

    filter operation is left for compatibility

    let is the canonical filter

    Definition Classes
    _filter
  7. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  8. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  9. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  10. def let(f: Filter[A]): Stream[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_filter
  11. def letAll(that: ~[A])(implicit o: Ordering[A] = null): ~[A]

    Group filter

    Group filter

    Only lets elements equal to the found in that stream

    val idx = (1 to 5).all.flatMap(i => Seq(i,i,i)).to[Idx]
    
    idx.all.lp                        // Prints: ~(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5)
    
    idx.all.letAll(3 to 7).lp         // Prints: ~(3, 3, 3, 4, 4, 4, 5, 5, 5)
    
    idx.all.letAll(List(2, 5, 11)).lp // Prints: ~(2, 2, 2, 5, 5, 5)

    Note. The operation is very efficient if streams are sorted

    Definition Classes
    _filter
  12. def letAllBy[B](f: Mapping[A, B], that: ~[B])(implicit o: Ordering[B] = null): ~[A]

    Property group filter

    Property group filter

    Only lets elements, which produce property value equal to the found in that stream

    ~~("abc", "d", "e", "", "fg", "hijk").letAllBy(_.length, Seq(0, 1, 2)).lp
    
    // Output
    ~(d, e, , fg)
    Definition Classes
    _filter
  13. def letIdx(f: Filter.Idx[A], start: Int = 0): ~[A]

    Indexed filter

    Indexed filter

    Only lets elements satisfying the filter

    ('a' to 'z').all.letIdx((i, v) => i >= 2 && i <= 7, 1).lp
    
    // Output
    ~(b, c, d, e, f, g)
    start

    the starting indexing value

    Definition Classes
    _filter
  14. def letLast(number: Int): ~[A]

    Sequence tail filter

    Sequence tail filter

    Only lets specified number of last elements

    (1 to 10).all.letLast(3).lp  // Prints  ~(8, 9, 10)
    Definition Classes
    _filter
  15. def letMap[B](f: Mapping[A, Opt[B]])(implicit i: Tag[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)

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

    Definition Classes
    _filter → Shared
  16. def letNext(number: Int): ~[A]

    Sequence head filter

    Sequence head filter

    Only lets specified number of next elements

    Note: This might look like take, but it is more efficient (take immediately iterates the elements creating a new stream)

    (1 to 10).all.letNext(3).lp  // Prints  ~(1, 2, 3)
    Definition Classes
    _filter
  17. def letRange(r: Range): ~[A]

    Sequence range filter

    Sequence range filter

    Only lets elements within given index range

    ('a' to 'z').all.letRange(1 to 7).lp
    
    // Output
    ~(b, c, d, e, f, g, h)
    Definition Classes
    _filter
  18. 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
    _filter → Shared
  19. def letWhile(f: Filter[A]): ~[A]

    Sequence head filter

    Sequence head filter

    Only lets first consecutive elements satisfying the filter

    Note, everything starting from the first non compliant element will be discarded (including later compliant elements)

    def all = (1 to 5).all +~ (1 to 5)
    
    all.lp                     // Prints ~(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)
    
    all.letWhile(_ <= 3).lp    // Prints ~(1, 2, 3)
    Definition Classes
    _filter
  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  23. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  24. def toString(): String
    Definition Classes
    AnyRef → Any
  25. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. def drop(f: Filter[A]): Stream[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_filter
  29. def dropAll(a: ~[A])(implicit o: Ordering[A] = null): ~[A]

    Group reversed filter

    Group reversed filter

    Discards all elements equal to the found in that stream

    val idx = (1 to 5).all.flatMap(i => Seq(i, i, i)).to[Idx]
    
    idx.all.lp                         // Prints: ~(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5)
    
    idx.all.dropAll(3 to 7).lp         // Prints: ~(1, 1, 1, 2, 2, 2)
    
    idx.all.dropAll(List(2, 5, 11)).lp // Prints: ~(1, 1, 1, 3, 3, 3, 4, 4, 4)

    Note. The operation is very efficient if streams are sorted

    Definition Classes
    _filter
  30. def dropAllBy[B](f: Mapping[A, B], a: ~[B])(implicit o: Ordering[B] = null): ~[A]

    Property group reversed filter

    Property group reversed filter

    Discards elements, which produce property value equal to the found in that stream

    ~~("abc", "d", "e", "", "fg", "hijk").dropAllBy(_.length, Seq(0, 3)).lp
    
    // Output
    ~(d, e, fg, hijk)
    Definition Classes
    _filter
  31. def dropEverythingIf(b: Boolean): ~[A]

    Discarding everything

    Discarding everything

    With a single test lets to drop the entire pipeline in favor of void instance

    Note: This can also be done with 'if-else' outside the pipeline, however it proved to be useful with really long statements

    (1 to 10).all.dropEverythingIf(true).lp  // Prints ~()
    Definition Classes
    _filter
  32. def dropLast(number: Int): ~[A]

    Sequence tail reversed filter

    Sequence tail reversed filter

    Discards the last consecutive number of elements

    (1 to 10).all.dropLast(3).lp // Prints ~(1, 2, 3, 4, 5, 6, 7)
    Definition Classes
    _filter
  33. def dropNext(number: Int): ~[A]

    Sequence head reversed filter

    Sequence head reversed filter

    Discards the first consecutive number of elements

    (1 to 10).all.dropNext(3).lp // Prints ~(4, 5, 6, 7, 8, 9, 10)
    Definition Classes
    _filter
  34. def dropRange(r: Range): ~[A]

    Sequence range reversed filter

    Sequence range reversed filter

    Discards elements, which fall within the specified range

    (1 to 10).all.dropRange(3 to 7).lp  // Prints ~(1, 2, 3, 9, 10)
    Definition Classes
    _filter
  35. def dropWhile(f: Filter[A]): ~[A]

    Sequence head reversed filter

    Sequence head reversed filter

    Discards first consecutive elements satisfying the filter

    Note, everything starting from the first non compliant element will be allowed (including later compliant elements)

    def all = (1 to 5).all +~ (1 to 5)
    
    all.lp                     // Prints ~(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)
    
    all.dropWhile(_ <= 3).lp   // Prints ~(4, 5, 1, 2, 3, 4, 5)
    Definition Classes
    _filter

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