~._build._filter

trait _filter extends _take with _drop
trait _drop
trait _take
class Object
trait Matchable
class Any
trait _build
object ~

Def

inline def filter[A](inline f: A => Boolean): ~[A]

Legacy filter

Legacy filter

Filters Stream elements according to given function

  (0 <>> 10).~.filter(_ > 5).tp

  // Output
  ~(6, 7, 8, 9)

Note: take is usually used instead.

Source
__.scala
inline def FILTER[A](inline f: A => Boolean): ~[A]
Source
__.scala

Inherited

inline def drop[A](inline f: A => Boolean): ~[A]

Reverse filter

Reverse filter

Disallows Stream elements satisfying the given function

  (0 <>> 10).~.drop(_ > 5).tp

  // Output
  ~(0, 1, 2, 3, 4, 5)

Note: Scala equivalent is called "filterNot"

Inherited from
_drop
Source
_drop.scala
inline def DROP[A](inline f: A => Boolean): ~[A]

Heavy reversed filter

Heavy reversed filter

Disallows Stream elements satisfying the given function

DROP is functionally equivalent to drop, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.

Inherited from
_drop
Source
_drop.scala
@targetName("drop_Range")
inline def drop_<>[A](inline i: <>): ~[A]

Range reversed filter

Range reversed filter

Only allows elements outside specified sequencial range

  ('a' <> 'f').~.drop_<>(2 <> 3).tp

  // Output
  ~(a, b, e, f)

Note: Sequence indexing starts from 0

Inherited from
_drop
Source
_drop.scala
def dropAll[A](v: ~[A]): ~[A]

Multi element reversed filter

Multi element reversed filter

Only lets elements not found in given stream

  ('a' <> 'z').~.dropAll('c' <> 'x') .tp       // Prints ~(a, b, y, z)
Inherited from
_drop
Source
_drop.scala
def dropAllBy[A](f: A => B, v: ~[B]): ~[A]

Multi element mapped reversed filter

Multi element mapped reversed filter

Only lets elements, which mapped value is not found in given stream

  ('a' <> 'z').~.dropAllBy(_.Int % 10, ~~(1,3,7,4,6)).tp

  // Output
  ~(b, c, d, f, i, l, m, n, p, s, v, w, x, z)
Inherited from
_drop
Source
_drop.scala
inline def dropEvery[A](nTh: Int): ~[A]

Every Nth element reversed filter

Every Nth element reversed filter

Drops every nTh element

  (1 <> 10).~.dropEvery(3).tp   // Prints: ~(1, 2, 4, 5, 7, 8, 10)
Inherited from
_drop
Source
_drop.scala
inline def dropFirst[A](inline n: Int): ~[A]

Head reversed filter

Head reversed filter

Drops given number of first elements

  (1 <> 10).~.dropFirst(3).tp  // Prints  ~(4, 5, 6, 7, 8, 9, 10)
Inherited from
_drop
Source
_drop.scala
inline def dropLast[A](n: Int): ~[A]

Tail reversed filter

Tail reversed filter

Drops given number of elements coming last

  (1 <> 10).~.dropLast(3).tp  // Prints  ~(1, 2, 3, 4, 5, 6, 7)

Note: This method will block on unlimited streams

Inherited from
_drop
Source
_drop.scala
def dropOnly[A](v: A, vs: A*): ~[A]

Single value reversed filter

Single value reversed filter

Drops only specified value.

  (1 <> 4).~.dropOnly(3).tp

  // Output
  ~(1, 2, 4)

Note: dropOnly is more efficient than general filter, because there is no function involved.

Inherited from
_drop
Source
_drop.scala
def dropOnlyBy[A](f: A => B, vs: B*): ~[A]
Inherited from
_drop
Source
_drop.scala
inline def dropSame[A]: ~[A]

Duplicates reversed filter

Duplicates reversed filter

Drops elements equal to passed in prior position

Note: To generally get rid of all duplicates, the stream must be sorted to arrange duplicates in sequence

Inherited from
_drop
Source
_drop.scala
inline def dropSameBy[A](inline f: A => B): ~[A]

Mapped duplicates reversed filter

Mapped duplicates reversed filter

Drops elements, which evaluate to the same value as elements passed in prior position

Note: To generally get rid of all duplicates, the stream must be sorted by the mapping function

  (1 <> 100).~.dropSameBy(_.toString.length).tp

  // Output
  ~(1, 10, 100)
Inherited from
_drop
Source
_drop.scala
def dropVoid[A](using Info.Tag.Void[A]): ~[A]

Void value reversed filter

Void value reversed filter

Drops elements which test to be void

