-
Notifications
You must be signed in to change notification settings - Fork 1
FlatmapSeq
laforge49 edited this page Aug 18, 2011
·
4 revisions
FlatmapSeq[K, V, V1] is a subclass of Sequence[K, V1] and is used to transform the values of another sequence, while dropping null values. The constructor takes two parameters, (1) another sequence actor, seq: Sequence[K, V], and (2) a function, f: V => V1. FlatmapSeq takes its mailbox from its seq actor, so its interactions with seq are usually synchronous.
Test code.
val alphabet = new java.util.HashMap[Int, String]
alphabet.put(8, "Apple")
alphabet.put(22, "Boy")
alphabet.put(5, "Cat")
val range = Range(0, 10)
val flatmap = new FlatmapSeq(range, (v: Int) => alphabet.get(v))
Future(flatmap, Loop((key: Int, value: String) => println(key+" "+value)))
Output.
5 Cat
8 Apple