Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 12th, 2006, 6:52 PM   #1
52Degrees
Newbie
 
Join Date: May 2006
Location: Central Valley, Kalifornia
Posts: 13
Rep Power: 0 52Degrees is on a distinguished road
Trouble understanding simple concepts

I'm reading my C# book just about every day during lunchtime since that is the best time for me to understand new stuff.

I'm in the middle of learning about arrays and come up to these "jagged" arrays. I can understand the idea of arrays having non constant dimensions, but there's something I just don't get.

int [,,] ia3d=new int [3,2,4] {{{8, 3, 4, 2}, {7, 4, 1, 2}},
                               {{2, 7, 3, 6}, {5, 1, 9, 0}},
                               {{0, 4, 9, 7}, {3, 9, 8, 5}}};

Can someone (or several of you) explain to me what is happening in this line in such a manner that I might understand it?

Thanks.
52Degrees is offline   Reply With Quote
Old Jun 12th, 2006, 7:16 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Why do you call them jagged arrays? It's quite regular. Consider a spreadsheet with 10 columns and 4 rows. That isn't even, but it's regular. Now consider a second sheet behind that one, with the same 10 columns and 4 rows. You now have a multidimensional array that is 2 x 4 x 10. Add rows. Add columns. Add row:n col m: on page 1 to row:n col:m on page 2. No biggie.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 12th, 2006, 7:34 PM   #3
52Degrees
Newbie
 
Join Date: May 2006
Location: Central Valley, Kalifornia
Posts: 13
Rep Power: 0 52Degrees is on a distinguished road
The book I'm reading called them jagged. That wasn't the problem I'm having.

[3,2,4] I'm seeing this a 3 high, 2 wide and 4 deep, right?




Oh, SHIT!!!

Nevermind. I'm an idiot.
52Degrees is offline   Reply With Quote
Old Jun 12th, 2006, 7:40 PM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
It does vary from language to language (Fortran is not the same as C). I don't know dink about C#, but it's probably the same as C/C++: [most significant]....[least significant]. Least significant signifying that the index is the most rapidly varying. A true array can be represented by a linear stretch of memory, regardless of dimensions.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 12th, 2006, 7:47 PM   #5
52Degrees
Newbie
 
Join Date: May 2006
Location: Central Valley, Kalifornia
Posts: 13
Rep Power: 0 52Degrees is on a distinguished road
Yeah. I was having a momentary lapse of reason. For some reason I was looking at that line and just not understanding what i was seeing. It was really frustrating because I knew that I knew it, but couldn't figure it out.
52Degrees is offline   Reply With Quote
Old Jun 12th, 2006, 8:12 PM   #6
Jason Isom
Programmer
 
Join Date: Dec 2005
Posts: 53
Rep Power: 3 Jason Isom is on a distinguished road
Quote:
Originally Posted by 52Degrees
Yeah. I was having a momentary lapse of reason. For some reason I was looking at that line and just not understanding what i was seeing. It was really frustrating because I knew that I knew it, but couldn't figure it out.
You may want to look at your book again because there is a difference between a jagged array and a regular array. What you posted is a multi-dimensional regular array, as Dawei already pointed out. If your book is calling those jagged arrays, you may want to invest in a better book.
Jason Isom is offline   Reply With Quote
Old Jun 12th, 2006, 8:34 PM   #7
52Degrees
Newbie
 
Join Date: May 2006
Location: Central Valley, Kalifornia
Posts: 13
Rep Power: 0 52Degrees is on a distinguished road
It's not, I was saying I understood that concept. What I didn't understand was what I was looking at. Because my brain decided to attempt to divide by zero or something.

Just waiting for splinter to chime in
52Degrees is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:48 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC