Hash vs list

Jonathan Ellis jonathan at carnageblender.com
Fri Apr 21 21:19:45 MDT 2006


On Fri, 21 Apr 2006 20:51:59 -0600, "Levi Pearson" <levi at cold.org> said:
> Anyway, what O-notation doesn't tell you is what the constant factors  
> in the algorithm are.  It's all about how the algorithm scales.  This  
> means that if you know your problem will always be a certain size,  
> the optimal algorithm might be different than if you know your  
> problem set will grow, depending on the constant factors.

However, PHP is brain-damaged and implements lists as hashes whose keys
are the counting numbers.  (In PHP terminology, both lists and hashes
are "arrays.")  So in PHP, looking something up in a hash _is_ always
faster than searching a list, since the search is a series of hash
lookups.

-Jonathan
-- 
C++ is history repeated as tragedy. Java is history repeated as farce.  --Scott McKay




More information about the PLUG mailing list