[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
c++ nub here Why is declaring a 2d vector such a fucking mess
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 13
Thread images: 2
File: brupU.jpg (28 KB, 500x392) Image search: [Google]
brupU.jpg
28 KB, 500x392
c++ nub here

Why is declaring a 2d vector such a fucking mess

they couldn't think of anything more intuitive than
std::vector< std::vector< float > > item ( height, std::vector<float> ( width, 0 ) );
?

Is there a better alternative?
>>
Java
>>
>>52193856
thanks for being helpful, I knew I shouldn't have asked this shithole.
>>
>>52193856
I don't want to deal with class names a mile long
>>
>>52194070
then your naming conventions are to blame, not java retard
>>
That's not a "2d vector" you fucking moron. That's a dynamically sized list of dynamically sized lists of numbers.

Please invent a time machine then go back and abort yourself.
>>
2d vector in c++:
float twodvector[y][x]
>>
>>52194070
>System.out.println();
Disgusting
>>
>>52194710
dynamically sized list = vector

dynamically sized list * dynamically sized list = vector * vector = 2d vector

kill yourself
>>
If you care that much you can typedef a shorter name
>>
File: 1451230563033.png (286 KB, 468x342) Image search: [Google]
1451230563033.png
286 KB, 468x342
>>52194060
>posts a shrek meme picture
here's your you
>>
Use the Go, Rob.
>>
>>52196104

No, retard. That's a vector of vectors.

A dynamically sized list of dynamically sized lists does not replace 2d arrays. That's a data structure where each "row" has its own independent size and are all independently dynamically allocated and managed.

A "2d vector" (which is not fucking real terminology when talking about data structures, it's called a two-dimensional array, but OP is too fucking stupid to know that a "vector" in C++ is a dynamically sized array) is just two coordinates mapped on to a single array, i.e. a single array indexed using y*height+x, not thousands of independently allocated arrays
Thread replies: 13
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.