Haskell data structure with O(1) indexing/updating and O(logn) cons

Viewed 225

Currently I need an immutable data structure (indexed by Int) that has fast read and update (basically, effectively O(1)), but somewhat slower cons (such as O(logn)) is acceptable. Other operations are not necessary. What I have now are:

  • Data.IntMap which is a radix tree. It has asymptotic O(1) for everything and is currently the best choice.
  • Data.Sequence which is a finger tree. It has worst-case O(logn) lookup/update but O(1) cons. That is not quite in line with my need and indeed performs worse then IntMaps in my microbenchmarks.
  • Data.HashMap has O(logn) for everything and performs worse than IntMap.

My question is: is there any Haskell data structures that can perform better than IntMap in this regard?

0 Answers
Related