~~.Flow

abstract class Flow[A] extends _build[A] with _use[A] with _metadata[A]

Stream Flow

Flow is similar to stream, but without sequence specific methods.

Elements of Flow can be processed either in parallel or sequentially.

Flow is usually created from stream with ".parallel" method.

  val flow: ~~.Flow[Int] = (1 <> 10).~.parallel
Source
__.scala
trait _metadata[A]
trait _use[A]
trait _build[A]
class java.lang.Object
trait scala.Matchable
class Any

Def

@scala.annotation.targetName("stream")
def ~: ~[A]

Convert to stream

Convert to stream

Wraps ~~.Flow into regular stream.

If ~~.Flow is parallel, then this convertion can be very costly, and it is always prefferable to consume ~~.Flow without going back to ~

Inherited from
_build
Source
_build.scala
def collect[B](f: scala.PartialFunction[A, B]): ~~.Flow[B]

Partial map

Partial map

Creates a new ~~.Flow by applying a partial function to all elements of current ~~.Flow on which the function is defined.

Inherited from
_build
Source
_build.scala
def contains[B >: A](value: B): Boolean

Value check

Value check

Returns true if flow contains given value

Inherited from
_use
Source
_use.scala
def count: Int

All count

All count

Counts all flow elements

Inherited from
_use
Source
_use.scala

Count and time

Count and time

Returns all elements count and Time.Length it took to pump the flow

  val (cnt,time) = (1 <> 1000).~.parallel.peek(_ => J.sleep(1.Millis)).countAndTime

  ("" + cnt + " elements processed in " + time.tag).tp

  // Output
  1000 elements processed in 0.040820901 sec

Note. Only massively parallel execution allowed to process the above example in 0.04 seconds

Inherited from
_use
Source
_use.scala

Tree description

Tree description

Returns a tree describing all flow trasformations

 ('a' <> 'z').~
    .take(_ > 'X')
    .map(_.toUpper)
    .parallel
    .docTree.tp

 // Output
  scalqa.val.stream.z.flow.parallel.Flow_asJavaStream@ncwo{}
    scalqa.lang.char.g.stream.z.map$Chars@uru4{raw=Char,fromRaw=Char}
      scalqa.lang.char.g.Stream$TakeStream$2@56u4{raw=Char,fromRaw=Char}
        scalqa.lang.char.g.stream.Z$Stream_fromRange@cq06{raw=Char,size=26,from=a,step=1}
Inherited from
_metadata
Source
_metadata.scala
def drain: Unit

Pump flow out

Pump flow out

Fetches and discards all flow elements

This operation can be usefull for side effects built into pipeline

Inherited from
_use
Source
_use.scala
def drop(f: A => Boolean): ~~.Flow[A]

Reverse filter

Reverse filter

Disallows ~~.Flow elements satisfying the given function

Inherited from
_build
Source
_build.scala
def exists(f: A => Boolean): Boolean

Exists check

Exists check

Returns true if there is an elemnet satisfying given predicate

Inherited from
_use
Source
_use.scala
def find(f: A => Boolean): A

Find value

Find value

Finds value accepted by given predicate

Note: If value is not found operation fails, use find_? in most cases

Inherited from
_use
Source
_use.scala
@scala.annotation.targetName("find_Opt")
def find_?(f: A => Boolean): Opt[A]

Find optional value

Find optional value

Finds value accepted by given predicate or returns void option if not found

Inherited from
_use
Source
_use.scala
@scala.annotation.targetName("findAny_Opt")
def findAny_?: Opt[A]

Find optional any value

Find optional any value

Finds any value or returns void option if not found

Inherited from
_use
Source
_use.scala
def flatMap[B](f: A => ~[B]): ~~.Flow[B]

Flat map

Flat map

Creates a new ~~.Flow by applying given function to all elements of current ~~.Flow and concatenating the results

Inherited from
_build
Source
_build.scala
def fold(start: A)(bf: (A, A) => A): A

Fold

Fold

Folds elements with a binary function

Value Params
f

binary function to fold elements with

start

seed value to start with

Inherited from
_use
Source
_use.scala
def foldAs[B](start: B)(bf: (B, A) => B, cf: (B, B) => B): B

Fold and convert

Fold and convert

Folds and converts elements with a binary function

Value Params
f

binary function to fold elements with

start

seed value to start with

Inherited from
_use
Source
_use.scala
def foreach[U](f: A => U): Unit

Process flow

Process flow

Applies given function to each flow element

Inherited from
_use
Source
_use.scala
def isEvery(f: A => Boolean): Boolean

Forall check

Forall check

Returns true if every single element satisfies the given predicate

Inherited from
_use
Source
_use.scala
def isParallel: Boolean

Parallel check

Parallel check

Returns true if this Parallel is parallel

Inherited from
_metadata
Source
_metadata.scala
def map[B](f: A => B): ~~.Flow[B]

Simple map

Simple map

