|
Author
|
Message
|
|
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
|

04-30-2013
, 23:51
Re: How does pawn handle arrays and which way is better.
|
#1
|
Quote:
Originally Posted by .Dare Devil.
Hello, Im pretty curious about arrays like this
PHP Code:
new something[256]
now there is
PHP Code:
new something[4] // lets do small array for example, i ofcourse prefer always the big ones :)
public myfunction(pos, value) { something[pos] = value
}
is it same like this?
PHP Code:
new something0,something1,something2,something3 public myfunction(pos, value) { switch(pos) { case 0: something0 = value case 1: something1 = value case 2: something2 = value case 3: something3 = value
}
}
the way i understand things right now is that the first code is better and faster way and it does not matter if the array size is big or small, it does not effect the cpu speed.
|
You can test it to see if it works the same. In your example the difference is likely negligible and you should code for readability/flexibility/maintainability.
Quote:
Originally Posted by .Dare Devil.
I was an idea for creating big array like this Float:chuckdata[8000][3]
so inside of chuckdata are costom areas ( values are in bit )
so i can just easily check that if player is in costom area
PHP Code:
static Float:o[3],a, b pev(id, pev_origin, o) for( a = 0; a < 3; a++ ) { b = floatround(o[a] + 4000.0) // i dont know that if its right, i dont know about bits, never tested them and i was thinking that they are useless what is very wrong. I want to check here like if( o[a] != mybit) you know what i mean with that... :) if( chuckdata[b][a] ~ mybit) return }
// and now if cpu is here then player is standing in area what is in my database. // i need to use bits because then i can but more than one areas in one place for example ( and also if area is inside of ohter area, bits will help me. )
|
What in the world are you trying to do here? If you think you need to make an array that big then I would guess that you need to rethink how you are doing it.
__________________
Last edited by fysiks; 04-30-2013 at 23:52.
|
|
|
|