Aladdin - Scala Bugtracking
[#1129] project: api priority: low category: missing feature
submitter assigned to status date submitted
Nikolay Sean won't fix 2007-05-21 21:06:31.0
subject [contrib #513] Collection classes should make it possible to define an alternative comparator
code
(no code)
what happened
I wanted to have a collection (a set to be precise) in which objects would be compared by a different notion of \
equality than the one of ==. It was not possible using the collections of the Scala library.
what expected Like Java collections, all Scala collections should offer a constructor that accepts a comparator as argument. This comparator should then be used to compare elements of the collection.
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-05-21 21:07:01.0
Sean  edited on  2007-05-21 21:56:22.0
I'm not sure if we should do this. Configurable comparators only applies to ordered collections. Also, there is a handy function I just added last week: scala.Collection.equalsWith. If you want it to be the default, override equals?
Sean  edited on  2007-07-17 18:03:31.0
Only sorted collections accept comparators, and these will work in Scala (e.g., new TreeSet[String]()(str => new MyCompator(str))). Use equalsWith in sequence if possible. Otherwise, Java doesn't support this, so we can't support it in the JCL.