UnionSeq - laforge49/Asynchronous-Functional-Programming GitHub Wiki
UnionSeq[K, V] extends Sequence[K, java.util.List[V]]. It is used for combining the key/value pairs of several sequences while maintaining key order. The constructor takes 2 parameters, (1) a mailbox and (2) a list of Sequence[K, V] objects.
Test code.
val seqs = new java.util.ArrayList[Sequence[Int, Int]]
val range = new Range(1, 15)
seqs.add(new FilterSeq(range, (x: Int) => x % 2 == 0))
seqs.add(new FilterSeq(range, (x: Int) => x % 3 == 0))
seqs.add(new FilterSeq(range, (x: Int) => x % 5 == 0))
val union = new UnionSeq(null, seqs)
Future(union, Loop((key: Int, value: java.util.List[Int]) => println(key+" "+value)))
Output.
2 [2]
3 [3]
4 [4]
5 [5]
6 [6, 6]
8 [8]
9 [9]
10 [10, 10]
12 [12, 12]
14 [14]