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 ?
2008/7/11 Dmitri O.Kondratiev <dokondr@gmail.com>:
> I don't quite understand how Data.Array.Diff work.replaceDiffArray is low-level, nobody should use it, use the normal
> I tried this:
>
>> let arr = listArray (1,3) [1..3] :: DiffArray Int Int
>
> then:
>> replaceDiffArray arr [(1, 777)]
> array (1,3) [(1,1),(2,777),(3,3)]
> Why when replacing first element the second one changes?
IArray interface instead.
(To answer your question, replaceDiffArray works with low level index,
not the Ix class, all array are indexed by 0, 1, .. for it, so 1 is
the index of the second element of the array)
No, the size of a DiffArray can't be changed : DiffArray are just an
> and also trying to add 4-th element results in:
> Prelude Data.Array.Diff> replaceDiffArray arr [(4, 444)]
> array (1,3) [(1,1),(2,2),(3,3)]
>
> It looks like replaceDiffArray can not be used to add new element to the end
> of array?
IArray instance with better performances for update than the classic
IArray instance (which copy the entire content on every update...).
There are some libraries that allows you to change the size of your
array, be aware though that this operation is very costly (in every
language).
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ArrayRef
--
Jedaï