Skip to content
Snippets Groups Projects
Unverified Commit 526b675b authored by Hamza Remmal's avatar Hamza Remmal :homes:
Browse files

Add Intersection Wrong example from lecture 3

parent 81d408ac
No related branches found
No related tags found
No related merge requests found
package lecture3
import scala.collection._
import scala.collection.parallel.CollectionConverters.IterableIsParallelizable
import org.scalameter._
// TODO : THIS DOES NOT COMPILE
def intersection(a: GenSet[Int], b: GenSet[Int]): Set[Int] =
val result = mutable.Set[Int]()
for (x <- a) if (b contains x) result += x
result
@main def intersectionWrong =
val seqres = intersection((0 until 1000).toSet, (0 until 1000 by 4).toSet)
val parres = intersection((0 until 1000).par.toSet, (0 until 1000 by 4).par.toSet)
log(s"Sequential result - ${seqres.size}")
log(s"Parallel result - ${parres.size}")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment