This page is no longer maintained — Please continue to the home page at www.scala-lang.org

MultiSet, MultiMap, BidiMap

5 replies
Landei
Joined: 2008-12-18,
User offline. Last seen 45 weeks 4 days ago.

Hi!

I think the new Scala Collection Framework could be a good reason to discuss
about additional data structures. I'm especially missing MultiSet (a.k.a
Bag), MultiMap and BidiMap. Of course it's easy to come up with own
implementations based on the existing classes (and I'm pretty sure there are
already some of these around), however I think it is important that these
classes fit into the new framework structure.

What I want to discuss here is:
- Should these classes be part of the Scala distribution? If not, what would
be an approriate place?
- How should the interfaces look like, given the structure and the
limitations of the new framework?

What do you think?

Cheers,
Daniel

Erik Engbrecht
Joined: 2008-12-19,
User offline. Last seen 3 years 18 weeks ago.
Re: MultiSet, MultiMap, BidiMap
I'd suggest discussing it on the Scala Incubator Google group.
http://groups.google.com/group/scala-incubator

On Fri, Dec 25, 2009 at 3:44 PM, Landei <Daniel [dot] Gronau [at] gmx [dot] de> wrote:

Hi!

I think the new Scala Collection Framework could be a good reason to discuss
about additional data structures. I'm especially missing MultiSet (a.k.a
Bag), MultiMap and BidiMap. Of course it's easy to come up with own
implementations based on the existing classes (and I'm pretty sure there are
already some of these around), however I think it is important that these
classes fit into the new framework structure.

What I want to discuss here is:
- Should these classes be part of the Scala distribution? If not, what would
be an approriate place?
- How should the interfaces look like, given the structure and the
limitations of the new framework?

What do you think?

Cheers,
Daniel
--
View this message in context: http://old.nabble.com/MultiSet%2C-MultiMap%2C-BidiMap-tp26923642p26923642.html
Sent from the Scala - Debate mailing list archive at Nabble.com.




--
http://erikengbrecht.blogspot.com/
f.esser
Joined: 2009-11-23,
User offline. Last seen 42 years 45 weeks ago.
Re: MultiSet, MultiMap, BidiMap

Landei wrote:
>
> Hi!
>
> I think the new Scala Collection Framework could be a good reason to
> discuss about additional data structures. I'm especially missing MultiSet
> (a.k.a Bag), MultiMap and BidiMap.
>
> What do you think?
>
> Cheers,
> Daniel
>

Just for fun! These small scala sets are already kind of multi-sets (bags):

import scala.collection.immutable.Set._

val s2= new Set2(1,1)
val s3= new Set3(1,1,1)
val s4= new Set4(1,1,1,1)
println(s2.size) // 2
println(s3.size) // 3
println(s4.size) // 4

println(s2.drop(1).size) // 1
println(s2.count(_==1)) // 2
println(s4.count(_==1)) // 4

esser

ounos
Joined: 2008-12-29,
User offline. Last seen 3 years 44 weeks ago.
Re: MultiSet, MultiMap, BidiMap

2009/12/29 f.esser :
>
>
> Landei wrote:
>>
>> Hi!
>>
>> I think the new Scala Collection Framework could be a good reason to
>> discuss about additional data structures. I'm especially missing MultiSet
>> (a.k.a Bag), MultiMap and BidiMap.
>>
>> What do you think?
>>
>> Cheers,
>> Daniel
>>
>
> Just for fun! These small scala sets are already kind of multi-sets (bags):
>
>    import scala.collection.immutable.Set._
>
>    val s2= new Set2(1,1)
>    val s3= new Set3(1,1,1)
>    val s4= new Set4(1,1,1,1)
>    println(s2.size)  // 2
>    println(s3.size)  // 3
>    println(s4.size)  // 4
>
>    println(s2.drop(1).size)    // 1
>    println(s2.count(_==1))  // 2
>    println(s4.count(_==1))  // 4
>
>
> esser

Wow. Please file a bug, these constructors should have been private.

>
> --
> View this message in context: http://old.nabble.com/MultiSet%2C-MultiMap%2C-BidiMap-tp26923642p2695332...
> Sent from the Scala - Debate mailing list archive at Nabble.com.
>
>

f.esser
Joined: 2009-11-23,
User offline. Last seen 42 years 45 weeks ago.
Re: MultiSet, MultiMap, BidiMap

Dimitris Andreou wrote:
>
>
> Wow. Please file a bug, these constructors should have been private.
>
>

Sorry,

but I use Set2, Set3 for an (undirected) graph-implementation,
i.e. new Set2(1,1) represents a loop from node 1 to itself.
You see, even small bags are useful.

Greetings
Esser

ounos
Joined: 2008-12-29,
User offline. Last seen 3 years 44 weeks ago.
Re: MultiSet, MultiMap, BidiMap

2009/12/29 f.esser :
>
>
> Dimitris Andreou wrote:
>>
>>
>> Wow. Please file a bug, these constructors should have been private.
>>
>>
>
> Sorry,
>
> but I use Set2, Set3 for an (undirected) graph-implementation,
> i.e. new Set2(1,1) represents a loop from node 1 to itself.
> You see, even small bags are useful.
>
> Greetings
> Esser

I filed it anyway: https://lampsvn.epfl.ch/trac/scala/ticket/2845

If you are using sets to represent edges (is this right?), you could
use Pair/Tuple2 instead of Set2. But you mention Set3 too. Are you
doing hypergraphs then?? That's very rare. Anyway, I think it would be
prudent to remove dependencies on such "features" from your code. :)

Regards,
Dimitris

>
> --
> View this message in context: http://old.nabble.com/MultiSet%2C-MultiMap%2C-BidiMap-tp26923642p2695395...
> Sent from the Scala - Debate mailing list archive at Nabble.com.
>
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland