Raised This Month: $ Target: $400
 0% 

Building an array of tries


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 07-17-2011 , 01:26   Building an array of tries
Reply With Quote #1

I wanted to try and make some sort of arrays of tries with indexes based off of the plugin id's. Each index would then be a Trie table storing the function names. I wanted to try and create a way to track certain functions within certain plugins, but I can't use the function ids because they aren't unique, and function names can be the same in different plugins. I was wondering if anyone had any different ideas on how to approach this. Since the array would have to be the size of get_pluginsnum(), it would have to be instantiated at runtime, but the plugins that aren't used would just be left uninitialized until they are initialized (if they need to be used).

From the top of my head, it would look something like this...

Code:
new Array:myArray;

public plugin_init() {
    myArray = ArrayCreate(1);
    for (new i; i < get_pluginsnum(); i++) {
         new Trie:myTrie = TrieCreate();
         ArrayPushCell(myArray, i, myTrie);
    }
}
I haven't actually tried it yet, but that's just what is in my head.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]

Last edited by Tirant; 07-17-2011 at 01:39.
Tirant is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-17-2011 , 01:41   Re: Building an array of tries
Reply With Quote #2

Code:
container: Array
[
    plugin_id: Array
    [
        function_name: string
    ]
]
That seems the simplest structure to me.

If you wanted to also store function IDs:

Code:
container: Array
[
    plugin_id: Array
    [
        function_names: Array
        [
            function_name
        ],
        function_ids: Trie
        [
            function_name: function_id
        ]
    ]
]
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 07-17-2011 , 01:50   Re: Building an array of tries
Reply With Quote #3

Ya, cause what I'm trying to do is create a structure that stores plugin ids and function ids, but the way it is right now, I'm creating a new cell every time they initialize a new command. What I'm trying to do is store new commands when they need and just make the IDs refer the the command that was created. Like if there are 2 different commands that execute the same function. So the array's trie cell references the index of the registered function in the array.

Thanks for your advice.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
Reply



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 01:09.


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