This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[INC] CellTravTrie


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-16-2009 , 22:55   Re: [INC] CellTravTrie
Reply With Quote #1

Why do you have checks to see if the strings begin with the newline character? Won't you meant the null character?

Other thing: there is a recurrent "problem" in her coding (it also happens in ArrayX):

This:

PHP Code:
stock bool:TravTrieSetCell(TravTrie:trie, const key[], any:value)
{
    if(
key[0] == '^n') return false;
    
    new 
any:val;
    if(!
TravTrieGetCell(triekeyval) )
    {
        new Array:
iter;
        if(!
TrieGetCell(Trie:trie,"",any:iter)) return false;
    
        
ArrayPushString(Array:iter,key);
    }
    if(
key[0] == '^n') return false;
    
    
TrieSetCell(Trie:trie,key,value);
    return 
true;

should be:

PHP Code:
stock bool:TravTrieSetCell(TravTrie:trie, const key[], any:value)
{
    if(
key[0] == '^n') return false;
    
    new 
any:val;
    if(!
TravTrieGetCell(triekeyval) )
    {
        new Array:
iter;
        if(!
TrieGetCell(Trie:trie,"",any:iter)) return false;
    
        
ArrayPushString(Array:iter,key);

        if(
key[0] == '^n') return false;
    }
    
    
TrieSetCell(Trie:trie,key,value);
    return 
true;

In keytable_natives.cpp she has
PHP Code:
if(== endhandle->lower_bound(start);
if(
== endhandle->upper_bound(start);
if(
== end) return 0;
else 
len--; 
It should be:

PHP Code:
if(== end
{
    
handle->lower_bound(start)
        
    if(
== end)
        
handle->upper_bound(start);
}

if(
== end)
    return 
0
else
    
len-- 
Not that it matter that much to performance but i thought that she has extremely rigorous at coding. It seems that she prefers to compact the code instead of making it more accurate
__________________

Last edited by joaquimandrade; 03-16-2009 at 23:32.
joaquimandrade is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 03-16-2009 , 23:25   Re: [INC] CellTravTrie
Reply With Quote #2

I don't think it can store a "^n" as the key. Also, you're right about the problem. It's a trivial optimization, though.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-16-2009 , 23:36   Re: [INC] CellTravTrie
Reply With Quote #3

Quote:
Originally Posted by Hawk552 View Post
I don't think it can store a "^n" as the key. Also, you're right about the problem. It's a trivial optimization, though.
I don't believe in that. The character '^n' is, for the programming language, the same as any other, except the 0. And, the code just checks if it starts by '^n' so, it can have ^n's thereafter. So, i think it was meant to be a 0.
__________________

Last edited by joaquimandrade; 03-17-2009 at 01:09.
joaquimandrade is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 03-16-2009 , 23:45   Re: [INC] CellTravTrie
Reply With Quote #4

I never tested it because I assumed that Suzuka knew what it was doing. You're probably right, though.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-16-2009 , 23:50   Re: [INC] CellTravTrie
Reply With Quote #5

Quote:
Originally Posted by Hawk552 View Post
I never tested it because I assumed that Suzuka knew what it was doing. You're probably right, though.
Please enlight me over this:

What does this include makes you able to do, that you can't do without it?
__________________
joaquimandrade is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 03-16-2009 , 23:52   Re: [INC] CellTravTrie
Reply With Quote #6

It allows you to traverse a trie. Without this header, you can't traverse it.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-16-2009 , 23:57   Re: [INC] CellTravTrie
Reply With Quote #7

Quote:
Originally Posted by Hawk552 View Post
It allows you to traverse a trie. Without this header, you can't traverse it.
Ok. Thanks. Sorry for bothering.
__________________
joaquimandrade 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 17:33.


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