Raised This Month: $75 Target: $400
 18% 

[ TUT ]Dynamic Array


Post New Thread Reply   
 
Thread Tools Display Modes
SpawnerF
Member
Join Date: Apr 2017
Location: Morocco
Old 07-06-2017 , 11:46   Re: [ TUT ]Dynamic Array
Reply With Quote #41

Hi,

Code:
"An array follows the same rules as a regular variable"
How?

A regular variable when it's created it creates a new place in memory when we add/remove a value on it it creates also a new place in memory so you mean that Array:_ArrayName does the same?

Code:
"* These are not designed to be used as a replacement for normal arrays, as
* normal arrays are faster and should be used whenever possible."
Of course, since we can add more than the specified size in a static array . So i don't see how it's smart ...

Also is there a way to add a key and pair to the Array something like that?


Code:
ArrayPush( _ArrayName, key, pair );

Also if it would be good if a duplicate check ( boolean ) added in pushString and others, if it's true then you can add Duplicated items but if it's false skip them.

why cellsize is equal to 1? Since the Array that we have created is Empty at the begining shouldn't be Size equal to 0?

Code:
ArrayCreate( cellsize=1 );

And thank's for your effort.
__________________
XX was created just for giving evidence and not meant to damage public servers.
&We do not test on public servers.
Thank's.
SpawnerF is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-06-2017 , 14:00   Re: [ TUT ]Dynamic Array
Reply With Quote #42

Quote:
why cellsize is equal to 1? Since the Array that we have created is Empty at the begining shouldn't be Size equal to 0?
It's not the size of the array. Dynamic arrays have no fixed size, that's why they exists, to let you store unlimited data. The cellsize param is the size of the data that will be stored in that array. Since I used it to store integers, cellsize is 1. If I stored strings with 128 size, then I would have used 128 there.

Quote:
Also is there a way to add a key and pair to the Array something like that?
You can pair a trie with arrays, it can do wonders.

Quote:
Of course, since we can add more than the specified size in a static array . So i don't see how it's smart ...
I'm not sure to understand what you mean. A "normal" array has a fixed size. I said it' "smart" more as a joke, but it tells you that if you don't work with unkown number of elements or elements without a known maximum, then you should always use normal arrays. For example, if you want to store kills per player, it is better to use a normal array, as you know you have only 32 players at max. If you had to read a file and save all data, it is good to use a dynamic array, as you don't know how many things are in that file.
__________________
HamletEagle is offline
thEsp
Veteran Member
Join Date: Aug 2017
Location: Gjilan, Albania
Old 10-04-2018 , 14:32   Re: [ TUT ]Dynamic Array
Reply With Quote #43

Maybe Im late here. But how can I change arrays ?

As an integer it would be
Quote:
randomThing = 1
I tried following codes
Quote:
randomThing[1] = 1 ,,, randomThing[0] = 1 ,,, randomThing[id] = 1
but all turned to not work. PLZ Help me asap !.
__________________

Last edited by thEsp; 10-04-2018 at 14:34.
thEsp is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-04-2018 , 17:57   Re: [ TUT ]Dynamic Array
Reply With Quote #44

Show your array.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Midnight Kid
Junior Member
Join Date: Aug 2017
Location: Chernobay, Ukraine
Old 06-19-2019 , 03:06   Re: [ TUT ]Dynamic Array
Reply With Quote #45

Can you give an example of creating a menu based on an array of items whose output is controlled by toggle-cvar?
Midnight Kid is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-19-2019 , 05:04   Re: [ TUT ]Dynamic Array
Reply With Quote #46

Quote:
Originally Posted by Midnight Kid View Post
Can you give an example of creating a menu based on an array of items whose output is controlled by toggle-cvar?
Suggestions/requests section is here: https://forums.alliedmods.net/forumdisplay.php?f=12
__________________
HamletEagle is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:03.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode