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 ?
On Fri, Jul 11, 2008 at 4:58 PM, Chaddaï Fouché <[EMAIL PROTECTED]> wrote: > 2008/7/11 Dmitri O.Kondratiev <[EMAIL PROTECTED]>: > > I don't quite understand how Data.Array.Diff work. > > 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? > > replaceDiffArray is low-level, nobody should use it, use the normal > 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) > > > 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? > > No, the size of a DiffArray can't be changed : DiffArray are just an > 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ï >
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe