[Haskell-cafe] Newbie: Appending arrays?

Chaddaï Fouché chaddai.fouche at gmail.com
Fri Jul 11 11:23:53 EDT 2008


2008/7/11 Dmitri O.Kondratiev <dokondr at gmail.com>:
> How does Data.Sequence
> http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Sequence.html
> compares with ArrayRef for appending and accessing arrays efficiently ?

It doesn't since Data.Sequence doesn't use arrays, it uses a custom
data structure that allows to do plenty of operations with pretty good
asymptotic complexity. Be aware though that the constants aren't that
good and that depending on your usage, lists, array or another
specialized data structure could be much more efficient.

By comparisons, extending an array is very likely to be much more
expensive from time to time than adding some elements to your
Data.Sequence. On the other hand the random access would be much
faster in an array and even the amortized cost of extending the array
may not be much worse than the amortized cost on the Data.Sequence in
some cases.

What exactly are you trying to do ?

-- 
Jedaï


More information about the Haskell-Cafe mailing list