t

Stream.Flow

trait _Trait[A] extends _extend[A] with _consume[A] with _info[A]

Potentially Parallel Flow.

Stream.Flow is Stream's parent, with only methods able of parallel processing

For example, running <stream>.parallelIfOver(100) will always return Flow, but it will only execute in parallel, if there are more than a 100 elements. Otherwise it will still be a Stream, reduced to Flow interface.

Ordering
  1. Alphabetic
Inherited
  1. Flow
  2. Flow._info
  3. Flow._consume
  4. Flow._consume._foreach
  5. Flow._consume._evaluate
  6. Flow._consume._convert
  7. Any.Able.ToText
  8. Flow._consume._aggregate
  9. Flow._extend
  10. Flow._extend._peek
  11. Flow._extend._map
  12. Flow._extend._flow
  13. Flow._extend._filter
  14. Flow._extend.Z.Shared
  15. scala.AnyRef
  16. 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 contains[B >: A](value: B): Boolean

    Includes check

    Includes check

    Returns true if there is element equal to the given value

    def all = ('a' <> 'f').all
    
    all.contains('c').lp       // Prints: true
    
    all.contains('y').lp       // Prints: false
    Definition Classes
    _evaluate
  4. def copyTo(b: Idx.Array.Buffer.Loader[A]): Unit

    Copy to buffer

    Copy to buffer

    This is potentially the most efficient way to get all Stream elements

    Idx.Array.Buffer.Loader provides a trustless way to copy arrays in bulk, so many array based Streams can take advantage of this

    Definition Classes
    _convert
  5. def count(f: Filter[A]): Int

    Element conditional count

    Element conditional count

    Returns count of elements satisfying the filter

    Definition Classes
    _evaluate
  6. abstract def count: Int

    All elements count

    All elements count

    Returns count of all elements

    ('a' <> 'z').all.count.lp  // Prints: 26
    Definition Classes
    _evaluate
  7. def countAndTime: (Int, Duration)

    Element count and time

    Element count and time

    Returns count of all elements and the Duration it took to pump the pipeline

    (1 <> 1000).all.peek(_ => App.pause(1.Millis)).countAndTime.lp // Prints: (1000,1.004 sec)
    Definition Classes
    _evaluate
  8. def countFew(f: Filter[A]*): Idx[Int]

    Element multi count

    Element multi count

    Counts elements for several filters at once

    Returns Idx[Int], where each Int corresponds to the given filter index

    If the pipeline is empty, the resulting Idx will still hold 0 in each position, but will test isVoid positive

    f

    several filters

    Definition Classes
    _evaluate
    Example:
    1. val (all, odd, even) = (1 <> 50).all.countFew(ANY, _ % 2 == 1, _ % 2 == 0).toTuple3
      
      "all=" + all lp;    // Prints: all=50
      "odd=" + odd lp;    // Prints: odd=25
      "even=" + even lp;  // Prints: even=25
      
       // ----------------------------------------------------------------------------------
      
      def count(stream: ~[Int]): Idx[Int] = stream.countFew(_ < 10, _ > 20, 30 <> 60)
      
      count(1 <> 50).all lp  // Prints: ~(9, 30, 21)
      
      count(\/).all lp       // Prints: ~(0, 0, 0)
      
      count(\/).Opt lp       // Prints: Opt.Void
  9. def drain: Unit

    Discharge everything

    Discharge everything

    Calls foreach, discarding all retrieved elements

    Even though nothing is done at this point, this method can be run for the benefit of other functions in the pipeline

    ('A' <> 'C').all.peek("Process " + _ lp).drain
    
    // Output
    Process A
    Process B
    Process C
    Definition Classes
    _foreach
  10. def drop(f: Filter[A]): Flow[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
  11. def dropVoid: Flow[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
  12. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  14. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. def find(f: Filter[A]): A

    Find

    Find

    Returns the first element satisfying the given filter

    Fails if none found

    (1 <> 1000).all.find(_ > 100).lp  // Prints: 101
    Definition Classes
    _evaluate
  16. abstract def findAnyOpt: Opt[A]
    Attributes
    protected
    Definition Classes
    _evaluate
  17. def findOpt(f: Filter[A]): Opt[A]

    Find

    Find

    Optionally returns the first element satisfying the given filter

    (1 <> 1000).all.findOpt(_ > 100).lp  // Prints: Opt(101)
    Definition Classes
    _evaluate
  18. abstract def flatMap[B](f: Mapping[A, ~[B]])(implicit arg0: Ilk[B]): Flow[B]

    Map multiplier

    Map multiplier

    For every existing element, a mapped stream of elements is inserted into the pipeline

    Note. The mapping can return an empty stream, in which case total number of elements might even be reduced

    f

    function to provide a stream of elements for each existing element

    Definition Classes
    _map
    Example:
    1. ~.*(1, 2, 3).flatMap(i => ~.*(i * 10, i * 100, i * 1000)).lp
      
      // Output
      ~(10, 100, 1000, 20, 200, 2000, 30, 300, 3000)
  19. def fold(start: A)(bf: Folding[A]): A

    Basic fold

    Basic fold

    Folds elements with a binary function

    Returns start value for empty pipeline

    start

    seed value to start with

    bf

    binary function to fold elements with

    Definition Classes
    _aggregate
    Example:
    1. // Multiply every element by next
      
      (1 <> 10).all.fold(1, _ * _).lp   // Prints: 3628800
  20. abstract def foldFlowAs[B](start: B)(bf: Folding.As[B, A], cf: Folding[B])(implicit arg0: Ilk[B]): B

    Fold and convert

    Fold and convert

    Folds and converts elements with a binary function.

    Returns Opt.Void for empty pipeline

    start

    seed value to start with

    bf

    binary function to fold elements with

    cf

    collect function to put together results of parallel computations. It is not required and ignored for Stream

    Definition Classes
    _aggregate
    Example:
    1. // Calculate sum of first 1000 Ints in 10 concurrent jobs
      
      (1 <> 1000).all.parallelGroup(100).foldFlowAs[Long](0L, _ + _, _ + _).lp // Prints: 500500
  21. abstract def foreach(f: Consumer[A]): Unit

    For each

    For each

    Applies given function for each element

    (1 <> 3).all.foreach("Element: " + _ lp)
    
    // Output
    Element: 1
    Element: 2
    Element: 3
    Definition Classes
    _foreach
  22. def foreachSynchronized(c: Consumer[A]): Unit

    Synchronized foreach

    Synchronized foreach

    Calls foreach within synchronized context

    Definition Classes
    _foreach
  23. def format(separator: Opt[String] = \/, padBefore: Opt[String] = \/, padAfter: Opt[String] = \/, converter: Opt[(A) ⇒ String] = \/): String

    Elements as String

    Elements as String

    All elements are converted toString

    The results are concatenated with possible use of padding and separator

    separator

    optional string between elements

    padBefore

    optional string before each element

    padAfter

    optional string after each element

    converter

    custom element to String function

    Definition Classes
    _convert
    Example:
    1. ('a' <> 'z').all.format().lp
      ('a' <> 'z').all.format("|").lp
      ('a' <> 'z').all.format(",", "[", "]").lp
      
      // Output
      abcdefghijklmnopqrstuvwxyz
      
      a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z
      
      [a],[b],[c],[d],[e],[f],[g],[h],[i],[j],[k],[l],[m],[n],[o],[p],[q],[r],[s],[t],[u],[v],[w],[x],[y],[z]
  24. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  25. abstract def ilkOpt: Opt[Any.Ilk]

    Data Any.Ilk if known

    Data Any.Ilk if known

    Stream elements Any.Ilk if known for granted

    Definition Classes
    _Trait
  26. def isAny(f: Filter[A]): Boolean

    Any check

    Any check

    Returns true if there is an element satisfying the filter

    def all = (1 <> 100).all
    
    all.isAny(_ > 10).lp   // Prints: true
    
    all.isAny(_ > 100).lp  // Prints: false
    Definition Classes
    _evaluate
  27. def isEvery(f: Filter[A]): Boolean

    Every check

    Every check

    Returns true if every element is satisfying the filter

    def all = (1 <> 100).all
    
    all.isEvery(_ > 10).lp   // Prints: false
    
    all.isEvery(_ > 0).lp    // Prints: true
    Definition Classes
    _evaluate
  28. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  29. abstract def isParallel: Boolean

    Parallel check

    Parallel check

    Returns true if this Flow is parallel

    Definition Classes
    _Trait
  30. abstract def let(f: Filter[A]): Flow[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
  31. def letBy[T](property: Mapping[A, T], f: Filter[T]): Flow[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
  32. def letLookup[B](f: PartialFunction[A, B])(implicit arg0: Ilk[B]): Flow[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
    Shared
    Note

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

  33. def letMap[B](f: Mapping[A, Opt[B]])(implicit arg0: Ilk[B]): Flow[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
    Shared
  34. def letType[B](implicit t: ClassTag[B]): Flow[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
    Shared
  35. def lookupOpt[B](f: PartialFunction[A, B]): Opt[B]

    Find first matching option

    Find first matching option

    The matching element is mapped with the functions

    def stream = ~[Any] + "ABC" + 1 + 22.0 + "DE" + 333F + "F"
    
    // Find length of the first matching string
    stream.lookupOpt{
      case s: String if (s.length > 1) => s.length
    }.lp    // Prints: Opt(3)
    Definition Classes
    _evaluate
  36. abstract def map[B](f: Mapping[A, B])(implicit arg0: Ilk[B]): Flow[B]

    Element conversion

    Element conversion

    Converts every element in the pipeline with given function

    (1 <> 5).all.map( _ / 2.0).lp
    
    // Output
    ~(0.5, 1.0, 1.5, 2.0, 2.5)
    Definition Classes
    _map
  37. def mapType[B]: Flow[B]

    Element cast

    Element cast

    Casts the pipeline elements into the type specified

    def all: ~[Any] = 1 ~+ 2 + 3
    
    all.mapType[Int].lp // Prints: ~(1, 2, 3)
    Definition Classes
    _map
    Note

    If there is a problem for element casting, it will come up later during pumping action

  38. def max(implicit o: Ordering[A]): A

    Largest

    Largest

    Selects maximum element, based on the Ordering

    Fails for empty stream

    ~.*(4, 3, 12, 7).maxOpt.lp // Prints: 12
    Definition Classes
    _aggregate
  39. def maxBy[B](f: Mapping[A, B])(implicit o: Ordering[B]): A

    Largest by property

    Largest by property

    Selects maximum element, based on mapping

    Fails for empty stream

    ("AA" ~+ "B" + "CCCC" + "DDD").maxBy(_.length).lp // Prints: CCCC
    Definition Classes
    _aggregate
  40. def maxByOpt[B](f: Mapping[A, B])(implicit o: Ordering[B]): Opt[A]

    Largest by property option

    Largest by property option

    Selects maximum element, based on mapping

    ("AA" ~+ "B" + "CCCC" + "DDD").maxBy(_.length).lp // Prints: Opt(CCCC)
    Definition Classes
    _aggregate
  41. def maxOpt(implicit o: Ordering[A]): Opt[A]

    Largest

    Largest

    Selects maximum element, based on the Ordering

    ~.*(4, 3, 12, 7).maxOpt.lp // Prints: Opt(12)
    Definition Classes
    _aggregate
  42. def min(implicit o: Ordering[A]): A

    Smallest

    Smallest

    Selects minimal element, based on the Ordering

    Fails for empty stream

    (4 ~+ 3 + 12 + 7).minOpt.lp // Prints: 3
    Definition Classes
    _aggregate
  43. def minBy[B](f: Mapping[A, B])(implicit o: Ordering[B]): A

    Smallest by property

    Smallest by property

    Selects minimal element, based on mapping

    Fails for empty stream

    ("AA" ~+ "B" + "CCCC" + "DDD").minBy(_.length).lp // Prints: B
    Definition Classes
    _aggregate
  44. def minByOpt[B](f: Mapping[A, B])(implicit o: Ordering[B]): Opt[A]

    Smallest by property option

    Smallest by property option

    Selects minimal element, based on mapping

    ("AA" ~+ "B" + "CCCC" + "DDD").minBy(_.length).lp // Prints: Opt(B)
    Definition Classes
    _aggregate
  45. def minOpt(implicit o: Ordering[A]): Opt[A]

    Smallest

    Smallest

    Selects minimal element, based on the Ordering

    (4 ~+ 3 + 12 + 7).minOpt.lp // Prints: Opt(3)
    Definition Classes
    _aggregate
  46. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  47. final def notify(): Unit
    Definition Classes
    AnyRef
  48. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  49. abstract def peek(c: Consumer[A]): Flow[A]

    Element access

    Element access

    Provides access to passing pipeline elements

    This method does not change pipeline type or composition in any way

    ('A' <> 'C').all.peek("Passing: " + _ lp).count.lp
    
    // Output
    Passing: A
    Passing: B
    Passing: C
    3
    Definition Classes
    _peek
  50. def peekIdx(c: Consumer.Idx[A], start: Int = 0): Flow[A]

    Indexed element access

    Indexed element access

    Provides access to passing pipeline elements with their index in sequence

    start

    starting value for element indexing

    ('A' <> 'C').all.peekIdx("Peek" + _ + " = " + _ lp).count.lp
    
    // Output
    Peek 0 = A
    Peek 1 = B
    Peek 2 = C
    3
    Definition Classes
    _peek
  51. def range(implicit c: Ordering[A]): Range[A]

    Element Range

    Element Range

    Selects min and max elements (according to the Ordering ), and returns result as Range

    Note. Range is void for empty pipelines.

    (4 ~+ 1 + 12 + 7).range.lp
    
    // Output
    1 <> 12
    Definition Classes
    _aggregate
  52. def reduce(bf: Folding[A]): A

    Reduces elements with a Folding functions

    Reduces elements with a Folding functions

    Will fail for empty Stream

    Definition Classes
    _aggregate
  53. abstract def reduceOpt(bf: Folding[A]): Opt[A]

    Reduces elements with a Folding functions

    Reduces elements with a Folding functions

    Returns Opt.Void for for empty Stream

    Definition Classes
    _aggregate
  54. def sequential: Stream[A]

    Restore Flow to Stream

    Restore Flow to Stream

    Restores potentially parallel Flow back to Stream

    If this object is already a Stream, the operation is instant

    Otherwise the operation is quite expensive

    In many cases it is advisable to consume pipeline as Flow instead of converting to Stream

    (1 <> 1000).all
       .parallel                       // Switching to parallel Stream.Flow
       .peek(_ => App.pause(1.Millis)) // Expensive operation
       .sequential                     // Back to Stream
       .countAndTime("Count = " + _ + "\tDone in " + _ lp)
    
    // Output
    Count = 1000   Done in 0.186 sec
    Definition Classes
    _flow
  55. abstract def sizeOpt: Opt.Int

    Size if known

    Size if known

    Stream elements count if known for granted

    sizeOpt must be trusted

    For example, if sizeOpt returns 0, processing logic should not even attempt to confirm that pipeline is empty

    Definition Classes
    _Trait
  56. def sum(implicit n: Numeric[A]): A

    Sum

    Sum

    Computes sum value of all elements

    (0 <> 1000).all.sum.lp // Prints: 500500
    Definition Classes
    _aggregate
  57. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  58. def to[TRGT[_]](implicit cnv: Stream.Interface.To.Converter[TRGT]): TRGT[A]

    Convert to type

    Convert to type

    Converts pipeline elements to the specified target type

    Available targets are defined in Stream.Interface.To$

    • Idx
    • Idx.M
    • Idx.OM
    • Idx.I
    • scala.List
    • scala.Seq
    • scala.IndexedSeq
    • scala.Iterator
    • scala.Vector
    • scala.collection.mutable.Buffer
    • java.util.Collection
    • java.util.List
    • java.util.Iterator
    • java.util.Spliterator
    • java.util.stream.Stream
    ("1" ~+ "2" + "3").to[Idx.I]  // Returns: Idx.I[String]
    
    ('A' <> 'D').all.to[List]        // Returns: scala.List[Char]
    
    (1 <> 5).all.to[java.util.List]  // Returns: java.util.List[Int]

    New target conversions can be implemented by creating implicit object extending Stream.Interface.To$.Converter

    Definition Classes
    _convert
  59. def toArray(implicit ct: ClassTag[A]): Array[A]

    Convert to Array

    Convert to Array

    Concert stream to array

    val a : Array[Int] =  (1<>10).all.toArray
    Definition Classes
    _convert
  60. def toInfo: Pro.Info

    Metadata as String

    Metadata as String

    ('a' <> 'z').all.let(_ > 'X').map(_.toUpper).toInfo.lp
    
    // Output
    
    Stream.Z.extend.map.toChar$Default$4{ilk=Chars,chainDepth=3,preIterate=333}
    Definition Classes
    _Trait
  61. def toRaw[TRGT](implicit c: Stream.Interface.To.Primitive.Converter[A, TRGT]): TRGT

    Convert to immutable collection

    Convert to immutable collection

    Converts pipeline to the specified immutable collection

    The types of collection and Stream must match

    Available targets are:

    (1 <> 10).all.toRaw[Ints]
    
    ('A' <> 'D').all.toRaw[Chars]
    Definition Classes
    _convert
  62. def toString(): String

    Elements as String

    Elements as String

    Returns String starting with "~(" and containing all elements separated by ", "

    (1 <> 5).all.toString.lp
    
    // Output
    ~(1, 2, 3, 4, 5)
    Definition Classes
    _convert → AnyRef → Any
  63. def toString(name: String): String

    Elements as String

    Elements as String

    Returns String starting with given name and containing all elements separated by ", "

    (1 <> 5).all.toString("My Ints").lp
    
    // Output
    My Ints(1, 2, 3, 4, 5)
    Definition Classes
    _convert
  64. def toText: String

    Elements as multi-line String

    Elements as multi-line String

    Returns all elements as String formatted table

    If elements implement Any.Able.ToInfo, each 'info' property value is placed in a different column

    If elements implement scala.Product (like all Tuples), each Product element is placed in a different column

    ('a' <> 'e').all.map(c => (c + "1", c + "2", c + "3", c + "4", c + "5")) tp
    
    // Output
    -- -- -- -- --
    ?  ?  ?  ?  ?
    -- -- -- -- --
    a1 a2 a3 a4 a5
    b1 b2 b3 b4 b5
    c1 c2 c3 c4 c5
    d1 d2 d3 d4 d5
    e1 e2 e3 e4 e5
    -- -- -- -- --
    Definition Classes
    _convertToText
  65. def toVals(implicit c: Any.Datum.Setup[A]): Vals[A]

    Convert to Vals

    Convert to Vals

    Stores all elements as Vals immutable collection

    Only works if Stream holds Any.Datum type

    Definition Classes
    _convert
  66. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  67. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  68. 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