[Arrays] Random Access Times ?

Hal Daume III hdaume@ISI.EDU
Sun, 4 May 2003 08:48:56 -0700 (PDT)

> Well, ok, but I still want to get the fastest array
> available at this moment and I yet only have one array
> working with Hugs. If you know a way how I can
> implement that it in GHC, I would be pleased to hear
> it.

Well, you can use boxed or unboxed IO Arrays.  Unboxed will be faster
(depending on what you're doing, around 2-10 times faster).  A boxed array
means that if you have:

  IOArray Int Int

then this is essentially represented as:

  int* array[]

where each array element holds a pointer to the int.  Unboxed means that
the array holds the actual elements.  Obviously unboxed arrays are
strict.  They're significantly faster though.

You should be able to just use the code you were using in hugs in GHC and
it should compile fine.

 - Hal