Inherited from
_drop
Source
_drop.scala
inline def dropWhile[A](inline f: A => Boolean): ~[A]

Coditional reversed head filter

Coditional reversed head filter

Discards first consecutive elements satisfying the condition

  def stream = (1 <> 5).~ ++ (1 <> 5)

  stream.tp                     // Prints ~(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)

  stream.dropWhile(_ <= 3).tp   // Prints ~(4, 5, 1, 2, 3, 4, 5)

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

Inherited from
_drop
Source
_drop.scala
inline def take[A](inline f: A => Boolean): ~[A]

Main filter

Main filter

Only takes Stream elements satisfying the given function

  (0 <>> 10).~.take(_ > 5).tp

  // Output
  ~(6, 7, 8, 9)

Note: Traditional method filter is also available and can be used, but take is prefferable in most cases.

Inherited from
_take
Source
_take.scala
inline def TAKE[A](inline f: A => Boolean): ~[A]

Heavy filter

Heavy filter

Filters Stream elements according to given function

TAKE is functionally equivalent to take, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.

Inherited from
_take
Source
_take.scala
@targetName("take_Range")
inline def take_<>[A](inline i: <>): ~[A]

Range filter

Range filter

Only allows elements withing specified sequencial range

  ('a' <> 'z').~.take_<>(1 <> 7).tp

  // Output
  ~(b, c, d, e, f, g, h)

Note: Sequence indexing starts from 0

Inherited from
_take
Source
_take.scala
def takeAll[A](v: ~[A]): ~[A]

Multi element filter

Multi element filter

Only lets elements equal to the found in given stream

  ('a' <> 'z').~.takeAll(~~('z','x','b')).tp   // Prints ~('b','x','y')

  ('a' <> 'z').~.takeAll('b' <> 'f') .tp       // Prints ~('b','c','d','e','f')
Inherited from
_take
Source
_take.scala
def takeAllBy[A](f: A => B, v: ~[B]): ~[A]

Multi element mapped filter

Multi element mapped filter

Only lets elements, which mapped value is found in given stream

  ('a' <> 'z').~.takeAllBy(_.Int % 10, ~~(1,3,7)).tp

  // Output
  ~(a, e, g, k, o, q, u, y)
Inherited from
_take
Source
_take.scala
inline def takeEvery[A](inline nTh: Int): ~[A]

Every Nth element filter

Every Nth element filter

Only lets every nTh element

  (1 <> 20).~.takeEvery(4).tp   // Prints: ~(4, 8, 12, 16, 20)
Inherited from
_take
Source
_take.scala
inline def takeFirst[A](n: Int): ~[A]

Head filter

Head filter

Only takes given number of first elements

  (1 <> 10).~.takeFirst(3).tp  // Prints  ~(1, 2, 3)
Inherited from
_take
Source
_take.scala
inline def takeIndexed[A](inline f: (Int, A) => Boolean, inline start: Int): ~[A]

Indexed filter

Indexed filter

Only lets elements satisfying the given function, which also accepts element sequential index

  ('a' <> 'z').~.takeIndexed((i, _) => i >= 2 && i <= 7, 1).tp

  // Output
  ~(b, c, d, e, f, g)

Note: By default indexing starts from 0, but starting value can also be explicitly specified.

Inherited from
_take
Source
_take.scala
inline def takeLast[A](inline n: Int): ~[A]

Tail filter

Tail filter

Only takes given number of elements coming last

  (1 <> 10).~.takeLast(3).tp  // Prints  ~(8, 9, 10)

Note: This method will block on unlimited streams

Inherited from
_take
Source
_take.scala
def takeOnly[A](v: A, vs: A*): ~[A]

Single value filter

Single value filter

Filters only specified value.

  (0 <>> 10).~.takeOnly(5).tp

  // Output
  ~(5)

Note: takeOnly is more efficient than general filter, because there is no function involved.

Inherited from
_take
Source
_take.scala
def takeOnlyBy[A](f: A => B, v: B*): ~[A]
Inherited from
_take
Source
_take.scala
inline def takeType[A](using inline t: ClassTag[B]): ~[B]

Type filter

Type filter

Only lets elements of specified type

  ~~(1, '2', "3", new Object(), 0.0).takeType[String].tp  // Prints: ~(3)
Inherited from
_take
Source
_take.scala
inline def takeWhile[A](inline f: A => Boolean): ~[A]

Conditional head filter

Conditional head filter

Only takes first consecutive elements satisfying the condition

  def stream = (1 <> 5).~ ++ (1 <> 5)

  stream.tp                     // Prints ~(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)

  stream.takeWhile(_ <= 3).tp    // Prints ~(1, 2, 3)

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

Inherited from
_take
Source
_take.scala