-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
I noticed that flipM is implemented with flipAL, which uses Eq constraints. I think it's O(n^2) but could instead be O(n log n) with something like
flipM = Map.fromListWith (++) . map (\(k, v) -> (v, [k])) . Map.toListThere are details to check here: are the values in the new map in the same order as with the current implementation? What kind of efficiency does it have if every value in the original map is equal? I think the answers are "yes" and "O(n)" respectively, but that's just from a quick glance. Even if it's not quite right, something like this should be possible.
Metadata
Metadata
Assignees
Labels
No labels