Welcome to Scala 2.13.0-M5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_161).
Type in expressions for evaluation. Or try :help.
scala> val map = collection.mutable.AnyRefMap.empty[String, Int]
map: scala.collection.mutable.AnyRefMap[String,Int] = AnyRefMap()
scala> map.getOrElseUpdate("FB", { map.put("Ea", 1) ; 2 })
res0: Int = 2
scala> map.size
res1: Int = 2
scala> map.toList
res2: List[(String, Int)] = List((FB,2))
scala> map.get("Ea")
res3: Option[Int] = None
getOrElseUpdate
is not allowed"?
getOrElseUpdate
to get(key).getOrElse(put(key, default))
, and my understanding of the point of getOrElseUpdate
is that it's supposed to be faster than that (due to only having to find the entry once)
knownSize
is always O(1)
in the library so far. I would say O(log n)
is more like O(1)
than like O(n)
(in the sense that O(log n)^2
is less than O(n)
), so if it happened somehow to take O(log n)
time to compute knownSize
it probably should be computed instead of returning -1
.
IterableOnce
or an Iterator
without looping myself? Wouldn't last
/lastOption
make sense for them (I know the other right-oriented variants takeRight
/dropRight
were removed earlier from the strawman as they would require buffering, but last
/lastOption
would only need a buffer of size one)?
ListBuffer.from(iterableOnce).lastOption
reduce
and fold
also work
List
for instance, Seq
wants concat
to mean appendedAll
, but there's a StrictOptimizedIterableOps#concat
that gets mixed in later..
concat
enate" implies an order, but the paint's dry on that shed, I'm sure)