I'm looking at using a DoubleLinkedList. It's remove() method says "Removes the current node from the double linked list." but there are no other references to current in the page.
What is the current node, how do I set it, and surely this can't be…
Say I have a set of Strings that I want to be ordered by length but unique by the normal String uniqueness. What I mean is that I that I could have more than one String of same length in the Set, but that they should be sorted by length.
I want to…
I have a list of type List(String,String) and I wanted to convert it to map. When I used toMap method I found that it does not preservers the order of data that is there in the List. However my goal is to convert the list to Map by keeping the order…
In Scala Collection documentation, there is some clue to this question:
Trait Seq has two subtraits LinearSeq, and IndexedSeq. These do not add any new operations, but each offers different performance characteristics: A linear sequence has…
If I create a Set in Scala using Set(1, 2, 3) I get an immutable.Set.
scala> val s = Set(1, 2, 3)
s: scala.collection.immutable.Set[Int] = Set(1, 2, 3)
Q1: What kind of Set is this actually? Is it some hash-set? What is the complexity of look-ups…
Does Scala provide a built-in class, utility, syntax, or other mechanism for converting (by wrapping) an Iterator with an Iterable?
For example, I have an Iterator[Foo] and I need an Iterable[Foo], so currently I am:
val foo1: Iterator[Foo] = ....
…
In trying to write an API I'm struggling with Scala's collections in 2.8(.0-beta1).
Basically what I need is to write something that:
adds functionality to immutable sets of a certain type
where all methods like filter and map return a collection…
In Scala before 2.10, I can set the parallelism in the defaultForkJoinPool (as in this answer scala parallel collections degree of parallelism). In Scala 2.10, that API no longer exists. It is well documented that we can set the parallelism on a…
Let's say I have two optional Ints (both can be Some or None):
val one : Option[Int] = Some(1)
val two : Option[Int] = Some(2)
My question is the following: Are there any intelligent way to sum them op using Scalas brilliant collection-methods? I…
I want to work with an immutable indexed multidimensional array. The structure that makes sense is a Vector of Vectors.
scala> val v = Vector[Vector[Int]](Vector[Int](1,2,3), Vector[Int](4,5,6), Vector[Int](7,8,9))
v:…
This post only discusses scala.collection.mutable.LinkedList. Other implementations are not the topic of this thread.
My question is: what is the use case of this class? I find it has the problems of both mutable and immutable type of structures…
a and b are values of Iterator[String] type. I need c to include all the elements of a and b. Surprisingly I can't figure out how to achieve this. May you happen to know?
I'm confused about behavior of method take in trait Iterator. It seems that it doesn't consume items. Here is an example:
scala> Iterator(1,2,3)
res0: Iterator[Int] = non-empty iterator
scala> res0 take 2 toArray
res1: Array[Int] = Array(1,…
I have an Iterator[Option[T]] and I want to get an Iterator[T] for those Options where T isDefined. There must be a better way than this:
it filter { _ isDefined} map { _ get }
I would have thought that it was possible in one construct... Anybody…
I noticed that Stream is deprecated in Scala 2.13 and they suggest using LazyList.
They also say "Use LazyList (which is fully lazy) instead of Stream (which has a lazy tail only)".
What does it exactly mean ? Why did they deprecate Stream ?