Jump to content


2D Array


21 replies to this topic

#21 DrunkenCoder

    Member

  • Members
  • PipPip
  • 97 posts

Posted 04 August 2003 - 06:03 AM

Quote

memory access cache polution is STILL not a problem. as you HAVE to use my arrays the "other way around" to get the same behaviour as the original c array anyways. there is no way around it.

I never said it was a problem if you used it the way you intend I just said
that it's contra intuitive and will in most cases thrash the cache for anyone
trying to use it instead of a normal 2D array. Changing access order of arrays
is quite much like making a numberclass where + means - and - means +
sure the class author can make it compute the right things but anyone not
familar with the innerworkings of it will get into trouble with seemingly faulty
results. It's just one of those design guidelines don't surprise people with
stuff like this if it's going to act as a drop in replacement.

Quote

never said i like my code.. its merely there to be useful for newbies to see the power and the poverty of c++.. you can do everything you want, if you know how, and what. but 2d arrays in c++ are still done best by doing them 1d..

I never said you said, I just pointed out some obvious flaws and something very
close to abusive design. Im not attacking you or your ability to code Im merly
pointing out issues with the code you posted.

And about the 2D arrays are best done using 1D, yes, but wrapping them makes
them easier and less error prone to use without costing you any performance.
Also it makes it easier to have convinence functions to use STL algorithms,
and I really hope you don't dynamicly allocate 1D arrays instead of using
std::vector.

Quote

yep, line could be a subclass of array2d..

NO! It should be a member class of array2d that's probably what you ment
but a subclass is a wholy diffrenty entity.

#22 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 04 August 2003 - 06:40 AM

memberclass, subclass, bah.. yep, its what i ment..



btw, i NEVER ever used yet a c-style 2d or 3d array! NEVER. thats why i designed it that way. its the way that sounds logically for me:D

actually, when ever i use a dynamic sized array, but not dynamic resizable, i use it directly, no vector..

thats the lowlevel part of my heart beating :D
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users