471,317 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

data type for 2 D data

Tem
What would be the best data type for storing objects in a 2D array.
the ideal type would be one like generic List but Lists are only 1D. i don't
think i can have an array of lists.
The size of either the row or column is given while the size of the other
dimension can be dynamically changed.

the data type needs to be optimized for performance, only sequential
add/remove is nessesary.

any suggestions?

Tem

Apr 7 '08 #1
8 1255
I just wanted to point out that List<List<object>is perfectly fine. It may
not apply to your situation where one dimension is fixed.

"Tem" wrote:
What would be the best data type for storing objects in a 2D array.
the ideal type would be one like generic List but Lists are only 1D. i don't
think i can have an array of lists.
Apr 8 '08 #2
Tem
thanks. let me try that.

how is it performance wise?

"Family Tree Mike" <Fa************@discussions.microsoft.comwrote in
message news:D9**********************************@microsof t.com...
>I just wanted to point out that List<List<object>is perfectly fine. It
may
not apply to your situation where one dimension is fixed.

"Tem" wrote:
>What would be the best data type for storing objects in a 2D array.
the ideal type would be one like generic List but Lists are only 1D. i
don't
think i can have an array of lists.
Apr 8 '08 #3
Pardon me if I do not understand the problem statement
But, wouldn't jagged array work

e.g. Person[][] mydata = new Person[9][];
mydata[0] = new Person[4];
mydata[1] = new Person[n];

HTH
Kalpesh

On Apr 7, 8:41 pm, "Tem" <tem1...@yahoo.comwrote:
thanks. let me try that.

how is it performance wise?

"Family Tree Mike" <FamilyTreeM...@discussions.microsoft.comwrote in
messagenews:D9**********************************@m icrosoft.com...
I just wanted to point out that List<List<object>is perfectly fine. It
may
not apply to your situation where one dimension is fixed.
"Tem" wrote:
What would be the best data type for storing objects in a 2D array.
the ideal type would be one like generic List but Lists are only 1D. i
don't
think i can have an array of lists.
Apr 8 '08 #4
Tem
I need to be able to change the size of the array as needed. can this be
done with jagged array?

<sh***********@gmail.comwrote in message
news:1f**********************************@e10g2000 prf.googlegroups.com...
Pardon me if I do not understand the problem statement
But, wouldn't jagged array work

e.g. Person[][] mydata = new Person[9][];
mydata[0] = new Person[4];
mydata[1] = new Person[n];

HTH
Kalpesh

On Apr 7, 8:41 pm, "Tem" <tem1...@yahoo.comwrote:
>thanks. let me try that.

how is it performance wise?

"Family Tree Mike" <FamilyTreeM...@discussions.microsoft.comwrote in
messagenews:D9**********************************@ microsoft.com...
>I just wanted to point out that List<List<object>is perfectly fine.
It
may
not apply to your situation where one dimension is fixed.
"Tem" wrote:
>What would be the best data type for storing objects in a 2D array.
the ideal type would be one like generic List but Lists are only 1D. i
don't
think i can have an array of lists.
Apr 8 '08 #5
That is an array of lists, and is a real pain to resize; you can't
change the array, and you'd need to change every list individually. If
you went down this route, a list of arrays (List<T[]>) would be a better
option - at least then you can just add a new T[] as a new row; it is
still jagged, however.

The linearized Matrix<TI posted earlier handles all this in a single
list, and allows you to have either axis pinned. You could probably
loser all the ITypedList stuff without too much pain, though ;-p

Marc
Apr 8 '08 #6
Cool, man !

Thanks for sharing it,
Apr 8 '08 #7
Agreed. I posted a response to what the poster had asked, I think, before I
saw your other post. I wanted the poster to see what was possible. I liked
(and prefered) your solution!

"Marc Gravell" wrote:
That is an array of lists, and is a real pain to resize; you can't
change the array, and you'd need to change every list individually. If
you went down this route, a list of arrays (List<T[]>) would be a better
option - at least then you can just add a new T[] as a new row; it is
still jagged, however.

The linearized Matrix<TI posted earlier handles all this in a single
list, and allows you to have either axis pinned. You could probably
loser all the ITypedList stuff without too much pain, though ;-p

Marc
Apr 8 '08 #8
Tem
wow thanks for sharing!

Does anyone know how to limit the capacity of a regular List<>?

"Marc Gravell" <ma**********@gmail.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
That is an array of lists, and is a real pain to resize; you can't change
the array, and you'd need to change every list individually. If you went
down this route, a list of arrays (List<T[]>) would be a better option -
at least then you can just add a new T[] as a new row; it is still jagged,
however.

The linearized Matrix<TI posted earlier handles all this in a single
list, and allows you to have either axis pinned. You could probably loser
all the ITypedList stuff without too much pain, though ;-p

Marc
Apr 8 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Thomas Paul Diffenbach | last post: by
4 posts views Thread by Dan | last post: by
4 posts views Thread by toby989 | last post: by
10 posts views Thread by oktayarslan | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.