Raised This Month: $ Target: $400
 0% 

TrieCreate -- what is it? How to use it.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gamer99
Senior Member
Join Date: Jul 2011
Old 09-19-2011 , 06:25   TrieCreate -- what is it? How to use it.
Reply With Quote #1

Hi All ,


I saw in one of ConnorMcLeod's plugin he is using TrieCreate.

Can somebody tell me what is it and how to use it ?

I am just learning. So don't scold me.
__________________
Thanks and regards,
Gamer99
gamer99 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-19-2011 , 06:49   Re: TrieCreate -- what is it? How to use it.
Reply With Quote #2

It allows you to associate a key to something (integer, string or array), so a keytable.
And it's unlimited.

// Creating a trie
new handle = TrieCreate()

// Inserting a new key
TrieSetCell( handle, "gamer99", 1337 );
TrieSetCell( handle, "blabla", 123 );
...

// Checking if a key exists in the table
new bool:result = TrieKeyExists( handle, "gamer99" );

// Checking existing key/Retrieving its associated value
new value;
new bool:result = TrieGetCell( handle, "gamer99", value );

You get the idea.
To get more examples, simply look at the plugins. Many plugins use Trie. (Some default plugin too If I remember)
__________________

Last edited by Arkshine; 09-19-2011 at 09:36.
Arkshine is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 09-19-2011 , 06:51   Re: TrieCreate -- what is it? How to use it.
Reply With Quote #3

It can assign an unlimited amount of arrays/strings to values.
PHP Code:
new Trie:tAwesomenessLevel TrieCreate();

SetTrieCell(tAwesomenessLevel"hleV"1337);
SetTrieCell(tAwesomenessLevel"ConnorMcLeod", -1); 
For more functions check celltrie.inc.
__________________

Last edited by hleV; 09-19-2011 at 06:52. Reason: Damn Arkshine...
hleV is offline
gamer99
Senior Member
Join Date: Jul 2011
Old 09-19-2011 , 06:52   Re: TrieCreate -- what is it? How to use it.
Reply With Quote #4

Thank you for your nice explanation.

I got the idea .
__________________
Thanks and regards,
Gamer99
gamer99 is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 09-19-2011 , 09:29   Re: TrieCreate -- what is it? How to use it.
Reply With Quote #5

As far as Exolent told me, Tries allows you to index arrays with strings instead of numbers
Heres a brief concept map:
Code:
// this is not real coding, it just gives you an idea of what tries do my_trie[ "gamer99" ] = 89 my_trie[ "Arkshine" ] = my_key // Tries also support strings my_trie[ "Arkshine" ] = "my string"
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-19-2011 , 11:44   Re: TrieCreate -- what is it? How to use it.
Reply With Quote #6

Quote:
Originally Posted by abdul-rehman View Post
As far as Exolent told me, Tries allows you to index arrays with strings instead of numbers
Heres a brief concept map:
Code:
// this is not real coding, it just gives you an idea of what tries do my_trie[ "gamer99" ] = 89 my_trie[ "Arkshine" ] = my_key // Tries also support strings my_trie[ "Arkshine" ] = "my string"
Note that you have to know what the key data type is before you retrieve it.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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:33.


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