Arrays (Better coding methods) Expirenced programmers only
3 Attachment(s)
[OFF TOPIC]Like title says I don't want people who don't know what their talking about giving dumb answers.[/OFF TOPIC]
[ON TOPIC] Ok so what I want to know is which method is better for reading and speed. Say you want to store two or more values per user that have to do with the same thing. What would be a better way of storing it. (Explained in detail below) 1) 2D array with player ID first then split into two or three 2) 2D array split in two or three then into player IDs 3) 2 or more different arrays of just player IDs Method #1: 2D array Player first (Code then diagram attached) Code:
Method #2: 2D array split first (Code then diagram attached) Code:
Code:
Keep in mind that I'm not talking about just saving kills and deaths that was just the first things that came to mind when typing this for an example. |
There is no significant difference between all three; the difference is in how readable your code is.
|
how about Method #4: The solution for really experienced coders :roll:
Code:
|
Quote:
Honestly, for such a simple thing, using an enum is not useful or faster. |
it's technically faster to use two separate arrays as you remove an indirection.
it's also more readable. |
Quote:
|
Right, slightly faster. One memory access faster.
And no, it won't take more memory. It takes the exact same amount of memory. |
Ok, it was just a thought I had today and wanted an answer.
capndurk, I said expirenced programmers only for a reason. I didn't want little scripters' responses. |
Quote:
|
Quote:
1 & 2 use the same, and 3 method is 1 less, because it uses an array with 1 less level. And it's not like I was contributing to the discussion, I was just asking a question that I thought needed attention. So sue me for trying to learn. |
| All times are GMT -4. The time now is 16:37. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.