Are multi-networks missing in Scala?

I tried to solve qualification problems in the Hacker Cup 2013 in Scala, and for the third problem I felt the need for the ordered Multiset, but could not find it in the scala collections (2.10). Is this data structure missing from scala collections. Will it be implemented in a future version? Is Multiset really unnecessary if you already have the kit installed?

+7
source share
4 answers

A multiset is a rather peculiar and unusual data structure. This is not, for example, part of the standard Java library. Guava has one, and Boost, but Boost has basically everything.

If you only want to count the number of occurrences of elements, you can resort to SortedMap from the element to count. If you want the elements to be crisp, retrievable, but equivalent in sorting rules, you could use the SortedMap from the element (no matter which one) to Set selected elements to.

+1
source

Multiple sets can be quite useful sometimes. I often find that I encode Map[K, List[V]] manually. There is a large implementation of multisets called Bag Nicolas Staki, and is released on Maven.

Announced here:

https://groups.google.com/forum/#!topic/scala-internals/ceaEAiQPgK4

The code is here:

https://github.com/nicolasstucki/multisets

Maven:

https://github.com/nicolasstucki/multisets/blob/master/MavenRepository.md

+7
source

Seq has diff , intersect and even union . This should help you with a lot of your problems with multiple tasks. http://www.scala-lang.org/api/2.11.7/index.html# scala.collection.Seq@diff (that: Seq [A]): ​​Seq [A]

+2
source

If all you need is equality, and you don't care too much about performance, you can just use sorted lists.

0
source

All Articles