Def
Inherited
Pack
Pack
Returns stream elements as Pack
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Average
Average
Computes average
For empty Stream returns zero value
(10 <> 15).~.map(_.Float).average // Returns 12.5
Note: average is available for types providing given ~~.Custom.Math.Average implementations, which are by default Double, Float and opaque numerics based on Double and Float
- Inherited from
- _calculate
- Source
- _calculate.scala
Average option
Average option
Computes average or returns void option for empty stream
(10 <> 15).~.map(_.Float).average_? // Returns Opt(12.5)
Note: average_? is available for types providing given ~~.Custom.Math.Average implementations, which are by default Double, Float and opaque numerics based on Double and Float
- Inherited from
- _calculate
- Source
- _calculate.scala
Multi average
Multi average
Simultaneously computes up to 5 average values for properties specified by functions
Returns tuple of appropriate size with values corresponding to the given mappings
For empty Stream returned tuple will hold zeros
(1 <> 1000).~.averageFew(_ * 10F, _ * 100F).tp // Prints (5005, 50050)
val (first, second, third) = (1 <> 1000).~.averageFew(v => v.Double, _ * 10.0, _ * 100.0)
first.tp // Prints 5005
second.tp // Prints 5005
third.tp // Prints 5005
Note: Averages areavailable for types providing given Stream.Custom.Average implementations, which are by default Double, Float and opaque numerics based on Double and Float
- Inherited from
- _calculate
- Source
- _calculate.scala
Value check
Value check
Returns true if stream contains given value.
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Conditional count
Conditional count
Counts all stream elements, which satisfy given predicate
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Count and time
Count and time
Returns all elements count and Time.Length it took to pump the stream
val (cnt,time) = (1 <> 1000).~.peek(_ => J.sleep(1.Millis)).countAndTime
("" + cnt + " elements processed in " + time.tag).tp
// Output
1000 elements processed in 1.488880500 sec
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Multi count
Multi count
Simultaneously counts values for up to 5 different predicates
Returns tuple of appropriate size with values corresponding to the given mappings
For empty Stream returned tuple will hold zeros
val (large, odd, even) = (1 <>> 1000).~.countFew(_ > 100, _ % 2 == 0, _ % 2 == 1)
large.tp // Prints 899
odd.tp // Prints 499
even.tp // Prints 500
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Pump stream out
Pump stream out
Fetches and discards all stream elements
This operation can be usefull for side effects built into streaming pipeline
('A' <> 'C').~.peek(_.tp).drain
// Output
A
B
C
- Inherited from
- _process
- Source
- _process.scala
Equal check
Equal check
Iterates both streams and compares all corresponding elements
Returns true
if all are equal, `false`` otherwise
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Equal check
Equal check
Iterates both streams and compares all corresponding elements
When first not equal pair is found, the problem result is returned
If all elements are equal, Result[true] is returned
(0 <> 10).~.equalsAll_??(0 <> 10).tp
// Prints: Result(true)
(0 <> 10).~.equalsAll_??(0 <>> 10).tp
// Prints: Result(Problem(Second stream has less elements))
((0 <> 5).~ + 7 + 8).equalsAll_??(0 <> 10).tp
// Prints: Result(Problem(Fail at index 6: 7 != 6))
Note: The returned problem contains message with basic description
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Equal start check
Equal start check
Checks if starting elements of two streams (to a point where one stream ends) are equal
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Equal start check
Equal start check
Checks if starting elements of two streams (to a point where one stream ends) are equal
(0 <> 10).~.equalsStart_??(0 <> 1000).tp
// Prints: Result(true)
(0 <> 1000).~.equalsStart_??(0 <> 10).tp
// Prints: Result(true)
((0 <> 5).~ + 7 + 8).equalsStart_??(0 <> 10).tp
// Prints: Result(Problem(Fail at index 6: 7 != 6))
Note: The returned problem result contains message with basic description
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Exists check
Exists check
Returns true if there is an elemnet satisfying given predicate
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Find value
Find value
Finds the first value accepted by given predicate
(1 <> 1000).~.find(_ > 100).tp // Prints 101
Note: If value is not found find fails, use find_? in most cases
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Optional find value
Optional find value
Finds the first value accepted by given predicate or returns void option if not found
(1 <> 1000).~.find_?(_ > 100).tp // Prints Opt(101)
(1 <> 10).~.find_?(_ > 100).tp // Prints Opt(\/)
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Find index
Find index
Optionally returns index for the first element satisfying the predicate or Int.Opt(/) if none found
(50 <> 500).~.findPosition_?(_ == 400) // Retuns Int.Opt(350)
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Fold
Fold
Folds elements with a binary function
// Calculate sum of first 1000 Ints
(1 <> 1000).~.fold(0)(_ + _) // Returns 500500
- Value Params
- f
binary function to fold elements with
- start
seed value to start with
- Inherited from
- _aggregate
- Source
- _aggregate.scala
Heavy Fold
Heavy Fold
Folds elements with a binary function
FOLD is functionally equivalent to fold, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.
- Inherited from
- _aggregate
- Source
- _aggregate.scala
Heavy Fold and convert
Heavy Fold and convert
Folds and converts elements with a binary function
FOLD_AS is functionally equivalent to foldAs, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.
- Inherited from
- _aggregate
- Source
- _aggregate.scala
Fold and convert
Fold and convert
Folds and converts elements with a binary function
// Calculate sum of first 1000 Ints
(1 <> 1000).~.foldAs(0L)(_ + _) // Returns 500500
- Value Params
- f
binary function to fold elements with
- start
seed value to start with
- Inherited from
- _aggregate
- Source
- _aggregate.scala
Heavy process stream
Heavy process stream
Applies given function to each stream element
FOREACH is functionally equivalent to foreach, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.
- Inherited from
- _process
- Source
- _process.scala
Process stream
Process stream
Applies given function to each stream element
('A' <> 'C').~.foreach(_.tp)
// Output
A
B
C
- Inherited from
- _process
- Source
- _process.scala
For each indexed
For each indexed
Calls given function with counter
('A' <> 'C').~.foreachIndexed((i,v) => "Element " + i + " = " + v tp(), 1)
// Output
Element 1 = A
Element 2 = B
Element 3 = C
- Value Params
- start
starting value for indexing
- Inherited from
- _process
- Source
- _process.scala
Run for nonexistent value
Run for nonexistent value
Runs given function only if stream is empty.
This operation is rarely useful and is provided for consistency.
Use peekEmpty instead, it can be combined with other processing
- Inherited from
- _process
- Source
- _process.scala
Forall check
Forall check
Returns true if every single element satisfies the given predicate
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Iterator view
Iterator view
Wraps current stream as scala.collection.Iterator
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Last element
Last element
Returns the last stream element
Fails if empty
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Last element
Last element
Optionally returns the last element or Opt(/)
- Inherited from
- _evaluate
- Source
- _evaluate.scala
Convert ot String
Convert ot String
The result is a concatenation of all elements with given separator
('a' <> 'j').~.makeString() // Returns abcdefghij
('a' <> 'j').~.makeString("|") // Returns a|b|c|d|e|f|g|h|i|j
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Maximum
Maximum
Computes maximum value
Fails for empty streams
- Inherited from
- _calculate
- Source
- _calculate.scala
Optional maximum
Optional maximum
Computes maximum value or returns void option for empty streams
- Inherited from
- _calculate
- Source
- _calculate.scala
Maximum by property
Maximum by property
Computes maximum value based on given function
Fails for empty streams
- Inherited from
- _calculate
- Source
- _calculate.scala
Optional maximum by property
Optional maximum by property
Computes maximum value based on given function or returns void option for empty streams
- Inherited from
- _calculate
- Source
- _calculate.scala
Minimum
Minimum
Computes minimum value
Fails for empty streams
- Inherited from
- _calculate
- Source
- _calculate.scala
Optional minimum
Optional minimum
Computes minimum value or returns void option for empty streams
- Inherited from
- _calculate
- Source
- _calculate.scala
Minimum by property
Minimum by property
Computes minimum value based on given function
Fails for empty streams
- Inherited from
- _calculate
- Source
- _calculate.scala
Optional minimum by property
Optional minimum by property
Computes minimum value based on given function or returns void option for empty streams
- Inherited from
- _calculate
- Source
- _calculate.scala
Print to console
Print to console
Prints stream elements in a table like structure
Tuples, case classes, products, and Able.Info object properties are formatted as table columns
('A' <> 'F').~.map(v => (v.Int, v)).print
// Output
-- --
_1 _2
-- --
65 A
66 B
67 C
68 D
69 E
70 F
-- --
// -----------------------------------------------------
case class Case(int: Int, name: String, odd: Boolean):
def this(i: Int) = this(i, "Name"+i, i%2==0)
(1 <> 10).~.map(new Case(_)).print
// Output
--- ------ -----
int name odd
--- ------ -----
1 Name1 false
2 Name2 true
3 Name3 false
4 Name4 true
5 Name5 false
6 Name6 true
7 Name7 false
8 Name8 true
9 Name9 false
10 Name10 true
--- ------ -----
- Inherited from
- _print
- Source
- _print.scala
Print to console with rows numbered
Print to console with rows numbered
Same as regular print, but with added row number as first column
('A' <> 'F').~.map(v => (v.Int, v)).print_#
// Output
-- -- --
# _1 _2
-- -- --
0 65 A
1 66 B
2 67 C
3 68 D
4 69 E
5 70 F
-- -- --
Note: Number is mostly usefull for longer or even infinite streams
- Inherited from
- _print
- Source
- _print.scala
Print to console with rows indexed
Print to console with rows indexed
Same as regular print, but with added index as first column identifying the object
('A' <> 'F').~.map(v => (v.Int, v)).print
// Output
----------------- -- --
Id _1 _2
----------------- -- --
scala.Tuple2@dzkr 65 A
scala.Tuple2@zn1 66 B
scala.Tuple2@71j3 67 C
scala.Tuple2@562u 68 D
scala.Tuple2@c8tt 69 E
scala.Tuple2@p0m8 70 F
----------------- -- --
- Inherited from
- _print
- Source
- _print.scala
Process elements or empty case
Process elements or empty case
Applies given function to each stream element or runs second function when stream is empty
('A' <>> 'A').~.process(_.tp, "Empty".tp)
// Output
Empty
- Inherited from
- _process
- Source
- _process.scala
Range
Range
Computes value range
Fails for empty streams
- Inherited from
- _calculate
- Source
- _calculate.scala
Optional range
Optional range
Computes value value or returns void option for empty streams
- Inherited from
- _calculate
- Source
- _calculate.scala
Next element
Next element
Delivers next stream element
val s : ~[Char] = 'A' <> 'Z'
s.read.tp // Prints A
s.read.tp // Prints B
s.read.tp // Prints C
Note: If stream is empty, read will fail. So, use a safer read_? in most cases
- Inherited from
- _read
- Source
- _read.scala
Read many elements
Read many elements
Immediatelly removes given number of elements from current stream and returns them as a new stream
val s : ~[Int] = 1 <> 12
s.read_~(3).tp // Prints ~(1, 2, 3)
s.read_~(4).tp // Prints ~(4, 5, 6, 7)
s.read_~(7).tp // Prints ~(8, 9, 10, 11, 12)
s.read_~(8).tp // Prints ~()
Note: If requested number of elements is not available, the number returned is less (0 if empty)
- Inherited from
- _read
- Source
- _read.scala
Next optional element
Next optional element
Delivers next stream element or void option if stream is empty
val s : ~[Char] = 'A' <> 'C'
s.read_?.tp // Prints Opt(A)
s.read_?.tp // Prints Opt(B)
s.read_?.tp // Prints Opt(C)
s.read_?.tp // Prints Opt(\/)
- Inherited from
- _read
- Source
- _read.scala
Reduce
Reduce
Folds elements with a binary function
// Calculate sum of first 1000 Ints
(1 <> 1000).~.reduce(_ + _) // Returns 500500
Note. Threre is no default value, and if stream is empty, operation fails. Use reduce_? as safer option
- Value Params
- f
binary function to fold elements with
- Inherited from
- _aggregate
- Source
- _aggregate.scala
Heavy reduce
Heavy reduce
Folds elements with a binary function
REDUCE is functionally equivalent to reduce, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.
- Inherited from
- _aggregate
- Source
- _aggregate.scala
Optional reduce
Optional reduce
Folds elements with a binary function or returns empty option when stream is empty
// Calculate sum of first 1000 Ints
(1 <> 1000).~.reduce_?(_ + _) // Returns Opt(500500)
- Value Params
- f
binary function to fold elements with
- Inherited from
- _aggregate
- Source
- _aggregate.scala
Heavy optional reduce
Heavy optional reduce
Folds elements with a binary function
REDUCE_? is functionally equivalent to reduce_?, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.
- Inherited from
- _aggregate
- Source
- _aggregate.scala
Sum
Sum
Calculates sum of all values
For empty stream returns zero
(1 <> 1000).~.sum.tp // Prints 500500
- Inherited from
- _calculate
- Source
- _calculate.scala
Optional sum
Optional sum
Calculates sum of all values or returns void option for empty streams
(1 <> 1000).~.sum_?.tp // Prints Opt(500500)
- Inherited from
- _calculate
- Source
- _calculate.scala
Multi sum
Multi sum
Simultaneously computes up to 5 sum values for properties specified by given functions
Returns tuple of appropriate size with values corresponding to the given mappings
For empty Stream returned tuple will hold zeros
(1 <> 1000).~.sumFew(_ * 10, _ * 100).tp // Prints (5005000, 50050000)
val (first, second, third) = (1 <> 1000).~.sumFew(v => v, _ * 10, _ * 100)
first.tp // Prints 500500
second.tp // Prints 5005000
third.tp // Prints 50050000
- Inherited from
- _calculate
- Source
- _calculate.scala
Convert to Array
Convert to Array
Returns stream elements as Array
val a : Array[Int] = (1 <> 10).~.toArray
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to Buffer
Convert to Buffer
Returns stream elements as Buffer
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to Idx
Convert to Idx
Returns stream elements as Idx
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to Java Iterator
Convert to Java Iterator
Wraps current stream as java.util.Iterator
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to Java List
Convert to Java List
Returns stream elements as java.util.List
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to Java Spliterator
Convert to Java Spliterator
Wraps current stream as java.util.Spliterator
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to Java Stream
Convert to Java Stream
Wraps current stream as java.util.stream.Stream
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to List
Convert to List
Returns stream elements as scala.collection.immutable.List
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to Lookup
Convert to Lookup
Returns a stream of tuples with (Key,Value) pairs as Lookup
val intLookup : Lookup[Int,Char] = ('A' <> 'F').~.zipKey(_.Int).toLookup
intLookup.pair_~.tp // Prints ~((69,E), (70,F), (65,A), (66,B), (67,C), (68,D))
val charLookup : Lookup[Char,Int] = ('A' <> 'F').~.zipValue(_.Int).toLookup
charLookup.pair_~.tp // Prints ~((E,69), (F,70), (A,65), (B,66), (C,67), (D,68))
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to Product
Convert to Product
Returns stream elements as scala.Product
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to Seq
Convert to Seq
Returns stream elements as scala.collection.immutable.IndexedSeq
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to unique collection
Convert to unique collection
Returns stream elements as StableSet
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Elements as multi-line String
Elements as multi-line String
Returns all elements as String formatted table
If elements implement Able.Info, 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').~.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
-- -- -- -- --
- Inherited from
- _transformTo
- Source
- _transformTo.scala
Convert to Vector
Convert to Vector
Returns stream elements as scala.collection.immutable.Vector
- Inherited from
- _transformTo
- Source
- _transformTo.scala