Raised This Month: $ Target: $400
 0% 

Diferencia de Métodos


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 03-13-2012 , 23:13   Diferencia de Métodos
#1

Bueno vengo con una pregunta que me gustaría que respondieran para ver cuánto saben, es algo simple. Me encantaría que probaran esto con profile y me dijeran si hay alguna diferencia de tiempo en completar la llamada a la función.

Usando esta cadena
PHP Code:
new g_String[10][] =
{
    
"hola",
    
"adios",
    
"oso",
    
"pato",
    
"tigre",
    
"comer",
    
"dormir",
    
"saltar",
    
"jugar",
    
"goma"

Método 1:
PHP Code:
bool:YourFunction(const string[])
{    
    new 
bool:found false
    
for(new isizeof g_Stringi++)
    {    
        if(
equal(stringg_String[i]))
        {
            
found true
            
break
        }
    }
    return 
found    

Método 2:
PHP Code:
YourFunction(const string[])
{    
    for(new 
isizeof g_Stringi++)
    {    
        if(
equal(stringg_String[i]))
        {
            return 
1
        
}
    }
    return 
0    

Usando estos 2 ejemplos, como es más eficiente?


PS: La idea es que escriban ustedes un string y verificar si existe en la cadena ya mencionada y fijarse cual se llama más rápido.

Respuesta: http://forums.alliedmods.net/showpos...1&postcount=10
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).


Last edited by gladius; 03-14-2012 at 14:52.
gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
 



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 06:57.


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