Need a good array for this...
Code:
"Locations" PHP Code:
(32) = section Name (3) = pos (1) = 1/0 Q.2 - After creating the multi-dimensional array what would be the best form to either add/use data from it? Q.3 - Should I keep the keyvalues Handle opened, so I don't need to over-stress server? Thank you very much for reading my questions. Have a great time. |
Re: Need a good array for this...
Your declaration of CreateArray wouldn't work since the declaration's first argument determines the number of values it can hold in one array entry (and functions don't allow for arguments after the closing parenthesis). The size of the adt_array is dynamic and the initial size is the second argument. I wouldn't recommend using it for your particular use case.
You could do nested adt_trie so you could just read keys out, but you'd still have to deal with iterating through the KeyValues to put them into each trie. Out of curiosity, why not just use the KeyValues directly? Since you know exactly what keys you're working with, you can use forward slashes to read a value from a subkey. Assuming transitional syntax: Code:
KeyValues kv = new KeyValues("Locations"); |
Re: Need a good array for this...
Hi nosoop, thanks for replying me this fast, I did not understand what you meant with "adt_trie", would it be possible to add an example in? Also, I want to make this project extremely flexible and dynamic, therefore I can't just do what you told me.
The project objective is to build up a menu which it's contents will be the keyvalues section name... Done Will retrieve data from the keyvalues and cache it Will use this cached data when user inputs on the menu according to the specified option.. The dirty way would be accessing the keyvalues file everytime a user inputted data, however, I don't want it like that, so I need an array that could support all those 3 data ( name, ammo ? 1:0, pos[3] ) this way it wouldn't stress the server Sorry for my bad english, looking forward for a reply. Thanks. |
Re: Need a good array for this...
The KV file is already "cached" in memory, just don't continually close/re-open it.
|
Re: Need a good array for this...
Depending on what you're doing with the data, and how often, and how big the dataset is, you can put it into an adt-array or a trie.
|
Re: Need a good array for this...
Dr greg, can you show me an example with the adt_array?
|
Re: Need a good array for this...
Are you sure you don't want to use the KeyValues? I'd say it's a good fit for what you're trying to do, provided it's accessible across your plugin (i.e., you read it once into a global handle and just call its getters / setters; if you want to write out user input, figure out what you need to change and write that specific stuff back out). As far as I can see, there's nothing dirty about accessing KeyValues that have already been read from a file (as long as you don't read from disk every time you just need to KvGetNum()).
Treat it as just another data structure like adt_* instead of just a (de)serialization format and you'll be fine. But anyways, as requested, here's an example for nested adt_trie in 1.7: Code:
StringMap config = CreateTrie(); |
Re: Need a good array for this...
Quote:
|
Re: Need a good array for this...
Quote:
|
Re: Need a good array for this...
Quote:
|
All times are GMT -4. The time now is 05:45. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.