Raised This Month: $12 Target: $400
 3% 

[ 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
Old 10-04-2018, 14:32
thEsp
This message has been deleted by thEsp. Reason: Misconception between static and dynamic arrays.
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-04-2018 , 17:57   Re: [ TUT ]Dynamic Array
Reply With Quote #43

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

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 #45

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
AnimalMonster
Senior Member
Join Date: May 2020
Old 04-16-2023 , 13:43   Re: [ TUT ]Dynamic Array
Reply With Quote #46

I know this is a thread from 2017 but still i have a question.. how does ArrayResize work on a Dynamic Array with Arrays?
AnimalMonster is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-16-2023 , 15:30   Re: [ TUT ]Dynamic Array
Reply With Quote #47

Quote:
Originally Posted by AnimalMonster View Post
I know this is a thread from 2017 but still i have a question.. how does ArrayResize work on a Dynamic Array with Arrays?
It resizes the array . . . I think you need to be more specific.
__________________
fysiks 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 19:09.


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