t

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. def let(f: Filter[A]): Stream[A]

    Main filter

    Main filter

    Only lets elements satisfying the filter

    let is the main filtering method. It's equivalent in Java and Scala is called filter

    (1 <> 10).all.let(_ % 2 == 0).lp // Prints: ~(2, 4, 6, 8, 10)
    Definition Classes
    _filter_filter
  2. def letAll(that: ~[A])(implicit o: Ordering[A] = \/): ~[A]

    Group filter

    Group filter

    Only lets elements equal to the found in that stream

    val idx = (1 <> 5).all.flatMap(_.I repeat 3).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 <> 7).lp      // Prints: ~(3, 3, 3, 4, 4, 4, 5, 5, 5)
    
    idx.all.letAll(2 ~+ 5 + 11).lp // Prints: ~(2, 2, 2, 5, 5, 5)
    Definition Classes
    _filter
    Note

    The operation is very efficient if streams are sorted

  3. def letAllBy[B](f: Mapping[A, B], that: ~[B])(implicit o: Ordering[B] = \/): ~[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, 0 ~+ 1 + 2).lp
    
    // Output
    ~(d, e, void, fg)
    Definition Classes
    _filter
    Note

    The operation is very efficient if streams are sorted

  4. def letAt(r: Idx.Range): ~[A]

    Sequence range filter

    Sequence range filter

    Only lets elements within given index range

    ('a' <> 'z').all.letAt(1 <> 7).lp
    
    // Output
    ~(b, c, d, e, f, g, h)
    Definition Classes
    _filter
  5. def letBy[T](as: Mapping[A, T], f: Filter[T]): Stream[A]

    Property filter

    Property filter

    Only lets elements satisfying the filter on given property

    val filter: Stream.Filter[Int] = _ >= 2
    
    ("ABC" ~+ "D" + "E" + "FG").letBy(_.length, filter).lp // Prints: ~(ABC, FG)

    Note: This might be useful when existing filters are reused

    Definition Classes
    _filter_filter
  6. def letIdx(f: Filter.Idx[A], start: Int = 0): ~[A]

    Indexed filter

    Indexed filter

    Only lets elements satisfying the filter

    f

    filter

    start

    the starting index value

    ('a' <> 'z').all.letIdx((i, v) => i >= 2 && i <= 7, 1).lp
    
    // Output
    ~(b, c, d, e, f, g)
    Definition Classes
    _filter
  7. def letLast(number: Int): ~[A]

    Sequence tail filter

    Sequence tail filter

    Only lets last number of elements

    (1 <> 10).all.letLast(3).lp
    
    // Output
    ~(8, 9, 10)
    Definition Classes
    _filter
  8. 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
    _filter → Shared
    Note

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

  9. 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
    _filter → Shared
  10. def letNext(number: Int): ~[A]

    Sequence head filter

    Sequence head filter

    Only lets first number of elements

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

    (1 <> 10).all.letNext(3).lp
    
    // Output
    ~(1, 2, 3)
    Definition Classes
    _filter
  11. 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
  12. 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 <> 5).all +~ (1 <> 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
  13. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  14. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  15. def drop(f: Filter[A]): Stream[A]

    Reversed filter

    Reversed filter

    Discards all the elements satisfying the filter

    (1 <> 10).all.drop(_ % 2 == 0).lp // Prints: ~(1, 3, 5, 7, 9)
    Definition Classes
    _filter_filter
  16. def dropAll(a: ~[A])(implicit o: Ordering[A] = \/): ~[A]

    Group reversed filter

    Group reversed filter

    Discards all elements equal to the found in that stream

    val idx = (1 <> 5).all.flatMap(_.I repeat 3).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 <> 7).lp      // Prints: ~(1, 1, 1, 2, 2, 2)
    
    idx.all.dropAll(2 ~+ 5 + 11).lp // Prints: ~(1, 1, 1, 3, 3, 3, 4, 4, 4)
    Definition Classes
    _filter
    Note

    The operation is very efficient if streams are sorted

  17. def dropAllBy[B](f: Mapping[A, B], a: ~[B])(implicit o: Ordering[B] = \/): ~[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, 0 ~+ 3).lp
    
    // Output
    ~(d, e, fg, hijk)
    Definition Classes
    _filter
    Note

    The operation is very efficient if streams are sorted

  18. def dropAt(r: Idx.Range): ~[A]

    Sequence range reversed filter

    Sequence range reversed filter

    Discards sequence elements, which fall within the specified range

    (1 <> 10).all.dropAt(3 <> 7).lp
    
    // Output
    ~(1, 2, 3, 9, 10)
    Definition Classes
    _filter
  19. 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 pipeline statements

    (1 <> 10).all.dropEverythingIf(true).lp
    
    // Output
    void
    Definition Classes
    _filter
  20. def dropLast(number: Int): ~[A]

    Sequence tail reversed filter

    Sequence tail reversed filter

    Discards the last consecutive number of elements in the sequence

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

    Sequence head reversed filter

    Sequence head reversed filter

    Discards the first consecutive number of elements in the sequence

    (1 <> 10).all.dropNext(3).lp
    
    // Output
    ~(4, 5, 6, 7, 8, 9, 10)
    Definition Classes
    _filter
  22. def dropVoid: Stream[A]

    Reversed filter for void

    Reversed filter for void

    Discards all the objects which test Any.isVoid positive from the pipeline

    def all = ("A" ~+ null + "B" + "" + "C")
    
    all.lp              // Prints: ~(A, null, B, void, C)
    
    all.dropVoid.lp     // Prints: ~(A, B, C)
    Definition Classes
    _filter_filter
  23. 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 <> 5).all +~ (1 <> 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
  24. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  25. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  26. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  27. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  28. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  29. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  30. final def notify(): Unit
    Definition Classes
    AnyRef
  31. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  32. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  33. def toString(): String
    Definition Classes
    AnyRef → Any
  34. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. 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._filter[A], Shared[A], AnyRef, Any
Source: _filter.scala