Scala Collections
Adding and Multiplication
val data2 = Map(1 -> 1, 2 -> 1)
// data2: scala.collection.immutable.Map[Int,Int] = Map(1 -> 1, 2 -> 1)
val data1 = Map(1 -> 3, 2 -> 5, 3 -> 7, 5 -> 1)
// data1: scala.collection.immutable.Map[Int,Int] = Map(1 -> 3, 2 -> 5, 3 -> 7, 5 -> 1)
import com.twitter.algebird.Operators._
// import com.twitter.algebird.Operators._
data1 + data2
// res0: scala.collection.immutable.Map[Int,Int] = Map(1 -> 4, 2 -> 6, 3 -> 7, 5 -> 1)
data1 * data2
// res1: scala.collection.immutable.Map[Int,Int] = Map(1 -> 3, 2 -> 5)
Set(1,2,3) + Set(3,4,5)
// res2: scala.collection.immutable.Set[Int] = Set(5, 1, 2, 3, 4)
List(1,2,3) + List(3,4,5)
// res3: List[Int] = List(1, 2, 3, 3, 4, 5)
Map(1 -> 3, 2 -> 4, 3 -> 1) * Map(2 -> 2)
// res4: scala.collection.immutable.Map[Int,Int] = Map(2 -> 8)
Map(1 -> Set(2,3), 2 -> Set(1)) + Map(2 -> Set(2,3))
// res5: scala.collection.immutable.Map[Int,scala.collection.immutable.Set[Int]] = Map(1 -> Set(2, 3), 2 -> Set(1, 2, 3))
Other Collections
- IndexedSeq.scala
- MapAlgebra.scala
- PriorityQueue aggregator, monoid
Documentation Help
We’d love your help fleshing out this documentation! You can edit this page in your browser by clicking this link.