AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Building an array of tries (https://forums.alliedmods.net/showthread.php?t=162274)

Tirant 07-17-2011 01:26

Building an array of tries
 
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.

Exolent[jNr] 07-17-2011 01:41

Re: Building an array of tries
 
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
        ]
    ]
]


Tirant 07-17-2011 01:50

Re: Building an array of tries
 
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.


All times are GMT -4. The time now is 01:09.

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