Creates a new ~~.Flow where each element is a result of applying given function to current ~~.Flow elements

Inherited from
_build
Source
_build.scala
@scala.annotation.targetName("map_Opt")
def map_?[B](f: A => Opt[B]): ~~.Flow[B]

Optional map

Optional map

Creates a new ~~.Flow where each element is a result of applying given function to current ~~.Flow elements

It the function returns void option, the elements are dropped

Inherited from
_build
Source
_build.scala
def max(using scala.Ordering[A]): A

Maximum

Maximum

Computes maximum value

Fails for empty streams

Inherited from
_use
Source
_use.scala
@scala.annotation.targetName("max_Opt")
def max_?(using scala.Ordering[A]): Opt[A]

Optional maximum

Optional maximum

Computes maximum value or returns void option for empty streams

Inherited from
_use
Source
_use.scala
def maxBy[B](f: A => B)(using scala.Ordering[B]): A

Maximum by property

Maximum by property

Computes maximum value based on given function

Fails for empty streams

Inherited from
_use
Source
_use.scala
@scala.annotation.targetName("maxBy_Opt")
def maxBy_?[B](f: A => B)(using scala.Ordering[B]): Opt[A]

Optional maximum by property

Optional maximum by property

Computes maximum value based on given function or returns void option for empty streams

Inherited from
_use
Source
_use.scala
def min(using scala.Ordering[A]): A

Minimum

Minimum

Computes minimum value

Fails for empty streams

Inherited from
_use
Source
_use.scala
@scala.annotation.targetName("min_Opt")
def min_?(using scala.Ordering[A]): Opt[A]

Optional minimum

Optional minimum

Computes minimum value or returns void option for empty streams

Inherited from
_use
Source
_use.scala
def minBy[B](f: A => B)(using scala.Ordering[B]): A

Minimum by property

Minimum by property

Computes minimum value based on given function

Fails for empty streams

Inherited from
_use
Source
_use.scala
@scala.annotation.targetName("minBy_Opt")
def minBy_?[B](f: A => B)(using scala.Ordering[B]): Opt[A]

Optional minimum by property

Optional minimum by property

Computes minimum value based on given function or returns void option for empty streams

Inherited from
_use
Source
_use.scala
def peek(c: A => Unit): ~~.Flow[A]

Inspect

Inspect

The given function will be run for every passing stream flow element.

Inherited from
_build
Source
_build.scala
def peekIndexed[U](c: (Int, A) => U, start: Int): ~~.Flow[A]

Indexed peek

Indexed peek

The given function will be executed for every passing element and its index.

Inherited from
_build
Source
_build.scala
def range(using scala.Ordering[A]): <>[A]

Range

Range

Computes value range

Fails for empty streams

Inherited from
_use
Source
_use.scala
@scala.annotation.targetName("range_Opt")
def range_?(using scala.Ordering[A]): Opt[<>[A]]

Optional range

Optional range

Computes value value or returns void option for empty streams

Inherited from
_use
Source
_use.scala
def reduce(bf: (A, A) => A): A

Reduce

Reduce

Folds elements with a binary function

Note. Threre is no default value, and if flow is empty, operation fails. Use reduce_? as a safer option

Value Params
f

binary function to fold elements with

Inherited from
_use
Source
_use.scala
@scala.annotation.targetName("reduce_Opt")
def reduce_?(bf: (A, A) => A): Opt[A]

Optional reduce

Optional reduce

Folds elements with a binary function or returns empty option when stream is empty

Value Params
f

binary function to fold elements with

Inherited from
_use
Source
_use.scala
@scala.annotation.targetName("size_Opt")

Optional size

Optional size

Many streams can return their current element count. If the information is not available, void option is returned

Note: If size is known, but exceeds integer range, void option is returned. For theses cases use sizeLong_?

 var s = ('a' <> 'z').~

 s.size_?.tp         // Prints Int.Opt(26)

 s = s.take(_ > 10)  // static sizing is lost

 s.size_?.tp         // Prints Int.Opt(\/)
Inherited from
_metadata
Source
_metadata.scala
@scala.annotation.targetName("sizeLong_Opt")

Optional long size

Optional long size

Many streams can return their current element count. If the information is not available, void option is returned

var s = (Int.min.Long <> Int.max.Long).~

s.sizeLong_?.tp    // Prints Long.Opt(4294967296)

s = s.take(_ > 10) // static sizing is lost

s.sizeLong_?.tp    // Prints Long.Opt(\/)
Inherited from
_metadata
Source
_metadata.scala
def sum(using Math[A]): A

Sum

Sum

Calculates sum of all values

For empty stream returns zero

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

Filter

Filter

Only allow ~~.Flow elements satisfying the given function

Inherited from
_build
Source
_build.scala
def takeType[B](`evidence$1`: scala.reflect.ClassTag[B]): ~~.Flow[B]

Type filter

Type filter

Only lets elements of specified type

Inherited from
_build
Source
_build.scala