<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Thu, 20 Jun 2013 05:41:29 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Matthew Weier O'Phinney's Blog: Taming SplPriorityQueue]]></title>
      <guid>http://www.phpdeveloper.org/news/15760</guid>
      <link>http://www.phpdeveloper.org/news/15760</link>
      <description><![CDATA[<p>
<i>Matthew Weier O'Phinney</i> has <a href="http://weierophinney.net/matthew/archives/253-Taming-SplPriorityQueue.html">a new post</a> to his blog today looking at one of the tools the <a href="http://php.net/spl">Standard PHP Library (SPL)</a> has to offer developers - the SplPriorityQueue (PHP 5.3+)
</p>
<blockquote>
<a href="http://php.net/SplPriorityQueue">SplPriorityQueue</a> is a fantastic new feature of PHP 5.3. However, in trying to utilize it in a few projects recently, I've run into some behavior that's (a) non-intuitive, and (b) in some cases at least, undesired. In this post, I'll present my solutions.
</blockquote>
<p>
He talks about the "first in, first out" nature of queues and how it differs from a stack (including links to some of the other SPL offerings for both). He then moves into the problems he was seeing - that iteration removes values from the heap and the unexpected order of equal values in the queue. To solve the first problem, he creates an "outer iterator" that creates an "innerQueue" that's protected. The solution for the second issue - the random queue order - is a simple one: priority indexes aren't required to be integers. Strings can be substituted to help make things a bit more unique.
</p>]]></description>
      <pubDate>Tue, 18 Jan 2011 12:43:54 -0600</pubDate>
    </item>
  </channel>
</rss>
