Home All Groups Group Topic Archive Search About

two-dimensional arrays

Author
10 Jun 2006 12:13 AM
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

Author
10 Jun 2006 12:39 AM
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:

Show quoteHide quote
> 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
Author
10 Jun 2006 5:35 AM
Cor Ligthert [MVP]
Paul,

Microsoft has made around the standard (Data)Grids the most sophisticated OO
classes.

They all are in the system.data namespace.

For what you write I would first have a look at the DataTable.
You can make them by code.

Our website is full of samples which start with this.

Here a very simple one

http://www.vb-tips.com/default.aspx?ID=65a5ae57-d41c-4144-b9f9-d0e5d6bcb7e2

I hope this helps,

Cor

Show quoteHide quote
"PJ6" <no***@nowhere.net> schreef in bericht
news:eDh4xKCjGHA.4304@TK2MSFTNGP03.phx.gbl...
> 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
>
Author
10 Jun 2006 8:31 PM
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

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:OpsO29EjGHA.5020@TK2MSFTNGP02.phx.gbl...
> Paul,
>
> Microsoft has made around the standard (Data)Grids the most sophisticated
> OO classes.
>
> They all are in the system.data namespace.
>
> For what you write I would first have a look at the DataTable.
> You can make them by code.
>
> Our website is full of samples which start with this.
>
> Here a very simple one
>
> http://www.vb-tips.com/default.aspx?ID=65a5ae57-d41c-4144-b9f9-d0e5d6bcb7e2
>
> I hope this helps,
>
> Cor
>
> "PJ6" <no***@nowhere.net> schreef in bericht
> news:eDh4xKCjGHA.4304@TK2MSFTNGP03.phx.gbl...
>> 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
>>
>
>
Author
11 Jun 2006 5:35 PM
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]




Show quoteHide quote
"PJ6" <no***@nowhere.net> schreef in bericht
news:eDh4xKCjGHA.4304@TK2MSFTNGP03.phx.gbl...
> 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
>
Author
11 Jun 2006 6:26 PM
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

Show quoteHide quote
"Michel Posseth [MCP]" <mic***@posseth.com> wrote in message
news:eFzLR3XjGHA.4040@TK2MSFTNGP05.phx.gbl...
>
> 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" <no***@nowhere.net> schreef in bericht
> news:eDh4xKCjGHA.4304@TK2MSFTNGP03.phx.gbl...
>> 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
>>
>
>