Bringing the IntMap API up to par with the Map API

Johan Tibell johan.tibell at
Fri Aug 6 09:59:11 EDT 2010

There are a few functions on Maps that could be implemented on IntMaps but

  - deleteAt
  - elemAt
  - updateAt
  - findIndex
  - lookupIndex

The above 5 functions can be efficiently implemented on Maps in O(log n)
time, as the size of the subtrees are known, but not not on IntMaps. We
could still provide O(n) versions for IntMap. What's the use case for
indexed lookup in maps? I've never seen it in other languages.

- foldlWithKey
- foldrWithKey
- insertWith'
- insertWithKey'
- mapKeys
- mapKeysMonotonic
- mapKeysWith
- toDescList

I believe these should these should be straightforward to implement.

I suggest we add these functions to IntMap so one doesn't it's a "no
brainer" to switch from Maps to IntMaps for int keys.

Are there any other functions that should be added to both APIs e.g. strict
updateWith functions?

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Libraries mailing list