Def
Reverse filter
Reverse filter
Disallows Stream elements satisfying the given function
(0 <>> 10).stream.drop(_ > 5).tp
// Output
Stream(0, 1, 2, 3, 4, 5)
Note: Scala equivalent is called "filterNot"
- Inherited from
- _drop
- Source
- _drop.scala
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
Duplicates reversed filter
Duplicates reversed filter
Drops elements equal to the passed in prior position
Note: To generally get rid of all duplicates, the stream must be sorted to arrange duplicates in sequence
(1 <> 10).stream.repeat(3).dropDuplicates.tp // Prints Stream(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
- Inherited from
- _drop
- Source
- _drop.scala
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).stream.dropDuplicatesBy(_.toString.length).tp
// Output
Stream(1, 10, 100)
- Inherited from
- _drop
- Source
- _drop.scala
Every Nth element reversed filter
Every Nth element reversed filter
Drops every nTh element
(1 <> 10).stream.dropEvery(3).tp // Prints: Stream(1, 2, 4, 5, 7, 8, 10)
- Inherited from
- _drop
- Source
- _drop.scala
Head reversed filter
Head reversed filter
Drops given number of first elements
(1 <> 10).stream.dropFirst(3).tp // Prints Stream(4, 5, 6, 7, 8, 9, 10)
- Inherited from
- _drop
- Source
- _drop.scala
Tail reversed filter
Tail reversed filter
Drops given number of elements coming last
(1 <> 10).stream.dropLast(3).tp // Prints Stream(1, 2, 3, 4, 5, 6, 7)
Note: This method will block on unlimited streams
- Inherited from
- _drop
- Source
- _drop.scala
Single value reversed filter
Single value reversed filter
Drops only specified value.
(1 <> 4).stream.dropOnly(3).tp
// Output
Stream(1, 2, 4)
Note: dropOnly is more efficient than general filter ".drop(_ == value)", because there is no function involved.
- Inherited from
- _drop
- Source
- _drop.scala
Range reversed filter
Range reversed filter
Only allows elements outside specified sequencial range
('a' <> 'f').stream.dropRange(2 <> 3).tp
// Output
Stream(a, b, e, f)
Note: Range indexing starts from 0
- Inherited from
- _drop
- Source
- _drop.scala
Multi value reversed filter
Multi value reversed filter
Drops only provided set of values
(0 <>> 10).stream.dropValues(8,3,5).tp
// Output
Stream(0, 1, 2, 4, 6, 7, 9)
Note: dropValues is macro optimized when given value tuples sized from 2 to 5
- Inherited from
- _drop
- Source
- _drop.scala
Mapped multi value reversed filter
Mapped multi value reversed filter
Drops only values, which convert to provided set of values
(0 <>> 10).stream.dropValuesBy(_ % 5, (1,3) ).tp
// Output
Stream(0, 2, 4, 5, 7, 9)
Note: dropValuesBy is macro optimized when given value tuples sized from 2 to 5
- Inherited from
- _drop
- Source
- _drop.scala
Void value reversed filter
Void value reversed filter
Drops elements which test to be void
- Inherited from
- _drop
- Source
- _drop.scala
Coditional reversed head filter
Coditional reversed head filter
Discards first consecutive elements satisfying the condition
def stream = (1 <> 5).stream ++ (1 <> 5)
stream.tp // Prints Stream(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)
stream.dropWhile(_ <= 3).tp // Prints Stream(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
Main filter
Main filter
Only takes Stream elements satisfying the given function
(0 <>> 10).stream.take(_ > 5).tp
// Output
Stream(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
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
Duplicates filter
Duplicates filter
Takes only elements equal to the passed in prior position
Note: To generally get all duplicates, the stream must be sorted to arrange them in sequence
Stream(1,1,2,3,3,4,5,5,5).takeDuplicates.tp
// Output
Stream(1, 3, 5, 5)
- Inherited from
- _take
- Source
- _take.scala
Mapped duplicates filter
Mapped duplicates filter
Takes only elements, which evaluate to the same value as elements passed in prior position
Note: To generally get all duplicates, the stream must be sorted by the mapping function
(0 <> 10).stream.takeDuplicatesBy(_ / 2).tp
// Output
Stream(1, 3, 5, 7, 9)
- Inherited from
- _take
- Source
- _take.scala
Every Nth element filter
Every Nth element filter
Only lets every nTh element
(1 <> 20).stream.takeEvery(4).tp // Prints: Stream(4, 8, 12, 16, 20)
- Inherited from
- _take
- Source
- _take.scala
Head filter
Head filter
Only takes given number of first elements
(1 <> 10).stream.takeFirst(3).tp // Prints Stream(1, 2, 3)
- Inherited from
- _take
- Source
- _take.scala
Indexed filter
Indexed filter
Only lets elements satisfying the given function, which also accepts element sequential index
('a' <> 'z').stream.takeIndexed((i, _) => i >= 2 && i <= 7, 1).tp
// Output
Stream(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
Tail filter
Tail filter
Only takes given number of elements coming last
(1 <> 10).stream.takeLast(3).tp // Prints Stream(8, 9, 10)
Note: This method will block on unlimited streams
- Inherited from
- _take
- Source
- _take.scala
Single value filter
Single value filter
Filters only specified value.
(0 <>> 10).stream.takeOnly(5).tp
// Output
Stream(5)
Note: takeOnly is more efficient than general filter ".take(_ == value)", because there is no function involved.
- Inherited from
- _take
- Source
- _take.scala
Range filter
Range filter
Only allows elements withing specified sequencial range
('a' <> 'z').stream.takeRange(1 <> 7).tp
// Output
Stream(b, c, d, e, f, g, h)
Note: Range indexing starts from 0
- Inherited from
- _take
- Source
- _take.scala
Type filter
Type filter
Only lets elements of specified type
Stream(1, '2', "3", new Object(), 0.0).takeType[String].tp // Prints: Stream(3)
- Inherited from
- _take
- Source
- _take.scala
Multi value filter
Multi value filter
Takes only provided set of values
('a' <> 'z').stream.takeValues('z','x','b').tp // Prints Stream('b','x','y')
('a' <> 'z').stream.takeValues('b' <> 'f').tp // Prints Stream('b','c','d','e','f')
Note: takeValues is macro optimized when given value tuples sized from 2 to 5
- Inherited from
- _take
- Source
- _take.scala
Mapped multi value filter
Mapped multi value filter
Takes only values, which convert to provided set of values
(0 <>> 10).stream.takeValuesBy(_ % 5, (1,3) ).tp
// Output
Stream(1, 3, 6, 8)
Note: takeValuesBy is macro optimized when given value tuples sized from 2 to 5
- Inherited from
- _take
- Source
- _take.scala
Conditional head filter
Conditional head filter
Only takes first consecutive elements satisfying the condition
def stream = (1 <> 5).stream ++ (1 <> 5)
stream.tp // Prints Stream(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)
stream.takeWhile(_ <= 3).tp // Prints Stream(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