How to implement collection with covariance when delegating to another collection for storage?
- by memelet
I'm trying to implement a type of SortedMap with extended semantics. I'm trying to delegate to SortedMap as the storage but can't get around the variance constraints:
class IntervalMap[A, +B](implicit val ordering: Ordering[A])
//extends ...
{
var underlying = SortedMap.empty[A, List[B]]
}
Here is the error I get. I understand why I get…