two-dimensional arrays

P

PJ6

I've chosen to store the contents of a grid in a two dimensional object
array. As the size of the grid changes, so must the array. I was surprised
to find out that the niceties I'm used to with one dimensional arrays are
just not there with more dimensions. No ReDim (except for the rightmost
dimension), no CopyTo. Now for resizing I can get around this with my own
loops, but I was wondering if I wasn't missing something... more built in
(and therefore probably faster) for multi-dimensional array resizing.

Paul
 
T

tommaso.gastaldi

Hi Paul,
in a similar situation I have found to be more convenient and efficient
to work with an ArrayList of Objects().

You might consider this option as well. Vb does not seem to give its
best with multidimensional structures...

let's see some other opinions about that ...

-tom

PJ6 ha scritto:
 
P

PJ6

Hmmm. Well I guess I can use the DataTable, though I'll be using my own row
and column collections. Yes, that works rather nicely.

Thanks,
Paul
 
M

Michel Posseth [MCP]

Instead of a 2 dimensional array you might investigate Jagged Arrays

a big advantage is that you can use redim preserve and they are up to five
or six times faster as a multidimensional array
can you inmagine how much faster it will be as a datatable :)

regards

Michel Posseth [MCP]
 
P

PJ6

Hmmm...

Private MyTable As New Collections.Generic.Dictionary(Of Row,
Collections.Generic.Dictionary(Of Column, Cell))

Well that works.

I don't know if it performs faster but the housekeeping isn't too bad for
add and remove rows and columns and it's strongly typed.

Yeah I like that better. Thanks for the suggestion.

Paul

Michel Posseth said:
Instead of a 2 dimensional array you might investigate Jagged Arrays

a big advantage is that you can use redim preserve and they are up to five
or six times faster as a multidimensional array
can you inmagine how much faster it will be as a datatable :)

regards

Michel Posseth [MCP]




PJ6 said:
I've chosen to store the contents of a grid in a two dimensional object
array. As the size of the grid changes, so must the array. I was
surprised to find out that the niceties I'm used to with one dimensional
arrays are just not there with more dimensions. No ReDim (except for the
rightmost dimension), no CopyTo. Now for resizing I can get around this
with my own loops, but I was wondering if I wasn't missing something...
more built in (and therefore probably faster) for multi-dimensional array
resizing.

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top