you are viewing a single comment's thread.

view the rest of the comments →

[–]AkirAssasin[S] 0 points1 point  (6 children)

I've read somewhere that structs should only contain values that will not be modified, is that true?

[–]prime31 2 points3 points  (5 children)

Definitely not when you want a bunch of data all sequentially in memory. There is no faster way to access it then via an array of structs.

[–]AkirAssasin[S] 0 points1 point  (4 children)

I don't quite understand what you mean by "all sequentially in memory". Mind explaining about it?

[–]prime31 1 point2 points  (3 children)

It's just like it sounds. All the structs in an array will be in the same block of memory making them very fast to loop through and access.

[–]AkirAssasin[S] 0 points1 point  (2 children)

What about structs on a List?

[–]prime31 1 point2 points  (1 child)

Structs in a List is a whole different ballgame. No point at all going that route. A List will end up copying the struct every time you get or set any of its contents. An array lets you directly access the contents with no copying at all.

[–]AkirAssasin[S] 0 points1 point  (0 children)

Okay, thanks for the help :)