_drop
- Source
- _drop.scala
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"
- 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.
- 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)
- 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)
- 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)
- 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)
- 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
- 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.
- 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
- 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
- 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
- Source
- _drop.scala
Void value reversed filter
Void value reversed filter
Drops elements which test to be void
- 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)
- Source
- _drop.scala