trait _Trait[A] extends Stream.Flow._consume[A] with _aggregate[A] with _convert[A] with _evaluate[A] with _foreach[A]
- Alphabetic
- Stream._consume
- Stream._consume._foreach
- Stream._consume._evaluate
- Stream._consume._convert
- Stream._consume._aggregate
- Stream.Flow._consume
- Stream.Flow._consume._foreach
- Stream.Flow._consume._evaluate
- Stream.Flow._consume._convert
- Stream.Flow._consume._aggregate
- scala.AnyRef
- scala.Any
- Hide All
- Show All
- Public
- All
Method
-
def
apply(c: Consumer[A], forEmpty: ⇒ Any = ()): Unit
For each or for empty
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
average(implicit n: Numeric[A]): A
Average
Average
Computes average
(10 to 15).all.map(_.toFloat).average // Returns 12.5
- Definition Classes
- _aggregate
-
def
averageFew[B](f: Mapping[A, B]*)(implicit arg0: Numeric[B]): Seq[B] with Util.Able.Void
Multi average
Multi average
Simultaneously computes multiple average values for properties specified by several functions
Returns Seq with values corresponding to the given mappings
For empty pipelines returned Seq will still hold zero numerics, but will test isVoid==true
(1 to 1000).all.averageFew(v => v, _ * 10, _ * 100).all.lp // Prints ~(500, 5005, 50050)
- Definition Classes
- _aggregate
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
collectOpt[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] + 1 + "ABC" + 22.0 + "DE" + 333F + "F" // Find length of the first matching string stream.collectOpt{ case s: String if (s.length > 1) => s.length }.lp // Prints: Opt(3)
-
def
contains[B >: A](value: B): Boolean
Includes check
-
def
copyTo(b: Idx.Buffer.Loader[A]): Unit
Copy to buffer
Copy to buffer
This is potentially the most efficient way to get all Stream elements
Idx.Buffer.Loader provides a trustless way to copy arrays in bulk, so many array based Streams can take advantage of this
- Definition Classes
- _convert
-
def
count(f: Filter[A]): Int
Element conditional count
-
def
count: Int
All elements count
-
def
countAndSeconds: (Int, Double)
Element count and time
Element count and time
Returns total count and time in seconds it took to pump the pipeline from first to last elements
val (count, seconds) = (1 to 1000).all.peek(_ => Thread.sleep(1)).countAndSeconds println("Count = " + count + ", done in " + seconds + " secs") // Output Count = 1000, done in 1.004261423 secs
- Definition Classes
- _evaluate
-
def
countFew(f: Filter[A]*): Seq[Int]
Element multi count
Element multi count
Counts elements for several filters at once
Returns Seq, where each Int corresponds to the given filter index
val Seq(total, odd, even) = (1 to 50).all.countFew(_ => true, _ % 2 == 1, _ % 2 == 0) println("total=" + total + ", odd=" + odd + ", even=" + even) // Output total=50, odd=25, even=25
- f
several filters
-
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' to 'C').all.peek(v => println("Process " + v)).drain // Output Process A Process B Process C
- Definition Classes
- _foreach
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
find(f: Filter[A]): A
Find
- def findAnyOpt: Opt[A]
-
def
findIdxOpt(f: Filter[A]): Opt.Int
Find index
Find index
Optionally returns index for the first element satisfying the filter or Opt.Void if none found
(50 to 500).all.findIdxOpt(_ == 400) // Retuns Opt(350)
- Definition Classes
- _evaluate
-
def
findOpt(f: Filter[A]): Opt[A]
Find
-
def
fold(start: A)(op: Folding[A]): A
Basic fold
Basic fold
Folds elements with a binary function
Returns
start
value for empty pipeline// Multiply every element by next (1 to 10).all.fold(1)(_ * _) // Returns 3628800
- start
seed value to start with
- Definition Classes
- _aggregate → _aggregate
-
def
foldAs[B](start: B)(op: Folding.As[B, A])(implicit arg0: Tag[B]): B
Fold and convert
Fold and convert
Folds and converts elements with a binary function
// Calculate sum of first 1000 Ints (1 to 1000).all.foldAs[Long](0L)(_ + _) // Returns 500500
- start
seed value to start with
- Definition Classes
- _aggregate
-
def
foldFlowAs[B](start: B)(op: Folding.As[B, A], cf: Folding[B] = null)(implicit arg0: Tag[B]): B
foldAs
- start
seed value to start with
- cf
collect function to put together results of parallel computations. It is not required and ignored for Stream
- Definition Classes
- _aggregate → _aggregate
-
abstract
def
foreach(f: Consumer[A]): Unit
For each
For each
Applies given function for each element
(1 to 3).all.foreach(v => println("Element: " + v)) // Output Element: 1 Element: 2 Element: 3
- Definition Classes
- _foreach
-
def
foreachIdx(f: Consumer.Idx[A], start: Int = 0): Unit
For each indexed
For each indexed
Calls foreach with counter
('A' to 'C').all.foreachIdx((i,v) => println("Element " + i + " = " + v), 1) // Output Element 1 = A Element 2 = B Element 3 = C
- start
starting value for indexing
- Definition Classes
- _foreach
-
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
('a' to 'j').all.format() // Returns abcdefghij ('a' to 'j').all.format("|") // Returns a|b|c|d|e|f|g|h|i|j ('a' to 'j').all.format(",", "[", "]") // Returns [a],[b],[c],[d],[e],[f],[g],[h],[i],[j]
- 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
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
isAny(f: Filter[A]): Boolean
Any check
-
def
isEvery(f: Filter[A]): Boolean
Every check
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
last: A
Last element
Last element
Returns the last stream element
Fails if empty
- Definition Classes
- _evaluate
-
def
lastOpt: Opt[A]
Last element
Last element
Optionally returns the last element or Opt.Void
- Definition Classes
- _evaluate
-
def
lp: Unit
Line print
Line print
Is equivalent to:
println(this)
For example:
(1 to 10).all.lp // Prints ~(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
- Definition Classes
- _convert
-
def
max(implicit o: Ordering[A]): A
Largest
Largest
Selects maximum element, based on the Ordering
Fails for empty stream
~~(4, 3, 12, 7).max // Returns 12
- Definition Classes
- _aggregate
-
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) // Returns CCCC
- Definition Classes
- _aggregate
-
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").maxByOpt(_.length).lp // Returns Opt(CCCC)
- Definition Classes
- _aggregate → _aggregate
-
def
maxOpt(implicit c: Ordering[A]): Opt[A]
Largest
Largest
Selects maximum element, based on the Ordering
~~(4, 3, 12, 7).maxOpt // Returns Opt(12)
- Definition Classes
- _aggregate → _aggregate
-
def
min(implicit o: Ordering[A]): A
Smallest
Smallest
Selects minimal element, based on the Ordering
Fails for empty stream
~~(4, 3, 12, 7).min // Returns 3
- Definition Classes
- _aggregate
-
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) // Returns B
- Definition Classes
- _aggregate
-
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").minByOpt(_.length) // Returns Opt(B)
- Definition Classes
- _aggregate → _aggregate
-
def
minOpt(implicit c: Ordering[A]): Opt[A]
Smallest
Smallest
Selects minimal element, based on the Ordering
~~(4, 3, 12, 7).minOpt // Returns Opt(3)
- Definition Classes
- _aggregate → _aggregate
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
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 Util.Range
Note. Range is void for empty pipelines.
(~~[Int] + 4 + 1 + 12 + 7).range // Returns range from 1 to 12
- Definition Classes
- _aggregate → _aggregate
-
def
reduce(op: Folding[A]): A
Reduces elements with a Folding functions
Reduces elements with a Folding functions
Will fail for empty Stream
- Definition Classes
- _aggregate → _aggregate
-
def
reduceOpt(op: 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 → _aggregate
-
def
sum(implicit n: Numeric[A]): A
Sum
Sum
Computes sum value of all elements
(0 to 1000).all.sum // Returns: 500500
- Definition Classes
- _aggregate → _aggregate
-
def
sumFew[B](f: Mapping[A, B]*)(implicit arg0: Numeric[B]): Seq[B] with Util.Able.Void
Multi sum
Multi sum
Simultaneously computes multiple sum values for properties specified by several functions
Returns Seq, with values corresponding to the given mappings
For empty pipelines returned Seq will still hold zero numerics, but will test isVoid==true
(1 to 1000).all.sumFew(v => v, _ * 10, _ * 100).all.lp // Prints ~(500500, 5005000, 50050000)
- Definition Classes
- _aggregate
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
to[TRGT[_]](implicit cnv: Stream.Interface.To[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.Immutable
- Idx.Buffer
- Refs
- 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] // Returns: Idx[String] ('A' to 'D').all.to[List] // Returns: scala.List[Char] (1 to 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
- Definition Classes
- _convert
-
def
toArray(implicit ct: ClassTag[A]): Array[A]
Convert to Array
Convert to Array
Converts stream to array
val a : Array[Int] = (1 to 10).all.toArray
- Definition Classes
- _convert
-
def
toMemory: ~[A]
New buffered stream
-
def
toRaw[TRGT](implicit c: Stream.Interface.ToRaw[A, TRGT]): TRGT
Convert to immutable collection
-
def
toString(): String
Elements as String
Elements as String
Returns String starting with
~(
and containing all elements separated by comma(1 to 5).all.toString // Returns ~(1, 2, 3, 4, 5)
- Definition Classes
- _convert → AnyRef → Any
-
def
toString(name: String): String
Elements as String
Elements as String
Returns String starting with given
name
and containing all elements separated by ", "(1 to 5).all.toString("My Ints") // Returns My Ints(1, 2, 3, 4, 5)
- Definition Classes
- _convert
-
def
toText: String
Elements as multi-line String
Elements as multi-line String
Returns all elements as String formatted table
If elements implement Util.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' to 'e').all.map(v => (v + "1", v + "2", v + "3", v + "4", v + "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
- _convert
-
def
tp: Unit
Text print
Text print
Is equivalent to:
println(this.toText)
For example:
('a' to 'd').all.zipIdx.tp // Output - - ? ? - - 0 a 1 b 2 c 3 d - -
- Definition Classes
- _convert
-
def
unequalOpt(that: ~[A], firstIndex: Int = 0, check: (A, A) ⇒ Boolean = _ == _): Opt[String]
Unequal check
Unequal check
Pumps both streams and compares all corresponding elements
When first not equal pair is found, message is returned
If all elements are equal, Opt.Void is returned
(0 to 10).all unequalOpt (0 to 10) // Prints: Opt.Void (0 to 10).all unequalOpt (0 until 10) // Prints: Opt(First has more elements) (0 to 5).all + 7 + 8 unequalOpt (0 to 10) // Prints: Opt(Fail at index 6: 7 != 6)
- firstIndex
- start of element indexing for error messages
- check
is the function to compare two elements
- Definition Classes
- _evaluate
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Stream Consumption Operations
After invocation of any method, the Stream must be discarded (its behavior is no longer predictable)