Re: PEAR Algorithms/Containers

From: Date: Thu, 18 May 2006 13:57:28 +0000
Subject: Re: PEAR Algorithms/Containers
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-236391@lists.php.net to get a copy of this message
At 11:41 AM +0100 5/18/06, Andrew Brampton wrote:
Hi, In the past few weeks I've found the need for a hash table and a container that gives me O(log) search efficiency. Now I'm aware I can use associative arrays for my hash table, but I wanted to ensure efficiency. For my O(log) container I ended up using a sorted array, and a binary search (which I had to write). Now I thought common data structures, and algorithms, like these, and many others such as Binary Trees, Red/Black Trees and sorting algorithms and so on would be a useful addition to PHP, or more specifically PEAR, however I was unable to find any previous classes that provided these structures. So I figured I would make a set of containers and algorithms that could be used in a generic way , and hopefully put this code into PEAR. But before I start making nice PEAR code, I wanted to ask why nothing like this already exists? Is it because everyone has been to lazy until now, or is there a real reason that I'm missing that has made such structures pointless. thanks for any comments/replies Andrew
Andrew: I know what you are talking about, I wrote a splay binary-tree demo, see: http://www.sperling.com/freeware.php I've often wondered if there are algorithms like that in php buried somewhere. However, binary-trees are for searching and I use MySQL for that. I don't know specifically how MySQL preforms searches. I had hoped that somewhere one could set a bit and change the algorithms, but I haven't been able to find any references that allow that. In any event, the size of the things I work with (<50k items) are so small that it really doesn't matter for me -- and I don't know at what size where it starts to be a problem for others. So, if I was to take my previous code and port it over to php, I would most certainly test it against MySQL for performance before spending too much time providing something that doesn't significantly improve the status-quo. tedd -- ------------------------------------------------------------------------------------ http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#236391) next »