Reply to Re: Array comparison question

Your name:

Reply:


Posted by Simon Stienen on 04/03/07 01:32

You could array_intersect + array_unique before array_diffing to get the
part numbers that are in common first. This speeds up array_diff, since it
has to compare fewer items. However, as you have to array_intersect (+
array_unique) first, overall performance might even be decreased.

Another approach might be to array_flip the common numbers instead off
array_uniqueing them (since flipping does unique them anyway), then looping
the arrays yourself using foreach or array_filter and check for the
existance of he number using isset($common_flipped[$number]). I'm not into
PHPs array interna, but this might use a search tree (as it's an index
lookup) and therefore a complexity of O(log(n)) per item, while I suspect
array_diff to iterate through the items, therefore having a complexity of
O(n). AIMB: I'm not into the interna, but it might be faster at large tile
lists.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация