Raised This Month: $ Target: $400
 0% 

ArrayX


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 11-06-2007 , 01:03   ArrayX
Reply With Quote #1

New iteration of ArrayX, now with moar awesome.

I've upgraded arrays and keytables to use the cellarray syntax and a unified return structure, making it much easier to figure out (and no messy specifics).

Backward compatibility has been maintained for the most part, with a few patches needing to be fixed. Not that anyone really cares.

The main thing is that the linux version links, hopefully statically, against ++.a. It only needs three functions, but it might dynamically link, in which case, well, linux compatibility is screwed.

Tested for most functions on win32. untested, but compiled, on linux.

Have fun with it hawk.
Report any bugs quickly before I lose interest.
Attached Files
File Type: rar ArrayX.rar (764.3 KB, 854 views)
__________________

Last edited by Twilight Suzuka; 11-11-2007 at 13:02.
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
jurugi
Junior Member
Join Date: Apr 2005
Old 02-02-2008 , 23:24   Re: ArrayX
Reply With Quote #2

Today I was setting up Hawk's DPRP plugin set, which requires this module. As stated, linux is suppost to be supported. This version works; but it only does if you add it to the modules.ini as Array. The plugins which require ArrayX cannot load the module because it is named Array. Renaming the module to ArrayX of course doesn't work. Basically, it works, but the module is named Array rather than ArrayX, can you please recompile it?

Last edited by jurugi; 02-02-2008 at 23:29.
jurugi is offline
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 07-10-2008 , 17:10   Re: ArrayX
Reply With Quote #3

I am trying to learn how to code modules. I was looking at the ArrayX code and I noticed something in "arrayx_array.inc". I think this:
Code:
stock array_memory(array_id) { return array_size() * 4; }
should be like this:
Code:
stock array_memory(array_id) { return array_size(array_id) * 4; }
Sorry if I'm wrong
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
Drak
Veteran Member
Join Date: Jul 2005
Old 11-16-2008 , 12:15   Re: ArrayX
Reply With Quote #4

Small question. If anybody could answer this (Hawk?).
I don't know much about how this works, but for example:
Code:
#include <amxmodx> #include <arrayx_array> #include <arrayx_keytable> #include <arrayx_const> #define VERY_LARGE_INDEX 15000 #define RANDOM_VALUE 100 new g_Array public plugin_init() {     register_plugin("Test","Test","Test");         g_Array = array_create();     array_set_int(g_Array,VERY_LARGE_INDEX,RANDOM_VALUE); }

I'm using large index values, now how I guess i'm thinking of it (if it makes any sense) is something like this

Code:
new Array[15000] // Because Index val is 15000, it creates 15000 cells?

So basically, im asking, because I have my index val so high, does that actually cost performence, or the amount of memory the array uses?
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 11-16-2008 , 17:29   Re: ArrayX
Reply With Quote #5

Yes, it will probably take an assload of memory. Use CellTravTrie.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Drak
Veteran Member
Join Date: Jul 2005
Old 11-16-2008 , 18:02   Re: ArrayX
Reply With Quote #6

Quote:
Originally Posted by Hawk552 View Post
Yes, it will probably take an assload of memory. Use CellTravTrie.
Using your include, would something like this be correct?
Code:
#include <amxmodx> #include <celltravtrie> #define VERY_LARGE_INDEX 15000 #define RANDOM_VALUE 100 new TravTrie:g_Array public plugin_init() {     register_plugin("Test","Test","Test");         g_Array = TravTrieCreate();     TravTrieSetCellEx(g_Array,VERY_LARGE_INDEX,RANDOM_VALUE);         new RandomVal     TravTrieGetCellEx(g_Array,VERY_LARGE_INDEX,RandomVal);         server_print("Random Value: %d",RandomVal); } public plugin_end()     TravTrieDestroy(g_Array);
Which works, but does this actually use less memory?
And then, I'm pretty un-knowledgeable on these "iterator's" if they should be used instead of what I did.
__________________
Oh yeah

Last edited by Drak; 11-16-2008 at 18:05.
Drak is offline
Send a message via MSN to Drak
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 11-17-2008 , 14:02   Re: ArrayX
Reply With Quote #7

Your script looks correct. It will use much, much less memory (it's only using a relatively short string and a cell as opposed to every cell between 0 and VERY_LARGE_INDEX) on top of all the advantages CellTravTrie gives. I can't remember whether it was you who mentioned that you noticed CellTravTrie in ARP, but if not, go check it out because it uses it quite a lot.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Drak
Veteran Member
Join Date: Jul 2005
Old 11-17-2008 , 15:47   Re: ArrayX
Reply With Quote #8

Quote:
Originally Posted by Hawk552 View Post
Your script looks correct. It will use much, much less memory (it's only using a relatively short string and a cell as opposed to every cell between 0 and VERY_LARGE_INDEX) on top of all the advantages CellTravTrie gives. I can't remember whether it was you who mentioned that you noticed CellTravTrie in ARP, but if not, go check it out because it uses it quite a lot.
Yeah it was me, and thanks for all the answers.
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-16-2009 , 18:50   Re: ArrayX
Reply With Quote #9

EDIT: This module is not working as expected and amxmodx has this functionality integrated. So the test results are invalid. I will post the results using the amxmodx provided functions later.

This module can be very useful and can improve many plugins. (I assume that amxmodx don't have the functionality described bellow (without using this module)).

One particular example is:

Advanced Bans (Real Time) by Exolent

It serves as bridge between pawn and some C++ data structures. An example of its usage:

When you deal with data related to players you use an 33 cells array. If you want to check the data relative to one of the users you access array[id]. It is the faster way possible because you just need to make one access to memory.

But what about if you have a list of strings?

If you have a list of strings and want to, as an example, check if a string that you have is in the list, you normally iterate over the full list and compare your string with each one from the list. (In the worst case). The performance of an algorithm that makes this is O(N). (N strings, N comparisons)

With ArrayX module you can speed up this process using a Hash Table. It is a data structure that uses techniques to decrease the number of comparisons. Correct me if I'm wrong but i think its performance is O(log n).

Anyway using amxmodx profiler i made a test. The script and its measurement's output go as attachments.

It makes 10000 calls to a function that compares a steamID against a list of 22 steamID's.

With ArrayX it is 12x faster.
Attached Files
File Type: sma Get Plugin or Get Source (test.sma - 812 views - 1.4 KB)
File Type: txt test.txt (2.4 KB, 263 views)
__________________

Last edited by joaquimandrade; 03-16-2009 at 20:03.
joaquimandrade is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 03-16-2009 , 21:15   Re: ArrayX
Reply With Quote #10

I posted a tutorial called "CellTravTrie". Use the code from that.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
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 18:20.


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